annotate gtk3/dw.c @ 1918:1814a6577a5f

Import the same changes into the GTK3 MDI code... which is now disabled by default.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 28 Sep 2016 22:58:41 +0000
parents 933b5f7005a9
children 78a65391dbcb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2 * Dynamic Windows:
1386
fd1de4e9e542 Updated the readme and comments in the source files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1384
diff changeset
3 * A GTK like cross-platform GUI
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4 * GTK3 forwarder module for portabilty.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5 *
1912
5035750bcc65 Fix some deprecation warnings in recent GTK3 versions...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1900
diff changeset
6 * (C) 2000-2016 Brian Smith <brian@dbsoft.org>
1386
fd1de4e9e542 Updated the readme and comments in the source files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1384
diff changeset
7 * (C) 2003-2011 Mark Hessling <mark@rexx.org>
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8 * (C) 2002 Nickolay V. Shmyrev <shmyrev@yandex.ru>
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10 #include "config.h"
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11 #include "dw.h"
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
12 #include <glib/gi18n.h>
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
13 #include <string.h>
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
14 #include <stdlib.h>
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
15 #if !defined(GDK_WINDOWING_WIN32)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
16 # include <sys/utsname.h>
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
17 # include <sys/socket.h>
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
18 # include <sys/un.h>
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
19 # include <sys/mman.h>
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
20 #endif
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
21 #include <stdarg.h>
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
22 #include <stdio.h>
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
23 #include <unistd.h>
1001
4ef0e878fe06 Added support for Dynamic Windows style font names for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 998
diff changeset
24 #include <ctype.h>
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
25 #include <errno.h>
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
26 #include <sys/time.h>
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
27 #include <dirent.h>
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
28 #include <sys/stat.h>
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
29 #include <signal.h>
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
30 #include <fcntl.h>
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
31 #include <unistd.h>
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
32 #include <math.h>
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
33 #include <gdk/gdkkeysyms.h>
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
34
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
35 #ifdef USE_WEBKIT
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
36 #include <webkit/webkit.h>
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
37 #endif
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
38
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
39 #include <gdk-pixbuf/gdk-pixbuf.h>
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
40
1576
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
41 #if !GTK_CHECK_VERSION(3,1,0)
1577
fdafbc654e9d Switch to using GtkGrid instead of GtkTable in the MDI code for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1576
diff changeset
42 #error GTK 3.0 is no longer supported, please use 3.2 or later.
1576
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
43 #endif
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
44
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
45 #if __STDC_VERSION__ < 199901L
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
46 # if __GNUC__ >= 2
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
47 # define __func__ __FUNCTION__
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
48 # else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
49 # define __func__ "<unknown>"
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
50 # endif
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
51 #endif
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
52
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
53 #include "gtk/messagebox_error.xpm"
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
54 #include "gtk/messagebox_warning.xpm"
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
55 #include "gtk/messagebox_information.xpm"
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
56 #include "gtk/messagebox_question.xpm"
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
57
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
58 /* These are used for resource management */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
59 #if defined(DW_RESOURCES) && !defined(BUILD_DLL)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
60 extern DWResources _resources;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
61 #endif
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
62
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
63 /* ff = 255 = 1.0000
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
64 * ee = 238 = 0.9333
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
65 * cc = 204 = 0.8000
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
66 * bb = 187 = 0.7333
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
67 * aa = 170 = 0.6667
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
68 * 77 = 119 = 0.4667
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
69 * 00 = 0 = 0.0000
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
70 */
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
71 GdkRGBA _colors[] =
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
72 {
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
73 { 0.0000, 0.0000, 0.0000, 1.0 }, /* 0 black */
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
74 { 0.7333, 0.0000, 0.0000, 1.0 }, /* 1 red */
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
75 { 0.0000, 0.7333, 0.0000, 1.0 }, /* 2 green */
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
76 { 0.6667, 0.6667, 0.0000, 1.0 }, /* 3 yellow */
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
77 { 0.0000, 0.0000, 0.8000, 1.0 }, /* 4 blue */
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
78 { 0.7333, 0.0000, 0.7333, 1.0 }, /* 5 magenta */
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
79 { 0.0000, 0.7333, 0.7333, 1.0 }, /* 6 cyan */
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
80 { 0.7333, 0.7333, 0.7333, 1.0 }, /* 7 white */
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
81 { 0.4667, 0.4667, 0.4667, 1.0 }, /* 8 grey */
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
82 { 1.0000, 0.0000, 0.0000, 1.0 }, /* 9 bright red */
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
83 { 0.0000, 1.0000, 0.0000, 1.0 }, /* 10 bright green */
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
84 { 0.9333, 0.9333, 0.0000, 1.0 }, /* 11 bright yellow */
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
85 { 0.0000, 0.0000, 1.0000, 1.0 }, /* 12 bright blue */
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
86 { 1.0000, 0.0000, 1.0000, 1.0 }, /* 13 bright magenta */
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
87 { 0.0000, 0.9333, 0.9333, 1.0 }, /* 14 bright cyan */
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
88 { 1.0000, 1.0000, 1.0000, 1.0 }, /* 15 bright white */
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
89 };
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
90
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
91 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
92 * List those icons that have transparency first
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
93 */
1258
3df86772b625 Updated the list of supported image formats for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1245
diff changeset
94 #define NUM_EXTS 9
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
95 char *image_exts[NUM_EXTS] =
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
96 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
97 ".xpm",
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
98 ".png",
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
99 ".ico",
1258
3df86772b625 Updated the list of supported image formats for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1245
diff changeset
100 ".icns",
3df86772b625 Updated the list of supported image formats for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1245
diff changeset
101 ".gif",
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
102 ".jpg",
1258
3df86772b625 Updated the list of supported image formats for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1245
diff changeset
103 ".jpeg",
3df86772b625 Updated the list of supported image formats for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1245
diff changeset
104 ".tiff",
3df86772b625 Updated the list of supported image formats for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1245
diff changeset
105 ".bmp"
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
106 };
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
107
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
108 #ifndef max
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
109 # define max(a,b) (((a) > (b)) ? (a) : (b))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
110 #endif
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
111
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
112 #ifndef min
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
113 # define min(a,b) (((a) < (b)) ? (a) : (b))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
114 #endif
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
115
971
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
116 pthread_key_t _dw_fg_color_key;
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
117 pthread_key_t _dw_bg_color_key;
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
118 pthread_key_t _dw_mutex_key;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
119
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
120 GtkWidget *last_window = NULL, *popup = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
121
1597
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
122 static int _dw_ignore_click = 0, _dw_ignore_expand = 0;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
123 static pthread_t _dw_thread = (pthread_t)-1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
124
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
125 void (*_dw_gdk_threads_init)(void) = NULL;
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
126 void (*_dw_gdk_threads_enter)(void) = NULL;
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
127 void (*_dw_gdk_threads_leave)(void) = NULL;
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
128
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
129 #define DW_MUTEX_LOCK { if(pthread_self() != _dw_thread && !pthread_getspecific(_dw_mutex_key)) { _dw_gdk_threads_enter(); pthread_setspecific(_dw_mutex_key, (void *)1); _locked_by_me = TRUE; } }
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
130 #define DW_MUTEX_UNLOCK { if(pthread_self() != _dw_thread && _locked_by_me == TRUE) { _dw_gdk_threads_leave(); pthread_setspecific(_dw_mutex_key, NULL); _locked_by_me = FALSE; } }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
131
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
132 #define DEFAULT_SIZE_WIDTH 12
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
133 #define DEFAULT_SIZE_HEIGHT 6
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
134 #define DEFAULT_TITLEBAR_HEIGHT 22
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
135
780
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
136 #define _DW_TREE_TYPE_CONTAINER 1
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
137 #define _DW_TREE_TYPE_TREE 2
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
138 #define _DW_TREE_TYPE_LISTBOX 3
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
139 #define _DW_TREE_TYPE_COMBOBOX 4
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
140
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
141 /* Signal forwarder prototypes */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
142 static gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
143 static gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
144 static gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
145 static gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
146 static gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
147 static gint _generic_event(GtkWidget *widget, gpointer data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
148 static gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
149 static gint _activate_event(GtkWidget *widget, gpointer data);
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
150 static gint _container_enter_event(GtkWidget *widget, GdkEventAny *event, gpointer data);
785
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
151 static gint _combobox_select_event(GtkWidget *widget, gpointer data);
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
152 static gint _expose_event(GtkWidget *widget, cairo_t *cr, gpointer data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
153 static gint _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
154 static gint _tree_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
1578
36f0cfda3be3 Fix value_changed code for GTK3... thought this used to work...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1577
diff changeset
155 static gint _value_changed_event(GtkWidget *widget, gpointer user_data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
156 static gint _tree_select_event(GtkTreeSelection *sel, gpointer data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
157 static gint _tree_expand_event(GtkTreeView *treeview, GtkTreeIter *arg1, GtkTreePath *arg2, gpointer data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
158 static gint _switch_page_event(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer data);
786
0e251c2f5d08 Implemented the column click event handler...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 785
diff changeset
159 static gint _column_click_event(GtkWidget *widget, gpointer data);
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
160 static void _dw_signal_disconnect(gpointer data, GClosure *closure);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
161
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
162
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
163 #ifdef USE_WEBKIT
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
164 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
165 * we need to add these equivalents from webkitwebview.h so we can refer to
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
166 * our own pointers to functions (we don't link with the webkit libraries
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
167 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
168 # define DW_WEBKIT_TYPE_WEB_VIEW (_webkit_web_view_get_type())
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
169 # define DW_WEBKIT_WEB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), DW_WEBKIT_TYPE_WEB_VIEW, WebKitWebView))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
170 WEBKIT_API GType (*_webkit_web_view_get_type)(void) = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
171 WEBKIT_API void (*_webkit_web_view_load_html_string)(WebKitWebView *, const gchar *, const gchar *) = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
172 WEBKIT_API void (*_webkit_web_view_open)(WebKitWebView *, const gchar *) = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
173 WEBKIT_API GtkWidget *(*_webkit_web_view_new)(void) = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
174 WEBKIT_API void (*_webkit_web_view_go_back)(WebKitWebView *) = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
175 WEBKIT_API void (*_webkit_web_view_go_forward)(WebKitWebView *) = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
176 WEBKIT_API void (*_webkit_web_view_reload)(WebKitWebView *) = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
177 WEBKIT_API void (*_webkit_web_view_stop_loading)(WebKitWebView *) = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
178 WEBKIT_API void (*_webkit_web_frame_print)(WebKitWebFrame *) = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
179 WEBKIT_API WebKitWebFrame *(*_webkit_web_view_get_focused_frame)(WebKitWebView *) = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
180 #endif
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
181
874
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
182 GObject *_DWObject = NULL;
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
183 char *_DWDefaultFont = NULL;
1384
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
184 static char _dw_share_path[PATH_MAX+1] = { 0 };
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
185
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
186 typedef struct
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
187 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
188 void *func;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
189 char name[30];
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
190
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
191 } SignalList;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
192
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
193 typedef struct
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
194 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
195 HWND window;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
196 void *func;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
197 gpointer data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
198 gint cid;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
199 void *intfunc;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
200
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
201 } SignalHandler;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
202
836
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
203 #define SIGNALMAX 18
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
204
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
205 /* A list of signal forwarders, to account for paramater differences. */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
206 static SignalList SignalTranslate[SIGNALMAX] = {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
207 { _configure_event, DW_SIGNAL_CONFIGURE },
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
208 { _key_press_event, DW_SIGNAL_KEY_PRESS },
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
209 { _button_press_event, DW_SIGNAL_BUTTON_PRESS },
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
210 { _button_release_event, DW_SIGNAL_BUTTON_RELEASE },
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
211 { _motion_notify_event, DW_SIGNAL_MOTION_NOTIFY },
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
212 { _delete_event, DW_SIGNAL_DELETE },
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
213 { _expose_event, DW_SIGNAL_EXPOSE },
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
214 { _activate_event, "activate" },
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
215 { _generic_event, DW_SIGNAL_CLICKED },
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
216 { _container_enter_event, DW_SIGNAL_ITEM_ENTER },
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
217 { _tree_context_event, DW_SIGNAL_ITEM_CONTEXT },
785
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
218 { _combobox_select_event, DW_SIGNAL_LIST_SELECT },
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
219 { _tree_select_event, DW_SIGNAL_ITEM_SELECT },
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
220 { _set_focus_event, DW_SIGNAL_SET_FOCUS },
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
221 { _value_changed_event, DW_SIGNAL_VALUE_CHANGED },
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
222 { _switch_page_event, DW_SIGNAL_SWITCH_PAGE },
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
223 { _column_click_event, DW_SIGNAL_COLUMN_CLICK },
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
224 { _tree_expand_event, DW_SIGNAL_TREE_EXPAND }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
225 };
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
226
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
227 /* Alignment flags */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
228 #define DW_CENTER 0.5f
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
229 #define DW_LEFT 0.0f
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
230 #define DW_RIGHT 1.0f
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
231 #define DW_TOP 0.0f
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
232 #define DW_BOTTOM 1.0f
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
233
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
234 #ifdef DW_INCLUDE_DEPRECATED
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
235 /* MDI Support Code */
1918
1814a6577a5f Import the same changes into the GTK3 MDI code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1917
diff changeset
236 static void _dw_override_color(GtkWidget *widget, const char *element, GdkRGBA *color);
1814a6577a5f Import the same changes into the GTK3 MDI code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1917
diff changeset
237 static void _dw_override_font(GtkWidget *widget, const char *font);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
238 #define GTK_MDI(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, gtk_mdi_get_type (), GtkMdi)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
239 #define GTK_MDI_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, gtk_mdi_get_type (), GtkMdiClass)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
240 #define GTK_IS_MDI(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, gtk_mdi_get_type ())
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
241
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
242 typedef struct _GtkMdi GtkMdi;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
243 typedef struct _GtkMdiClass GtkMdiClass;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
244 typedef struct _GtkMdiDragInfo GtkMdiDragInfo;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
245 typedef enum _GtkMdiChildState GtkMdiChildState;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
246
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
247 enum _GtkMdiChildState
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
248 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
249 CHILD_NORMAL,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
250 CHILD_MAXIMIZED,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
251 CHILD_ICONIFIED
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
252 };
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
253
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
254 struct _GtkMdi
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
255 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
256 GtkContainer container;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
257 GList *children;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
258
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
259 GdkPoint drag_start;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
260 gint drag_button;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
261 };
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
262
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
263 struct _GtkMdiClass
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
264 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
265 GtkContainerClass parent_class;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
266
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
267 void (*mdi) (GtkMdi * mdi);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
268 };
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
269
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
270 #include "gtk/maximize.xpm"
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
271 #include "gtk/minimize.xpm"
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
272 #include "gtk/kill.xpm"
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
273
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
274 #define GTK_MDI_BACKGROUND "Grey70"
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
275 #define GTK_MDI_LABEL_BACKGROUND "RoyalBlue4"
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
276 #define GTK_MDI_LABEL_FOREGROUND "white"
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
277 #define GTK_MDI_DEFAULT_WIDTH 0
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
278 #define GTK_MDI_DEFAULT_HEIGHT 0
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
279 #define GTK_MDI_MIN_HEIGHT 22
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
280 #define GTK_MDI_MIN_WIDTH 55
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
281
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
282 typedef struct _GtkMdiChild GtkMdiChild;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
283
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
284 struct _GtkMdiChild
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
285 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
286 GtkWidget *widget;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
287
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
288 GtkWidget *child;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
289 GtkMdi *mdi;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
290
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
291 gint x;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
292 gint y;
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
293 gint width;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
294 gint height;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
295
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
296 GtkMdiChildState state;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
297 };
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
298
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
299 static void gtk_mdi_class_init(GtkMdiClass *klass);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
300 static void gtk_mdi_init(GtkMdi *mdi);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
301
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
302 static void gtk_mdi_realize(GtkWidget *widget);
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
303 static void gtk_mdi_size_allocate(GtkWidget *widget, GtkAllocation *allocation);
877
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
304 static gboolean gtk_mdi_draw(GtkWidget *widget, cairo_t *cr);
836
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
305 static void gtk_mdi_get_preferred_width (GtkWidget *widget, gint *minimum_width, gint *natural_width);
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
306 static void gtk_mdi_get_preferred_height (GtkWidget *widget, gint *minimum_height, gint *natural_height);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
307
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
308 /* Callbacks */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
309 static gboolean move_child_callback(GtkWidget *widget, GdkEvent *event, gpointer data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
310 static gboolean resize_child_callback(GtkWidget *widget, GdkEvent *event, gpointer data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
311 static gboolean iconify_child_callback(GtkWidget *widget, GdkEvent *event, gpointer data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
312 static gboolean maximize_child_callback(GtkWidget *widget, GdkEvent *event, gpointer data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
313 static gboolean kill_child_callback(GtkWidget *widget, GdkEvent *event, gpointer data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
314
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
315 static void gtk_mdi_add(GtkContainer *container, GtkWidget *widget);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
316 static void gtk_mdi_remove_true(GtkContainer *container, GtkWidget *widget);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
317 static void gtk_mdi_forall(GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
318
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
319 static GtkMdiChild *get_child(GtkMdi *mdi, GtkWidget * widget);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
320
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
321 static GType gtk_mdi_get_type(void)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
322 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
323 static GType mdi_type = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
324
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
325 if (!mdi_type)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
326 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
327
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
328 static const GTypeInfo mdi_info =
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
329 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
330 sizeof (GtkMdiClass),
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
331 NULL,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
332 NULL,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
333 (GClassInitFunc) gtk_mdi_class_init,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
334 NULL,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
335 NULL,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
336 sizeof (GtkMdi),
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
337 0,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
338 (GInstanceInitFunc) gtk_mdi_init,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
339 };
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
340
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
341 mdi_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkMdi", &mdi_info, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
342 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
343 return mdi_type;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
344 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
345
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
346 /* Local data */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
347 static GtkWidgetClass *parent_class = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
348
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
349 static void gtk_mdi_class_init(GtkMdiClass *class)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
350 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
351 GtkWidgetClass *widget_class;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
352 GtkContainerClass *container_class;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
353
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
354 widget_class = (GtkWidgetClass *) class;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
355 container_class = (GtkContainerClass *) class;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
356
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
357 parent_class = g_type_class_ref (GTK_TYPE_CONTAINER);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
358
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
359 widget_class->realize = gtk_mdi_realize;
877
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
360 widget_class->draw = gtk_mdi_draw;
836
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
361 widget_class->get_preferred_height = gtk_mdi_get_preferred_height;
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
362 widget_class->get_preferred_width = gtk_mdi_get_preferred_width;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
363 widget_class->size_allocate = gtk_mdi_size_allocate;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
364
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
365 container_class->add = gtk_mdi_add;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
366 container_class->remove = gtk_mdi_remove_true;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
367 container_class->forall = gtk_mdi_forall;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
368 class->mdi = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
369 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
370
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
371 static void gtk_mdi_init(GtkMdi *mdi)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
372 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
373 mdi->drag_button = -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
374 mdi->children = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
375 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
376
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
377 static GtkWidget *gtk_mdi_new(void)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
378 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
379 GtkWidget *mdi;
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
380 GdkRGBA background;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
381
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
382 mdi = GTK_WIDGET (g_object_new (gtk_mdi_get_type (), NULL));
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
383 gdk_rgba_parse (&background, GTK_MDI_BACKGROUND);
1918
1814a6577a5f Import the same changes into the GTK3 MDI code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1917
diff changeset
384 _dw_override_color (mdi, "background-color", &background);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
385
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
386 return mdi;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
387 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
388
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
389 static void gtk_mdi_put(GtkMdi *mdi, GtkWidget *child_widget, gint x, gint y, GtkWidget *label)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
390 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
391 GtkMdiChild *child;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
392
1577
fdafbc654e9d Switch to using GtkGrid instead of GtkTable in the MDI code for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1576
diff changeset
393 GtkWidget *grid;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
394 GtkWidget *button[3];
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
395
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
396 GtkWidget *child_box;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
397 GtkWidget *top_event_box;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
398 GtkWidget *bottom_event_box;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
399 GtkWidget *child_widget_box;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
400 GtkWidget *image;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
401
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
402 GdkRGBA color;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
403 gint i, j;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
404 GdkCursor *cursor;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
405 GdkPixbuf *pixbuf;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
406
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
407 child_box = gtk_event_box_new ();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
408 child_widget_box = gtk_event_box_new ();
1912
5035750bcc65 Fix some deprecation warnings in recent GTK3 versions...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1900
diff changeset
409 gtk_widget_set_margin_start(child_widget_box, 2);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
410 top_event_box = gtk_event_box_new ();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
411 bottom_event_box = gtk_event_box_new ();
1577
fdafbc654e9d Switch to using GtkGrid instead of GtkTable in the MDI code for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1576
diff changeset
412 grid = gtk_grid_new ();
fdafbc654e9d Switch to using GtkGrid instead of GtkTable in the MDI code for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1576
diff changeset
413 gtk_grid_set_row_spacing(GTK_GRID(grid), 1);
fdafbc654e9d Switch to using GtkGrid instead of GtkTable in the MDI code for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1576
diff changeset
414 gtk_grid_set_column_spacing(GTK_GRID(grid), 1);
fdafbc654e9d Switch to using GtkGrid instead of GtkTable in the MDI code for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1576
diff changeset
415
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
416 for (i = 0; i < 3; i++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
417 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
418 button[i] = gtk_event_box_new ();
1577
fdafbc654e9d Switch to using GtkGrid instead of GtkTable in the MDI code for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1576
diff changeset
419 gtk_widget_set_events (button[i], GDK_BUTTON_PRESS_MASK);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
420 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
421
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
422 gdk_rgba_parse (&color, GTK_MDI_LABEL_BACKGROUND);
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
423
1918
1814a6577a5f Import the same changes into the GTK3 MDI code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1917
diff changeset
424 _dw_override_color (top_event_box, "background-color", &color);
1814a6577a5f Import the same changes into the GTK3 MDI code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1917
diff changeset
425 _dw_override_color (bottom_event_box, "background-color", &color);
1814a6577a5f Import the same changes into the GTK3 MDI code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1917
diff changeset
426 _dw_override_color (child_box, "background-color", &color);
1894
ed377fd16360 Fix some warnings reported by clang on FreeBSD in the GTK modules.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1892
diff changeset
427 for (j = 0; j < 3; j++)
ed377fd16360 Fix some warnings reported by clang on FreeBSD in the GTK modules.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1892
diff changeset
428 {
1918
1814a6577a5f Import the same changes into the GTK3 MDI code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1917
diff changeset
429 _dw_override_color (button[j], "background-color", &color);
1814a6577a5f Import the same changes into the GTK3 MDI code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1917
diff changeset
430 _dw_override_color (button[j], "background-color", &color);
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
431 }
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
432 gdk_rgba_parse (&color, GTK_MDI_LABEL_FOREGROUND);
1918
1814a6577a5f Import the same changes into the GTK3 MDI code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1917
diff changeset
433 _dw_override_color (label, "color", &color);
1814a6577a5f Import the same changes into the GTK3 MDI code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1917
diff changeset
434 #if GTK_CHECK_VERSION(3,16,0)
1814a6577a5f Import the same changes into the GTK3 MDI code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1917
diff changeset
435 gtk_label_set_xalign(GTK_LABEL(label), 0.0f);
1814a6577a5f Import the same changes into the GTK3 MDI code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1917
diff changeset
436 gtk_label_set_yalign(GTK_LABEL(label), 0.5f);
1814a6577a5f Import the same changes into the GTK3 MDI code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1917
diff changeset
437 #else
1814a6577a5f Import the same changes into the GTK3 MDI code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1917
diff changeset
438 gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
1814a6577a5f Import the same changes into the GTK3 MDI code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1917
diff changeset
439 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
440
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
441 gtk_container_add (GTK_CONTAINER (top_event_box), label);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
442 gtk_container_add (GTK_CONTAINER (child_widget_box), child_widget);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
443 gtk_widget_set_size_request (bottom_event_box, 2, 2);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
444
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
445
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
446 pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)minimize_xpm);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
447 image = gtk_image_new_from_pixbuf(pixbuf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
448 gtk_widget_show(image);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
449 gtk_container_add (GTK_CONTAINER (button[0]), image);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
450 pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **) maximize_xpm);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
451 image = gtk_image_new_from_pixbuf(pixbuf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
452 gtk_widget_show(image);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
453 gtk_container_add (GTK_CONTAINER (button[1]), image);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
454 pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **) kill_xpm);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
455 image = gtk_image_new_from_pixbuf(pixbuf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
456 gtk_widget_show(image);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
457 gtk_container_add (GTK_CONTAINER (button[2]), image);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
458
1577
fdafbc654e9d Switch to using GtkGrid instead of GtkTable in the MDI code for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1576
diff changeset
459
1579
245e6bf51317 Fix GTK3 MDI titlebar buttons expanding... or really the label not expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1578
diff changeset
460 /* Titlebar and buttons */
245e6bf51317 Fix GTK3 MDI titlebar buttons expanding... or really the label not expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1578
diff changeset
461 gtk_widget_set_hexpand(top_event_box, TRUE);
1577
fdafbc654e9d Switch to using GtkGrid instead of GtkTable in the MDI code for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1576
diff changeset
462 gtk_grid_attach (GTK_GRID (grid), top_event_box, 0, 0, 1, 1);
fdafbc654e9d Switch to using GtkGrid instead of GtkTable in the MDI code for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1576
diff changeset
463 gtk_grid_attach (GTK_GRID (grid), button[0], 1, 0, 1, 1);
fdafbc654e9d Switch to using GtkGrid instead of GtkTable in the MDI code for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1576
diff changeset
464 gtk_grid_attach (GTK_GRID (grid), button[1], 2, 0, 1, 1);
fdafbc654e9d Switch to using GtkGrid instead of GtkTable in the MDI code for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1576
diff changeset
465 gtk_grid_attach (GTK_GRID (grid), button[2], 3, 0, 1, 1);
fdafbc654e9d Switch to using GtkGrid instead of GtkTable in the MDI code for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1576
diff changeset
466
1579
245e6bf51317 Fix GTK3 MDI titlebar buttons expanding... or really the label not expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1578
diff changeset
467 /* Window contents */
245e6bf51317 Fix GTK3 MDI titlebar buttons expanding... or really the label not expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1578
diff changeset
468 gtk_widget_set_hexpand(child_widget_box, TRUE);
245e6bf51317 Fix GTK3 MDI titlebar buttons expanding... or really the label not expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1578
diff changeset
469 gtk_widget_set_vexpand(child_widget_box, TRUE);
1577
fdafbc654e9d Switch to using GtkGrid instead of GtkTable in the MDI code for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1576
diff changeset
470 gtk_grid_attach (GTK_GRID (grid), child_widget_box, 0, 1, 4, 1);
fdafbc654e9d Switch to using GtkGrid instead of GtkTable in the MDI code for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1576
diff changeset
471
fdafbc654e9d Switch to using GtkGrid instead of GtkTable in the MDI code for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1576
diff changeset
472 /* Bottom border */
fdafbc654e9d Switch to using GtkGrid instead of GtkTable in the MDI code for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1576
diff changeset
473 gtk_grid_attach (GTK_GRID (grid), bottom_event_box, 4, 2, 1, 1);
fdafbc654e9d Switch to using GtkGrid instead of GtkTable in the MDI code for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1576
diff changeset
474
fdafbc654e9d Switch to using GtkGrid instead of GtkTable in the MDI code for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1576
diff changeset
475 gtk_container_add (GTK_CONTAINER (child_box), grid);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
476
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
477 child = g_new (GtkMdiChild, 1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
478 child->widget = child_box;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
479 child->x = x;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
480 child->y = y;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
481 child->width = -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
482 child->height = -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
483 child->child = child_widget;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
484 child->mdi = mdi;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
485 child->state = CHILD_NORMAL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
486
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
487 gtk_widget_set_parent (child_box, GTK_WIDGET (mdi));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
488 mdi->children = g_list_append (mdi->children, child);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
489
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
490 gtk_widget_show (child_box);
1577
fdafbc654e9d Switch to using GtkGrid instead of GtkTable in the MDI code for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1576
diff changeset
491 gtk_widget_show (grid);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
492 gtk_widget_show (top_event_box);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
493 gtk_widget_show (bottom_event_box);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
494 gtk_widget_show (child_widget_box);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
495 for (i = 0; i < 3; i++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
496 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
497 gtk_widget_show (button[i]);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
498 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
499
1912
5035750bcc65 Fix some deprecation warnings in recent GTK3 versions...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1900
diff changeset
500 cursor = gdk_cursor_new_for_display (gdk_display_get_default(), GDK_HAND1);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
501 gtk_widget_realize (top_event_box);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
502 gdk_window_set_cursor (gtk_widget_get_window(top_event_box), cursor);
1912
5035750bcc65 Fix some deprecation warnings in recent GTK3 versions...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1900
diff changeset
503 cursor = gdk_cursor_new_for_display (gdk_display_get_default(), GDK_BOTTOM_RIGHT_CORNER);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
504 gtk_widget_realize (bottom_event_box);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
505 gdk_window_set_cursor (gtk_widget_get_window(bottom_event_box), cursor);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
506
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
507 g_signal_connect (G_OBJECT (top_event_box), "event",
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
508 G_CALLBACK (move_child_callback),
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
509 child);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
510 g_signal_connect (G_OBJECT (bottom_event_box), "event",
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
511 G_CALLBACK (resize_child_callback),
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
512 child);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
513 g_signal_connect (G_OBJECT (button[0]), "button_press_event",
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
514 G_CALLBACK (iconify_child_callback),
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
515 child);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
516 g_signal_connect (G_OBJECT (button[1]), "button_press_event",
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
517 G_CALLBACK (maximize_child_callback),
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
518 child);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
519 g_signal_connect (G_OBJECT (button[2]), "button_press_event",
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
520 G_CALLBACK (kill_child_callback),
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
521 child);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
522 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
523
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
524 static void gtk_mdi_move(GtkMdi *mdi, GtkWidget *widget, gint x, gint y)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
525 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
526 GtkMdiChild *child;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
527
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
528 g_return_if_fail(GTK_IS_MDI(mdi));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
529 g_return_if_fail(GTK_IS_WIDGET(widget));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
530
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
531 child = get_child(mdi, widget);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
532 g_return_if_fail(child);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
533
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
534 child->x = x;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
535 child->y = y;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
536 if (gtk_widget_get_visible(widget) && gtk_widget_get_visible(GTK_WIDGET(mdi)))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
537 gtk_widget_queue_resize(GTK_WIDGET(widget));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
538 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
539
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
540 static void gtk_mdi_get_pos(GtkMdi *mdi, GtkWidget *widget, gint *x, gint *y)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
541 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
542 GtkMdiChild *child;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
543
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
544 g_return_if_fail(GTK_IS_MDI (mdi));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
545 g_return_if_fail(GTK_IS_WIDGET (widget));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
546
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
547 child = get_child(mdi, widget);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
548 g_return_if_fail(child);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
549
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
550 *x = child->x;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
551 *y = child->y;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
552 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
553
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
554 static void gtk_mdi_set_state(GtkMdi *mdi, GtkWidget *widget, GtkMdiChildState state)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
555 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
556 GtkMdiChild *child;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
557
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
558 g_return_if_fail (GTK_IS_MDI (mdi));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
559 g_return_if_fail (GTK_IS_WIDGET (widget));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
560
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
561 child = get_child (mdi, widget);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
562 g_return_if_fail (child);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
563
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
564 child->state = state;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
565 if (gtk_widget_get_visible(child->widget) && gtk_widget_get_visible(GTK_WIDGET(mdi)))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
566 gtk_widget_queue_resize(GTK_WIDGET(child->widget));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
567 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
568
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
569 static void gtk_mdi_remove(GtkMdi *mdi, GtkWidget *widget)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
570 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
571 GtkMdiChild *child;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
572
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
573 g_return_if_fail (GTK_IS_MDI (mdi));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
574 child = get_child (mdi, widget);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
575 g_return_if_fail (child);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
576 gtk_mdi_remove_true (GTK_CONTAINER (mdi), child->widget);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
577 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
578
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
579 static void gtk_mdi_realize(GtkWidget *widget)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
580 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
581 GtkMdi *mdi;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
582 GdkWindowAttr attributes;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
583 gint attributes_mask;
1185
415c25f87d57 Fix for MDI support for GTK3. Haven't tested completely...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1177
diff changeset
584 GdkWindow *thiswindow;
1555
5b5da6d21f08 Removed even more deprecated APIs from GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1554
diff changeset
585 GtkStyleContext *context;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
586
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
587 mdi = GTK_MDI (widget);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
588
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
589 g_return_if_fail (widget != NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
590 g_return_if_fail (GTK_IS_MDI (mdi));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
591
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
592 gtk_widget_set_realized(widget, TRUE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
593
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
594 GtkAllocation allocation;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
595 gtk_widget_get_allocation(widget, &allocation);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
596 attributes.x = allocation.x;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
597 attributes.y = allocation.y;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
598 attributes.width = allocation.width;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
599 attributes.height = allocation.height;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
600 attributes.wclass = GDK_INPUT_OUTPUT;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
601 attributes.window_type = GDK_WINDOW_CHILD;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
602 attributes.event_mask = gtk_widget_get_events (widget) |
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
603 GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK |
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
604 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK |
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
605 GDK_POINTER_MOTION_HINT_MASK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
606 attributes.visual = gtk_widget_get_visual (widget);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
607
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
608 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
1185
415c25f87d57 Fix for MDI support for GTK3. Haven't tested completely...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1177
diff changeset
609 thiswindow = gdk_window_new (gtk_widget_get_parent_window(widget), &attributes, attributes_mask);
415c25f87d57 Fix for MDI support for GTK3. Haven't tested completely...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1177
diff changeset
610 gtk_widget_set_window(widget, thiswindow);
415c25f87d57 Fix for MDI support for GTK3. Haven't tested completely...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1177
diff changeset
611
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
612 gdk_window_set_user_data (gtk_widget_get_window(widget), widget);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
613
1555
5b5da6d21f08 Removed even more deprecated APIs from GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1554
diff changeset
614 if((context = gtk_widget_get_style_context(widget)))
5b5da6d21f08 Removed even more deprecated APIs from GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1554
diff changeset
615 gtk_style_context_set_background (context, gtk_widget_get_window(widget));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
616 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
617
836
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
618 static void gtk_mdi_get_preferred_width (GtkWidget *widget, gint *minimum_width, gint *natural_width)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
619 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
620 GtkMdi *mdi;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
621 GtkMdiChild *child;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
622 GList *children;
836
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
623 gint child_minimum_width, child_natural_width;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
624
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
625 mdi = GTK_MDI (widget);
836
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
626 *natural_width = *minimum_width = GTK_MDI_DEFAULT_WIDTH;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
627
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
628 children = mdi->children;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
629 while(children)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
630 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
631 child = children->data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
632 children = children->next;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
633
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
634 if(gtk_widget_get_visible(child->widget))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
635 {
836
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
636 gtk_widget_get_preferred_width(child->widget, &child_minimum_width, &child_natural_width);
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
637 }
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
638 }
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
639 }
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
640
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
641 static void gtk_mdi_get_preferred_height (GtkWidget *widget, gint *minimum_height, gint *natural_height)
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
642 {
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
643 GtkMdi *mdi;
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
644 GtkMdiChild *child;
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
645 GList *children;
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
646 gint child_minimum_height, child_natural_height;
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
647
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
648 mdi = GTK_MDI (widget);
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
649 *natural_height = *minimum_height = GTK_MDI_DEFAULT_HEIGHT;
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
650
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
651 children = mdi->children;
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
652 while(children)
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
653 {
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
654 child = children->data;
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
655 children = children->next;
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
656
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
657 if(gtk_widget_get_visible(child->widget))
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
658 {
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
659 gtk_widget_get_preferred_height(child->widget, &child_minimum_height, &child_natural_height);
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
660 }
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
661 }
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
662 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
663
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
664 static void gtk_mdi_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
665 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
666 GtkMdi *mdi;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
667 GtkMdiChild *child;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
668 GtkAllocation child_allocation;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
669 GtkRequisition child_requisition;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
670 GList *children;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
671
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
672 mdi = GTK_MDI (widget);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
673
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
674 gtk_widget_set_allocation(widget, allocation);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
675
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
676 if(gtk_widget_get_realized(widget))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
677 gdk_window_move_resize (gtk_widget_get_window(widget),
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
678 allocation->x,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
679 allocation->y,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
680 allocation->width,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
681 allocation->height);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
682
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
683
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
684 children = mdi->children;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
685 while(children)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
686 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
687 child = children->data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
688 children = children->next;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
689
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
690 if(gtk_widget_get_visible(child->widget))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
691 {
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
692 gtk_widget_get_preferred_size (child->widget, NULL, &child_requisition);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
693 child_allocation.x = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
694 child_allocation.y = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
695 switch (child->state)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
696 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
697 case CHILD_NORMAL:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
698 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
699 if ((child->width < 0) && (child->height < 0))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
700 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
701 child_allocation.width = child_requisition.width;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
702 child_allocation.height = child_requisition.height;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
703 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
704 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
705 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
706 child_allocation.width = child->width;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
707 child_allocation.height = child->height;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
708 child->width = -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
709 child->height = -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
710 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
711 child_allocation.x += child->x;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
712 child_allocation.y += child->y;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
713 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
714 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
715 case CHILD_MAXIMIZED:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
716 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
717 if ((child->width < 0) && (child->height < 0))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
718 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
719 child->width = child_requisition.width;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
720 child->height = child_requisition.height;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
721 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
722 child_allocation.width = allocation->width;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
723 child_allocation.height = allocation->height;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
724 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
725 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
726 case CHILD_ICONIFIED:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
727 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
728 if ((child->width < 0) && (child->height < 0))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
729 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
730 child->width = child_requisition.width;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
731 child->height = child_requisition.height;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
732 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
733 child_allocation.x += child->x;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
734 child_allocation.y += child->y;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
735 child_allocation.width = child_requisition.width;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
736 child_allocation.height = GTK_MDI_MIN_HEIGHT;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
737 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
738 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
739 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
740 gtk_widget_size_allocate (child->widget, &child_allocation);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
741 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
742 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
743 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
744
877
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
745 static gboolean gtk_mdi_draw(GtkWidget *widget, cairo_t *cr)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
746 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
747 GtkMdiChild *child;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
748 GList *children;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
749 GtkMdi *mdi;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
750
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
751 g_return_val_if_fail (widget != NULL, FALSE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
752 g_return_val_if_fail (GTK_IS_MDI (widget), FALSE);
836
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
753 g_return_val_if_fail (cr != NULL, FALSE);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
754
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
755 mdi = GTK_MDI (widget);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
756 for (children = mdi->children; children; children = children->next)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
757 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
758 child = (GtkMdiChild *) children->data;
836
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
759 gtk_container_propagate_draw (GTK_CONTAINER (mdi),
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
760 child->widget,
836
28f9810dfebc More work on getting MDI working again.... still doesn't work right unfortunately.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 835
diff changeset
761 cr);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
762 }
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
763 return FALSE;
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
764 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
765
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
766 static void gtk_mdi_add(GtkContainer *container, GtkWidget *widget)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
767 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
768 GtkWidget *label;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
769 label = gtk_label_new ("");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
770 gtk_mdi_put (GTK_MDI (container), widget, 0, 0, label);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
771 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
772
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
773 static void gtk_mdi_remove_true(GtkContainer *container, GtkWidget *widget)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
774 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
775 GtkMdi *mdi;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
776 GtkMdiChild *child = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
777 GList *children;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
778
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
779 mdi = GTK_MDI (container);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
780
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
781 children = mdi->children;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
782 while (children)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
783 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
784 child = children->data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
785 if (child->widget == widget)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
786 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
787
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
788 children = children->next;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
789 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
790
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
791 if(child)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
792 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
793 gtk_widget_unparent (child->widget);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
794 g_free (child);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
795 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
796 mdi->children = g_list_remove_link (mdi->children, children);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
797 g_list_free (children);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
798 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
799
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
800 static void gtk_mdi_forall(GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
801 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
802 GtkMdi *mdi;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
803 GtkMdiChild *child;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
804 GList *children;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
805
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
806 g_return_if_fail (callback != NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
807
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
808 mdi = GTK_MDI (container);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
809
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
810 children = mdi->children;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
811 while (children)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
812 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
813 child = children->data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
814 children = children->next;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
815
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
816 (*callback) (child->widget, callback_data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
817 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
818 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
819
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
820 static gboolean move_child_callback(GtkWidget *widget, GdkEvent *event, gpointer data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
821 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
822 GtkMdi *mdi;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
823 GtkMdiChild *child;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
824
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
825 child = (GtkMdiChild *) data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
826 mdi = child->mdi;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
827
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
828 g_return_val_if_fail (GTK_IS_MDI (mdi), FALSE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
829 g_return_val_if_fail (GTK_IS_EVENT_BOX (widget), FALSE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
830
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
831
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
832 switch (event->type)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
833 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
834 case GDK_2BUTTON_PRESS:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
835 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
836 gdk_window_raise (gtk_widget_get_window(child->widget));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
837 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
838 case GDK_BUTTON_PRESS:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
839 if (child->state == CHILD_MAXIMIZED)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
840 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
841 if (mdi->drag_button < 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
842 {
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
843 if (gdk_device_grab (gdk_event_get_device(event),
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
844 event->button.window,
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
845 GDK_OWNERSHIP_WINDOW,
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
846 FALSE,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
847 GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
848 GDK_BUTTON_RELEASE_MASK,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
849 NULL,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
850 event->button.time) != GDK_GRAB_SUCCESS)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
851 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
852
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
853 mdi->drag_button = event->button.button;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
854
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
855 mdi->drag_start.x = event->button.x;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
856 mdi->drag_start.y = event->button.y;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
857 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
858 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
859
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
860 case GDK_BUTTON_RELEASE:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
861 if (mdi->drag_button < 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
862 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
863
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
864 if (mdi->drag_button == event->button.button)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
865 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
866 int x, y;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
867
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
868 gdk_device_ungrab (gdk_event_get_device(event), event->button.time);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
869 mdi->drag_button = -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
870
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
871 x = event->button.x + child->x - mdi->drag_start.x;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
872 y = event->button.y + child->y - mdi->drag_start.y;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
873
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
874 gtk_mdi_move (mdi, child->child, x, y);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
875 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
876 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
877
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
878 case GDK_MOTION_NOTIFY:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
879 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
880 int x, y;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
881
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
882 if (mdi->drag_button < 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
883 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
884
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
885 gdk_window_get_device_position (gtk_widget_get_window(widget), gdk_event_get_device(event), &x, &y, NULL);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
886
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
887
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
888 x = x - mdi->drag_start.x + child->x;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
889 y = y - mdi->drag_start.y + child->y;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
890
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
891
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
892 gtk_mdi_move (mdi, child->child, x, y);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
893 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
894 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
895
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
896 default:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
897 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
898 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
899
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
900 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
901 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
902
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
903 static gboolean resize_child_callback(GtkWidget *widget, GdkEvent *event, gpointer data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
904 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
905 GtkMdi *mdi;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
906 GtkMdiChild *child;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
907
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
908 child = (GtkMdiChild *) data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
909 mdi = child->mdi;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
910
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
911 g_return_val_if_fail (GTK_IS_MDI (mdi), FALSE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
912 g_return_val_if_fail (GTK_IS_EVENT_BOX (widget), FALSE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
913
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
914 switch (event->type)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
915 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
916 case GDK_BUTTON_PRESS:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
917 if (mdi->drag_button < 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
918 {
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
919 if (gdk_device_grab (gdk_event_get_device(event),
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
920 event->button.window,
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
921 GDK_OWNERSHIP_WINDOW,
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
922 FALSE,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
923 GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
924 GDK_BUTTON_RELEASE_MASK,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
925 NULL,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
926 event->button.time) != GDK_GRAB_SUCCESS)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
927 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
928
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
929 mdi->drag_button = event->button.button;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
930 if ((child->state == CHILD_MAXIMIZED) || (child->state == CHILD_ICONIFIED))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
931 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
932 GtkAllocation allocation;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
933
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
934 child->state = CHILD_NORMAL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
935 gtk_widget_get_allocation(child->widget, &allocation);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
936 child->x = allocation.x;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
937 child->y = allocation.y;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
938 child->width = allocation.width;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
939 child->height = allocation.height;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
940 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
941
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
942 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
943 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
944
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
945 case GDK_BUTTON_RELEASE:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
946 if (mdi->drag_button < 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
947 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
948
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
949 if (mdi->drag_button == event->button.button)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
950 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
951 int width, height;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
952 GtkAllocation allocation;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
953
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
954 gdk_device_ungrab (gdk_event_get_device(event), event->button.time);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
955 mdi->drag_button = -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
956
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
957 gtk_widget_get_allocation(widget, &allocation);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
958 width = event->button.x + allocation.x;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
959 height = event->button.y + allocation.y;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
960
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
961 width = MAX (width, GTK_MDI_MIN_WIDTH);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
962 height = MAX (height, GTK_MDI_MIN_HEIGHT);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
963
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
964 gtk_widget_set_size_request (child->widget, width, height);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
965 gtk_widget_queue_resize (child->widget);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
966 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
967 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
968
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
969 case GDK_MOTION_NOTIFY:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
970 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
971 int x, y;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
972 int width, height;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
973 GtkAllocation allocation;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
974
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
975 if (mdi->drag_button < 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
976 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
977
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
978 gdk_window_get_device_position (gtk_widget_get_window(widget), gdk_event_get_device(event), &x, &y, NULL);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
979
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
980 gtk_widget_get_allocation(widget, &allocation);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
981 width = x + allocation.x;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
982 height = y + allocation.y;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
983
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
984 width = MAX (width, GTK_MDI_MIN_WIDTH);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
985 height = MAX (height, GTK_MDI_MIN_HEIGHT);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
986
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
987 gtk_widget_set_size_request (child->widget, width, height);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
988 gtk_widget_queue_resize (child->widget);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
989 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
990 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
991
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
992 default:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
993 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
994 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
995
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
996 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
997 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
998
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
999 static gboolean iconify_child_callback (GtkWidget *widget, GdkEvent *event, gpointer data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1000 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1001 GtkMdiChild *child;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1002 child = (GtkMdiChild *) data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1003 if(child->state == CHILD_ICONIFIED)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1004 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1005 child->state = CHILD_NORMAL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1006 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1007 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1008 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1009 child->state = CHILD_ICONIFIED;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1010 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1011 if(gtk_widget_get_visible(child->widget))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1012 gtk_widget_queue_resize(GTK_WIDGET (child->widget));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1013 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1014 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1015
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1016 static gboolean maximize_child_callback (GtkWidget *widget, GdkEvent * event, gpointer data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1017 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1018 GtkMdiChild *child;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1019 child = (GtkMdiChild *) data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1020 if (child->state == CHILD_MAXIMIZED)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1021 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1022 child->state = CHILD_NORMAL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1023 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1024 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1025 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1026 child->state = CHILD_MAXIMIZED;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1027 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1028 if(gtk_widget_get_visible(child->widget))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1029 gtk_widget_queue_resize(GTK_WIDGET (child->widget));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1030 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1031 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1032
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1033 static gboolean kill_child_callback (GtkWidget *widget, GdkEvent *event, gpointer data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1034 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1035 GtkMdiChild *child;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1036 GtkMdi *mdi;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1037
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1038 child = (GtkMdiChild *) data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1039 mdi = child->mdi;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1040
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1041 g_return_val_if_fail (GTK_IS_MDI (mdi), FALSE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1042
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1043 gtk_mdi_remove_true (GTK_CONTAINER (mdi), child->widget);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1044 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1045 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1046
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1047 static GtkMdiChild *get_child (GtkMdi *mdi, GtkWidget *widget)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1048 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1049 GList *children;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1050
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1051 children = mdi->children;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1052 while (children)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1053 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1054 GtkMdiChild *child;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1055
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1056 child = children->data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1057 children = children->next;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1058
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1059 if (child->child == widget)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1060 return child;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1061 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1062
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1063 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1064 }
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
1065 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1066
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1067 static void _dw_msleep(long period)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1068 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1069 #ifdef __sun__
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1070 /* usleep() isn't threadsafe on Solaris */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1071 struct timespec req;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1072
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1073 req.tv_sec = 0;
1463
77f530f95826 Fixed error in _dw_msleep on Solaris... fix was already in dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1452
diff changeset
1074 if(period >= 1000)
77f530f95826 Fixed error in _dw_msleep on Solaris... fix was already in dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1452
diff changeset
1075 {
77f530f95826 Fixed error in _dw_msleep on Solaris... fix was already in dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1452
diff changeset
1076 req.tv_sec = (int)(period / 1000);
77f530f95826 Fixed error in _dw_msleep on Solaris... fix was already in dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1452
diff changeset
1077 period -= (req.tv_sec * 1000);
77f530f95826 Fixed error in _dw_msleep on Solaris... fix was already in dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1452
diff changeset
1078 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1079 req.tv_nsec = period * 10000000;
1463
77f530f95826 Fixed error in _dw_msleep on Solaris... fix was already in dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1452
diff changeset
1080
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1081 nanosleep(&req, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1082 #else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1083 usleep(period * 1000);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1084 #endif
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1085 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1086
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1087 /* Finds the translation function for a given signal name */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1088 static void *_findsigfunc(char *signame)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1089 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1090 int z;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1091
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1092 for(z=0;z<SIGNALMAX;z++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1093 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1094 if(strcasecmp(signame, SignalTranslate[z].name) == 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1095 return SignalTranslate[z].func;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1096 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1097 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1098 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1099
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1100 static SignalHandler _get_signal_handler(gpointer data)
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1101 {
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1102 SignalHandler sh = {0};
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1103
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1104 if(data)
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1105 {
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1106 void **params = (void **)data;
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1107 int counter = GPOINTER_TO_INT(params[0]);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1108 GtkWidget *widget = (GtkWidget *)params[2];
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1109 char text[100];
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1110
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1111 sprintf(text, "_dw_sigwindow%d", counter);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1112 sh.window = (HWND)g_object_get_data(G_OBJECT(widget), text);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1113 sprintf(text, "_dw_sigfunc%d", counter);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1114 sh.func = (void *)g_object_get_data(G_OBJECT(widget), text);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1115 sprintf(text, "_dw_intfunc%d", counter);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1116 sh.intfunc = (void *)g_object_get_data(G_OBJECT(widget), text);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1117 sprintf(text, "_dw_sigdata%d", counter);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1118 sh.data = g_object_get_data(G_OBJECT(widget), text);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1119 sprintf(text, "_dw_sigcid%d", counter);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1120 sh.cid = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), text));
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1121 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1122 return sh;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1123 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1124
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1125 static void _remove_signal_handler(GtkWidget *widget, int counter)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1126 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1127 char text[100];
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1128 gint cid;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1129
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1130 sprintf(text, "_dw_sigcid%d", counter);
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
1131 cid = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), text));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1132 g_signal_handler_disconnect(G_OBJECT(widget), cid);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1133 g_object_set_data(G_OBJECT(widget), text, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1134 sprintf(text, "_dw_sigwindow%d", counter);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1135 g_object_set_data(G_OBJECT(widget), text, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1136 sprintf(text, "_dw_sigfunc%d", counter);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1137 g_object_set_data(G_OBJECT(widget), text, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1138 sprintf(text, "_dw_intfunc%d", counter);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1139 g_object_set_data(G_OBJECT(widget), text, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1140 sprintf(text, "_dw_sigdata%d", counter);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1141 g_object_set_data(G_OBJECT(widget), text, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1142 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1143
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1144 static int _set_signal_handler(GtkWidget *widget, HWND window, void *func, gpointer data, void *intfunc, void *discfunc)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1145 {
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
1146 int counter = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "_dw_sigcounter"));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1147 char text[100];
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1148
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1149 sprintf(text, "_dw_sigwindow%d", counter);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1150 g_object_set_data(G_OBJECT(widget), text, (gpointer)window);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1151 sprintf(text, "_dw_sigfunc%d", counter);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1152 g_object_set_data(G_OBJECT(widget), text, (gpointer)func);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1153 sprintf(text, "_dw_intfunc%d", counter);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1154 g_object_set_data(G_OBJECT(widget), text, (gpointer)intfunc);
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1155 sprintf(text, "_dw_discfunc%d", counter);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1156 g_object_set_data(G_OBJECT(widget), text, (gpointer)discfunc);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1157 sprintf(text, "_dw_sigdata%d", counter);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1158 g_object_set_data(G_OBJECT(widget), text, (gpointer)data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1159
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1160 counter++;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1161 g_object_set_data(G_OBJECT(widget), "_dw_sigcounter", GINT_TO_POINTER(counter));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1162
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1163 return counter - 1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1164 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1165
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1166 static void _set_signal_handler_id(GtkWidget *widget, int counter, gint cid)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1167 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1168 char text[100];
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1169
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1170 sprintf(text, "_dw_sigcid%d", counter);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1171 g_object_set_data(G_OBJECT(widget), text, GINT_TO_POINTER(cid));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1172 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1173
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1174 static gint _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1175 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1176 SignalHandler work = _get_signal_handler(data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1177 int retval = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1178
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1179 if(work.window)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1180 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1181 int (*setfocusfunc)(HWND, void *) = work.func;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1182
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1183 retval = setfocusfunc(work.window, work.data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1184 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1185 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1186 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1187
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1188 static gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1189 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1190 SignalHandler work = _get_signal_handler(data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1191 int retval = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1192
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1193 if(work.window)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1194 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1195 int (*buttonfunc)(HWND, int, int, int, void *) = work.func;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1196 int mybutton = event->button;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1197
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1198 if(event->button == 3)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1199 mybutton = 2;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1200 else if(event->button == 2)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1201 mybutton = 3;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1202
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1203 retval = buttonfunc(work.window, event->x, event->y, mybutton, work.data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1204 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1205 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1206 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1207
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1208 static gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1209 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1210 SignalHandler work = _get_signal_handler(data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1211 int retval = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1212
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1213 if(work.window)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1214 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1215 int (*buttonfunc)(HWND, int, int, int, void *) = work.func;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1216 int mybutton = event->button;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1217
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1218 if(event->button == 3)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1219 mybutton = 2;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1220 else if(event->button == 2)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1221 mybutton = 3;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1222
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1223 retval = buttonfunc(work.window, event->x, event->y, mybutton, work.data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1224 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1225 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1226 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1227
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1228 static gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1229 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1230 SignalHandler work = _get_signal_handler(data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1231 int retval = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1232
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1233 if(work.window)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1234 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1235 int (*motionfunc)(HWND, int, int, int, void *) = work.func;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1236 int keys = 0, x, y;
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1237 GdkModifierType state = 0;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1238
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1239 if (event->is_hint)
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1240 gdk_window_get_device_position (event->window, gdk_event_get_device((GdkEvent *)event), &x, &y, &state);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1241 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1242 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1243 x = event->x;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1244 y = event->y;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1245 state = event->state;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1246 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1247
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1248 if (state & GDK_BUTTON1_MASK)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1249 keys = DW_BUTTON1_MASK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1250 if (state & GDK_BUTTON3_MASK)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1251 keys |= DW_BUTTON2_MASK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1252 if (state & GDK_BUTTON2_MASK)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1253 keys |= DW_BUTTON3_MASK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1254
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1255 retval = motionfunc(work.window, x, y, keys, work.data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1256 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1257 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1258 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1259
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1260 static gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1261 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1262 SignalHandler work = _get_signal_handler(data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1263 int retval = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1264
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1265 if(work.window)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1266 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1267 int (*closefunc)(HWND, void *) = work.func;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1268
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1269 retval = closefunc(work.window, work.data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1270 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1271 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1272 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1273
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1274 static gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1275 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1276 SignalHandler work = _get_signal_handler(data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1277 int retval = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1278
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1279 if(work.window)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1280 {
1747
f297d8a63aed Added utf8 parameter to key press callback on GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1745
diff changeset
1281 int (*keypressfunc)(HWND, char, int, int, void *, char *) = work.func;
f297d8a63aed Added utf8 parameter to key press callback on GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1745
diff changeset
1282 guint32 unichar = gdk_keyval_to_unicode(event->keyval);
f297d8a63aed Added utf8 parameter to key press callback on GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1745
diff changeset
1283 char utf8[7] = { 0 };
f297d8a63aed Added utf8 parameter to key press callback on GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1745
diff changeset
1284
f297d8a63aed Added utf8 parameter to key press callback on GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1745
diff changeset
1285 g_unichar_to_utf8(unichar, utf8);
f297d8a63aed Added utf8 parameter to key press callback on GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1745
diff changeset
1286
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1287 retval = keypressfunc(work.window, *event->string, event->keyval,
1747
f297d8a63aed Added utf8 parameter to key press callback on GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1745
diff changeset
1288 event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK), work.data, utf8);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1289 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1290 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1291 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1292
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1293 static gint _generic_event(GtkWidget *widget, gpointer data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1294 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1295 SignalHandler work = _get_signal_handler(data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1296 int retval = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1297
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1298 if(work.window)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1299 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1300 int (*genericfunc)(HWND, void *) = work.func;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1301
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1302 retval = genericfunc(work.window, work.data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1303 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1304 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1305 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1306
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1307 static gint _activate_event(GtkWidget *widget, gpointer data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1308 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1309 SignalHandler work = _get_signal_handler(data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1310 int retval = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1311
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1312 if(work.window && !_dw_ignore_click)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1313 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1314 int (*activatefunc)(HWND, void *) = work.func;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1315
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1316 retval = activatefunc(popup ? popup : work.window, work.data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1317 popup = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1318 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1319 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1320 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1321
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1322 static gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1323 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1324 SignalHandler work = _get_signal_handler(data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1325 int retval = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1326
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1327 if(work.window)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1328 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1329 int (*sizefunc)(HWND, int, int, void *) = work.func;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1330
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1331 retval = sizefunc(work.window, event->width, event->height, work.data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1332 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1333 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1334 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1335
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
1336 static gint _expose_event(GtkWidget *widget, cairo_t *cr, gpointer data)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1337 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1338 SignalHandler work = _get_signal_handler(data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1339 int retval = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1340
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1341 if(work.window)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1342 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1343 DWExpose exp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1344 int (*exposefunc)(HWND, DWExpose *, void *) = work.func;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1345
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
1346 exp.x = exp.y = 0;
780
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
1347 exp.width = gtk_widget_get_allocated_width(widget);
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
1348 exp.height = gtk_widget_get_allocated_height(widget);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1349 retval = exposefunc(work.window, &exp, work.data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1350 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1351 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1352 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1353
785
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1354 static gint _combobox_select_event(GtkWidget *widget, gpointer data)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1355 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1356 SignalHandler work = _get_signal_handler(data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1357 int retval = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1358
1742
cebf830e3da7 Minor GTK3 code cleanups from attempt at fixing combobox event order.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1718
diff changeset
1359 if(g_object_get_data(G_OBJECT(widget), "_dw_recursing"))
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1360 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1361
785
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1362 if(work.window && GTK_IS_COMBO_BOX(widget))
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1363 {
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1364 GtkTreeModel *store = gtk_combo_box_get_model(GTK_COMBO_BOX(widget));
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1365
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1366 if(store)
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1367 {
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1368 GtkTreeIter iter;
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1369 GtkTreePath *path;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1370
1742
cebf830e3da7 Minor GTK3 code cleanups from attempt at fixing combobox event order.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1718
diff changeset
1371 g_object_set_data(G_OBJECT(widget), "_dw_recursing", GINT_TO_POINTER(1));
785
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1372
787
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
1373 if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &iter))
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1374 {
787
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
1375 path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1376
787
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
1377 if(path)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1378 {
787
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
1379 gint *indices = gtk_tree_path_get_indices(path);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1380
787
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
1381 if(indices)
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
1382 {
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
1383 int (*selectfunc)(HWND, int, void *) = work.func;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1384
787
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
1385 retval = selectfunc(work.window, indices[0], work.data);
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
1386 }
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
1387 gtk_tree_path_free(path);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1388 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1389 }
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1390
1742
cebf830e3da7 Minor GTK3 code cleanups from attempt at fixing combobox event order.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1718
diff changeset
1391 g_object_set_data(G_OBJECT(widget), "_dw_recursing", NULL);
785
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1392 }
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1393 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1394 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1395 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1396
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
1397 #define _DW_DATA_TYPE_STRING 0
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
1398 #define _DW_DATA_TYPE_POINTER 1
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
1399
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1400 static gint _tree_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1401 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1402 SignalHandler work = _get_signal_handler(data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1403 int retval = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1404
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1405 if(work.window)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1406 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1407 if(event->button == 3)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1408 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1409 int (*contextfunc)(HWND, char *, int, int, void *, void *) = work.func;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1410 char *text = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1411 void *itemdata = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1412
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1413 if(widget && GTK_IS_TREE_VIEW(widget))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1414 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1415 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1416 GtkTreeModel *store = (GtkTreeModel *)gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1417 GtkTreeIter iter;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1418
780
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
1419 if(sel && gtk_tree_selection_get_mode(sel) != GTK_SELECTION_MULTIPLE &&
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
1420 gtk_tree_selection_get_selected(sel, NULL, &iter))
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1421 {
780
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
1422 if(g_object_get_data(G_OBJECT(widget), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_TREE))
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
1423 {
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
1424 gtk_tree_model_get(store, &iter, _DW_DATA_TYPE_STRING, &text, 2, &itemdata, -1);
780
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
1425 }
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
1426 else
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
1427 {
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
1428 gtk_tree_model_get(store, &iter, _DW_DATA_TYPE_STRING, &text, -1);
780
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
1429 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1430 }
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1431 else
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1432 {
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1433 GtkTreePath *path;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1434
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1435 gtk_tree_view_get_cursor(GTK_TREE_VIEW(widget), &path, NULL);
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1436 if(path)
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1437 {
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1438 GtkTreeIter iter;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1439
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1440 if(gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path))
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1441 {
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1442 if(g_object_get_data(G_OBJECT(widget), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_TREE))
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1443 {
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
1444 gtk_tree_model_get(store, &iter, _DW_DATA_TYPE_STRING, &text, 2, &itemdata, -1);
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1445 }
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1446 else
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1447 {
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
1448 gtk_tree_model_get(store, &iter, _DW_DATA_TYPE_STRING, &text, -1);
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1449 }
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1450 }
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1451 gtk_tree_path_free(path);
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1452 }
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1453 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1454 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1455
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1456 retval = contextfunc(work.window, text, event->x, event->y, work.data, itemdata);
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
1457 if(text)
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
1458 g_free(text);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1459 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1460 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1461 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1462 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1463
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1464 static gint _tree_select_event(GtkTreeSelection *sel, gpointer data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1465 {
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
1466 GtkWidget *item = NULL, *widget = (GtkWidget *)gtk_tree_selection_get_tree_view(sel);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1467 int retval = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1468
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1469 if(widget)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1470 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1471 SignalHandler work = _get_signal_handler(data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1472
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1473 if(work.window)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1474 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1475 int (*treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = work.func;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1476 GtkTreeIter iter;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1477 char *text = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1478 void *itemdata = NULL;
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1479 GtkTreeModel *store = (GtkTreeModel *)gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1480
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1481 if(g_object_get_data(G_OBJECT(widget), "_dw_double_click"))
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1482 {
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1483 g_object_set_data(G_OBJECT(widget), "_dw_double_click", GINT_TO_POINTER(0));
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1484 return TRUE;
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1485 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1486
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
1487 if(gtk_tree_selection_get_mode(sel) != GTK_SELECTION_MULTIPLE &&
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
1488 gtk_tree_selection_get_selected(sel, NULL, &iter))
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1489 {
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
1490 if(g_object_get_data(G_OBJECT(widget), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_TREE))
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
1491 {
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
1492 gtk_tree_model_get(store, &iter, _DW_DATA_TYPE_STRING, &text, 2, &itemdata, 3, &item, -1);
785
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1493 retval = treeselectfunc(work.window, (HTREEITEM)item, text, work.data, itemdata);
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1494 }
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1495 else if(g_object_get_data(G_OBJECT(widget), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1496 {
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
1497 gtk_tree_model_get(store, &iter, _DW_DATA_TYPE_STRING, &text, _DW_DATA_TYPE_POINTER, &itemdata, -1);
785
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1498 retval = treeselectfunc(work.window, (HTREEITEM)item, text, work.data, itemdata);
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
1499 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
1500 else
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
1501 {
785
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1502 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1503
785
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1504 if(path)
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1505 {
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1506 gint *indices = gtk_tree_path_get_indices(path);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1507
785
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1508 if(indices)
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1509 {
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1510 int (*selectfunc)(HWND, int, void *) = work.func;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1511
785
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1512 retval = selectfunc(work.window, indices[0], work.data);
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1513 }
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1514 gtk_tree_path_free(path);
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1515 }
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
1516 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1517 }
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1518 else
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1519 {
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1520 GtkTreePath *path;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1521
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1522 gtk_tree_view_get_cursor(GTK_TREE_VIEW(widget), &path, NULL);
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1523 if(path)
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1524 {
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1525 GtkTreeIter iter;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1526
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1527 if(gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path))
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1528 {
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1529 if(g_object_get_data(G_OBJECT(widget), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_TREE))
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1530 {
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
1531 gtk_tree_model_get(store, &iter, _DW_DATA_TYPE_STRING, &text, 2, &itemdata, 3, &item, -1);
785
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1532 retval = treeselectfunc(work.window, (HTREEITEM)item, text, work.data, itemdata);
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1533 }
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1534 else if(g_object_get_data(G_OBJECT(widget), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1535 {
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
1536 gtk_tree_model_get(store, &iter, _DW_DATA_TYPE_STRING, &text, _DW_DATA_TYPE_POINTER, &itemdata, -1);
785
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1537 retval = treeselectfunc(work.window, (HTREEITEM)item, text, work.data, itemdata);
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1538 }
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1539 else
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1540 {
785
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1541 gint *indices = gtk_tree_path_get_indices(path);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1542
785
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1543 if(indices)
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1544 {
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1545 int (*selectfunc)(HWND, int, void *) = work.func;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1546
785
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1547 retval = selectfunc(work.window, indices[0], work.data);
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
1548 }
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1549 }
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1550 }
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1551 gtk_tree_path_free(path);
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1552 }
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1553 }
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
1554 if(text)
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
1555 g_free(text);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1556 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1557 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1558 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1559 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1560
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1561 static gint _tree_expand_event(GtkTreeView *widget, GtkTreeIter *iter, GtkTreePath *path, gpointer data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1562 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1563 SignalHandler work = _get_signal_handler(data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1564 int retval = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1565
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1566 if(!_dw_ignore_expand && work.window)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1567 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1568 int (*treeexpandfunc)(HWND, HTREEITEM, void *) = work.func;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1569 retval = treeexpandfunc(work.window, (HTREEITEM)iter, work.data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1570 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1571 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1572 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1573
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1574 static gint _container_enter_event(GtkWidget *widget, GdkEventAny *event, gpointer data)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1575 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1576 SignalHandler work = _get_signal_handler(data);
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1577 GdkEventKey *keyevent = (GdkEventKey *)event;
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1578 GdkEventButton *buttonevent = (GdkEventButton *)event;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1579 int retval = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1580
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1581 if(work.window)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1582 {
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1583 /* Handle both key and button events together */
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1584 if((event->type == GDK_2BUTTON_PRESS && buttonevent->button == 1) ||
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1585 (event->type == GDK_KEY_PRESS && keyevent->keyval == VK_RETURN))
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1586 {
1881
653ccb517aa1 Fix missing rowdata parameter in container enter callback on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1875
diff changeset
1587 int (*contextfunc)(HWND, char *, void *, void *) = work.func;
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1588 char *text = NULL;
1881
653ccb517aa1 Fix missing rowdata parameter in container enter callback on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1875
diff changeset
1589 void *data = NULL;
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1590
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1591 /* Prevent some double events from happening */
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1592 if(event->type == GDK_2BUTTON_PRESS)
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1593 {
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1594 g_object_set_data(G_OBJECT(widget), "_dw_double_click", GINT_TO_POINTER(1));
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1595 }
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1596
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1597 /* Sanity check */
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1598 if(GTK_IS_TREE_VIEW(widget))
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1599 {
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1600 GtkTreePath *path;
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1601 GtkTreeModel *store = (GtkTreeModel *)gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1602
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1603 gtk_tree_view_get_cursor(GTK_TREE_VIEW(widget), &path, NULL);
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1604 if(path)
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1605 {
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1606 GtkTreeIter iter;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1607
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1608 if(gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path))
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1609 {
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1610 if(g_object_get_data(G_OBJECT(widget), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1611 {
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
1612 gtk_tree_model_get(store, &iter, _DW_DATA_TYPE_STRING, &text, _DW_DATA_TYPE_POINTER, &data, -1);
1881
653ccb517aa1 Fix missing rowdata parameter in container enter callback on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1875
diff changeset
1613 retval = contextfunc(work.window, text, work.data, data);
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
1614 if(text)
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
1615 g_free(text);
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1616 }
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1617 }
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1618 gtk_tree_path_free(path);
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1619 }
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1620 }
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1621 }
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
1622 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1623 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1624 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1625
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1626 /* Return the logical page id from the physical page id */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1627 int _get_logical_page(HWND handle, unsigned long pageid)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1628 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1629 int z;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1630 GtkWidget **pagearray = g_object_get_data(G_OBJECT(handle), "_dw_pagearray");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1631 GtkWidget *thispage = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), pageid);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1632
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1633 if(pagearray && thispage)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1634 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1635 for(z=0;z<256;z++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1636 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1637 if(thispage == pagearray[z])
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1638 return z;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1639 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1640 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1641 return 256;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1642 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1643
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1644
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1645 static gint _switch_page_event(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1646 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1647 SignalHandler work = _get_signal_handler(data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1648 int retval = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1649
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1650 if(work.window)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1651 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1652 int (*switchpagefunc)(HWND, unsigned long, void *) = work.func;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1653 retval = switchpagefunc(work.window, _get_logical_page(GTK_WIDGET(notebook), page_num), work.data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1654 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1655 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1656 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1657
786
0e251c2f5d08 Implemented the column click event handler...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 785
diff changeset
1658 static gint _column_click_event(GtkWidget *widget, gpointer data)
0e251c2f5d08 Implemented the column click event handler...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 785
diff changeset
1659 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1660 void **params = data;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1661 int retval = FALSE;
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1662
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1663 if(params && params[2])
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1664 {
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1665 GtkWidget *tree = (GtkWidget *)params[2];
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1666 gint handlerdata = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(tree), "_dw_column_click_id"));
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1667
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1668 if(handlerdata)
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1669 {
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1670 SignalHandler work;
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1671
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1672 params[0] = GINT_TO_POINTER(handlerdata-1);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1673 work = _get_signal_handler(params);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1674
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1675 if(work.window)
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1676 {
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1677 int column_num = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "_dw_column"));
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1678 int (*clickcolumnfunc)(HWND, int, void *) = work.func;
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1679 retval = clickcolumnfunc(work.window, column_num, work.data);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1680 }
788
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
1681 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1682 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1683 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1684 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1685
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1686 static int _round_value(gfloat val)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1687 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1688 int newval = (int)val;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1689
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1690 if(val >= 0.5 + (gfloat)newval)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1691 newval++;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1692
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1693 return newval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1694 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1695
1578
36f0cfda3be3 Fix value_changed code for GTK3... thought this used to work...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1577
diff changeset
1696 static gint _value_changed_event(GtkWidget *widget, gpointer data)
36f0cfda3be3 Fix value_changed code for GTK3... thought this used to work...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1577
diff changeset
1697 {
36f0cfda3be3 Fix value_changed code for GTK3... thought this used to work...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1577
diff changeset
1698 GtkWidget *slider, *spinbutton, *scrollbar;
36f0cfda3be3 Fix value_changed code for GTK3... thought this used to work...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1577
diff changeset
1699 GtkAdjustment *adjustment = (GtkAdjustment *)widget;
36f0cfda3be3 Fix value_changed code for GTK3... thought this used to work...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1577
diff changeset
1700 int max, val;
36f0cfda3be3 Fix value_changed code for GTK3... thought this used to work...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1577
diff changeset
1701
36f0cfda3be3 Fix value_changed code for GTK3... thought this used to work...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1577
diff changeset
1702 if(!GTK_IS_ADJUSTMENT(adjustment))
36f0cfda3be3 Fix value_changed code for GTK3... thought this used to work...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1577
diff changeset
1703 adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(widget), "_dw_adjustment");
36f0cfda3be3 Fix value_changed code for GTK3... thought this used to work...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1577
diff changeset
1704
36f0cfda3be3 Fix value_changed code for GTK3... thought this used to work...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1577
diff changeset
1705 slider = (GtkWidget *)g_object_get_data(G_OBJECT(adjustment), "_dw_slider");
36f0cfda3be3 Fix value_changed code for GTK3... thought this used to work...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1577
diff changeset
1706 spinbutton = (GtkWidget *)g_object_get_data(G_OBJECT(adjustment), "_dw_spinbutton");
36f0cfda3be3 Fix value_changed code for GTK3... thought this used to work...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1577
diff changeset
1707 scrollbar = (GtkWidget *)g_object_get_data(G_OBJECT(adjustment), "_dw_scrollbar");
36f0cfda3be3 Fix value_changed code for GTK3... thought this used to work...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1577
diff changeset
1708
36f0cfda3be3 Fix value_changed code for GTK3... thought this used to work...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1577
diff changeset
1709 max = _round_value(gtk_adjustment_get_upper(adjustment));
36f0cfda3be3 Fix value_changed code for GTK3... thought this used to work...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1577
diff changeset
1710 val = _round_value(gtk_adjustment_get_value(adjustment));
36f0cfda3be3 Fix value_changed code for GTK3... thought this used to work...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1577
diff changeset
1711
1486
5cfbf2715eec Code simplification on GTK2 and ported the fix to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1482
diff changeset
1712 if(g_object_get_data(G_OBJECT(adjustment), "_dw_suppress_value_changed_event"))
5cfbf2715eec Code simplification on GTK2 and ported the fix to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1482
diff changeset
1713 return FALSE;
5cfbf2715eec Code simplification on GTK2 and ported the fix to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1482
diff changeset
1714
5cfbf2715eec Code simplification on GTK2 and ported the fix to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1482
diff changeset
1715 if (slider || spinbutton || scrollbar)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1716 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
1717 SignalHandler work = _get_signal_handler(data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1718
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1719 if (work.window)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1720 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1721 int (*valuechangedfunc)(HWND, int, void *) = work.func;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1722
1583
525c4c9d04c6 After switching to non-deprecated functions in GTK3 like...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1579
diff changeset
1723 if(slider && gtk_orientable_get_orientation(GTK_ORIENTABLE(slider)) == GTK_ORIENTATION_VERTICAL)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1724 valuechangedfunc(work.window, (max - val) - 1, work.data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1725 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1726 valuechangedfunc(work.window, val, work.data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1727 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1728 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1729 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1730 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1731
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1732 static gint _default_key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1733 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1734 GtkWidget *next = (GtkWidget *)data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1735
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1736 if(next)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1737 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1738 if(event->keyval == GDK_KEY_Return)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1739 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1740 if(GTK_IS_BUTTON(next))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1741 g_signal_emit_by_name(G_OBJECT(next), "clicked");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1742 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1743 gtk_widget_grab_focus(next);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1744 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1745 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1746 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1747 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1748
976
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
1749 static GdkPixbuf *_find_pixbuf(HICN icon, unsigned long *userwidth, unsigned long *userheight)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1750 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1751 char *data = NULL;
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
1752 int z, id = GPOINTER_TO_INT(icon);
976
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
1753
1289
5fb54aeba5e0 Allow removing icons from containers on GTK2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1287
diff changeset
1754 /* Quick dropout for non-handle */
5fb54aeba5e0 Allow removing icons from containers on GTK2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1287
diff changeset
1755 if(!icon)
5fb54aeba5e0 Allow removing icons from containers on GTK2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1287
diff changeset
1756 return NULL;
5fb54aeba5e0 Allow removing icons from containers on GTK2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1287
diff changeset
1757
976
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
1758 if(id > 65535)
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
1759 {
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
1760 GdkPixbuf *icon_pixbuf = icon;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1761
976
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
1762 if(userwidth)
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
1763 *userwidth = gdk_pixbuf_get_width(icon_pixbuf);
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
1764 if(userheight)
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
1765 *userheight = gdk_pixbuf_get_height(icon_pixbuf);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1766
976
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
1767 return icon;
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
1768 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1769
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1770 for(z=0;z<_resources.resource_max;z++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1771 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1772 if(_resources.resource_id[z] == id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1773 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1774 data = _resources.resource_data[z];
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1775 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1776 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1777 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1778
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1779 if(data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1780 {
1327
e4ef8d86dfc4 Added support for GdkPixbuf inline data in GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1322
diff changeset
1781 GdkPixbuf *icon_pixbuf;
e4ef8d86dfc4 Added support for GdkPixbuf inline data in GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1322
diff changeset
1782
e4ef8d86dfc4 Added support for GdkPixbuf inline data in GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1322
diff changeset
1783 if(data[0] == 'G' && data[1] == 'd' && data[2] == 'k' && data[3] == 'P')
e4ef8d86dfc4 Added support for GdkPixbuf inline data in GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1322
diff changeset
1784 icon_pixbuf = gdk_pixbuf_new_from_inline(-1, (const guint8 *)data, FALSE, NULL);
e4ef8d86dfc4 Added support for GdkPixbuf inline data in GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1322
diff changeset
1785 else
e4ef8d86dfc4 Added support for GdkPixbuf inline data in GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1322
diff changeset
1786 icon_pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1787
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1788 if(userwidth)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1789 *userwidth = gdk_pixbuf_get_width(icon_pixbuf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1790 if(userheight)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1791 *userheight = gdk_pixbuf_get_height(icon_pixbuf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1792
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1793 return icon_pixbuf;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1794 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1795 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1796 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1797
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1798 /* Try to load the WebKitGtk shared libary */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1799 #ifdef USE_WEBKIT
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1800 void init_webkit(void)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1801 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1802 char libname[100];
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1803 void *handle = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1804
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1805 sprintf( libname, "lib%s.so", WEBKIT_LIB);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1806 handle = dlopen( libname, RTLD_LAZY );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1807
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1808 /* If we loaded it, grab the symbols we want */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1809 if ( handle )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1810 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1811 _webkit_web_view_get_type = dlsym( handle, "webkit_web_view_get_type" );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1812 _webkit_web_view_load_html_string = dlsym( handle, "webkit_web_view_load_html_string" );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1813 _webkit_web_view_open = dlsym( handle, "webkit_web_view_open" );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1814 _webkit_web_view_new = dlsym( handle, "webkit_web_view_new" );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1815 _webkit_web_view_go_back = dlsym( handle, "webkit_web_view_go_back" );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1816 _webkit_web_view_go_forward = dlsym( handle, "webkit_web_view_go_forward" );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1817 _webkit_web_view_reload = dlsym( handle, "webkit_web_view_reload" );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1818 _webkit_web_view_stop_loading = dlsym( handle, "webkit_web_view_stop_loading" );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1819 _webkit_web_frame_print = dlsym( handle, "webkit_web_frame_print" );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1820 _webkit_web_view_get_focused_frame = dlsym( handle, "webkit_web_view_get_focused_frame" );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1821 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1822 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1823 #endif
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1824
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1825 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1826 * Initializes the Dynamic Windows engine.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1827 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1828 * newthread: True if this is the only thread.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1829 * False if there is already a message loop running.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1830 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1831 int dw_int_init(DWResources *res, int newthread, int *argc, char **argv[])
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1832 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1833 if(res)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1834 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1835 _resources.resource_max = res->resource_max;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1836 _resources.resource_id = res->resource_id;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1837 _resources.resource_data = res->resource_data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1838 }
1384
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
1839
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
1840 /* Setup the private data directory */
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
1841 if(argc && argv && *argc > 0 && (*argv)[0])
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
1842 {
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
1843 char *pathcopy = strdup((*argv)[0]);
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
1844 char *pos = strrchr(pathcopy, '/');
1506
308bfa8426db Rewrite application directory detection code for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1505
diff changeset
1845 char *binname = pathcopy;
1384
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
1846
1506
308bfa8426db Rewrite application directory detection code for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1505
diff changeset
1847 /* If we have a / then...
308bfa8426db Rewrite application directory detection code for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1505
diff changeset
1848 * the binary name should be at the end.
308bfa8426db Rewrite application directory detection code for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1505
diff changeset
1849 */
1384
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
1850 if(pos)
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
1851 {
1506
308bfa8426db Rewrite application directory detection code for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1505
diff changeset
1852 binname = pos + 1;
1384
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
1853 *pos = 0;
1506
308bfa8426db Rewrite application directory detection code for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1505
diff changeset
1854 }
308bfa8426db Rewrite application directory detection code for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1505
diff changeset
1855
308bfa8426db Rewrite application directory detection code for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1505
diff changeset
1856 if(*binname)
308bfa8426db Rewrite application directory detection code for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1505
diff changeset
1857 {
308bfa8426db Rewrite application directory detection code for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1505
diff changeset
1858 char *binpos = strstr(pathcopy, "/bin");
308bfa8426db Rewrite application directory detection code for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1505
diff changeset
1859
308bfa8426db Rewrite application directory detection code for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1505
diff changeset
1860 if(binpos)
308bfa8426db Rewrite application directory detection code for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1505
diff changeset
1861 strncpy(_dw_share_path, pathcopy, (size_t)(binpos - pathcopy));
308bfa8426db Rewrite application directory detection code for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1505
diff changeset
1862 else
308bfa8426db Rewrite application directory detection code for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1505
diff changeset
1863 strcpy(_dw_share_path, "/usr/local");
308bfa8426db Rewrite application directory detection code for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1505
diff changeset
1864 strcat(_dw_share_path, "/share/");
308bfa8426db Rewrite application directory detection code for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1505
diff changeset
1865 strcat(_dw_share_path, binname);
1384
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
1866 }
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
1867 if(pathcopy)
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
1868 free(pathcopy);
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
1869 }
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
1870 /* If that failed... just get the current directory */
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
1871 if(!_dw_share_path[0] && !getcwd(_dw_share_path, PATH_MAX))
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
1872 _dw_share_path[0] = '/';
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
1873
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1874 #if !GLIB_CHECK_VERSION(2,31,0)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1875 g_thread_init(NULL);
1355
dd252596227b Removed a now unused variable on GTK in dw_html_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1354
diff changeset
1876 #endif
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
1877
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
1878 /* Load these functions via dlsym to avoid deprecation warnings */
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
1879 _dw_gdk_threads_init = dlsym(RTLD_DEFAULT, "gdk_threads_init");
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
1880 _dw_gdk_threads_enter = dlsym(RTLD_DEFAULT, "gdk_threads_enter");
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
1881 _dw_gdk_threads_leave = dlsym(RTLD_DEFAULT, "gdk_threads_leave");
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
1882
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
1883 _dw_gdk_threads_init();
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1884
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1885 gtk_init(argc, argv);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1886
971
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
1887 pthread_key_create(&_dw_fg_color_key, NULL);
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
1888 pthread_key_create(&_dw_bg_color_key, NULL);
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
1889 pthread_key_create(&_dw_mutex_key, NULL);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1890
1887
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
1891 _dw_init_thread();
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
1892
874
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
1893 /* Create a global object for glib activities */
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
1894 _DWObject = g_object_new(G_TYPE_OBJECT, NULL);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1895
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1896 #ifdef USE_WEBKIT
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1897 init_webkit();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1898 #endif
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1899
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1900 return TRUE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1901 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1902
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1903 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1904 * Runs a message loop for Dynamic Windows.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1905 */
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1524
diff changeset
1906 void API dw_main(void)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1907 {
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
1908 _dw_gdk_threads_enter();
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1909 _dw_thread = pthread_self();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1910 gtk_main();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1911 _dw_thread = (pthread_t)-1;
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
1912 _dw_gdk_threads_leave();
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1913 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1914
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1915 /*
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1524
diff changeset
1916 * Causes running dw_main() to return.
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1524
diff changeset
1917 */
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1524
diff changeset
1918 void API dw_main_quit(void)
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1524
diff changeset
1919 {
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1524
diff changeset
1920 gtk_main_quit();
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1524
diff changeset
1921 }
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1524
diff changeset
1922
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1524
diff changeset
1923 /*
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1924 * Runs a message loop for Dynamic Windows, for a period of milliseconds.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1925 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1926 * milliseconds: Number of milliseconds to run the loop for.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1927 */
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1524
diff changeset
1928 void API dw_main_sleep(int milliseconds)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1929 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1930 struct timeval tv, start;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1931 pthread_t curr = pthread_self();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1932
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1933 gettimeofday(&start, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1934
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1935 if(_dw_thread == (pthread_t)-1 || _dw_thread == curr)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1936 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1937 pthread_t orig = _dw_thread;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1938
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1939 gettimeofday(&tv, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1940
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1941 while(((tv.tv_sec - start.tv_sec)*1000) + ((tv.tv_usec - start.tv_usec)/1000) <= milliseconds)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1942 {
1510
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1943 int _locked_by_me = FALSE;
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1944
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1945 if(orig == (pthread_t)-1)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1946 {
1510
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1947 if(!pthread_getspecific(_dw_mutex_key))
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1948 {
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
1949 _dw_gdk_threads_enter();
1510
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1950 pthread_setspecific(_dw_mutex_key, (void *)1);
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1951 _locked_by_me = TRUE;
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1952 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1953 _dw_thread = curr;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1954 }
1510
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1955 if(curr == _dw_thread && gtk_events_pending())
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1956 gtk_main_iteration();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1957 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1958 _dw_msleep(1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1959 if(orig == (pthread_t)-1)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1960 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1961 _dw_thread = orig;
1510
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1962 if(_locked_by_me)
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1963 {
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1964 pthread_setspecific(_dw_mutex_key, NULL);
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
1965 _dw_gdk_threads_leave();
1510
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1966 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1967 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1968 gettimeofday(&tv, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1969 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1970 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1971 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1972 _dw_msleep(milliseconds);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1973 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1974
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1975 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1976 * Processes a single message iteration and returns.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1977 */
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1524
diff changeset
1978 void API dw_main_iteration(void)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1979 {
1510
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1980 pthread_t orig = _dw_thread;
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1981 pthread_t curr = pthread_self();
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1982 int _locked_by_me = FALSE;
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1983
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1984 if(_dw_thread == (pthread_t)-1)
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1985 {
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1986 if(!pthread_getspecific(_dw_mutex_key))
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1987 {
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
1988 _dw_gdk_threads_enter();
1510
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1989 pthread_setspecific(_dw_mutex_key, (void *)1);
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1990 _locked_by_me = TRUE;
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1991 }
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1992 _dw_thread = curr;
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1993 }
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1994 if(curr == _dw_thread && gtk_events_pending())
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1995 gtk_main_iteration();
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1996 else
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1997 sched_yield();
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1998 if(orig == (pthread_t)-1)
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
1999 {
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
2000 _dw_thread = orig;
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
2001 if(_locked_by_me)
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
2002 {
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
2003 pthread_setspecific(_dw_mutex_key, NULL);
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
2004 _dw_gdk_threads_leave();
1510
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
2005 }
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
2006 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2007 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2008
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2009 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2010 * Free's memory allocated by dynamic windows.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2011 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2012 * ptr: Pointer to dynamic windows allocated
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2013 * memory to be free()'d.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2014 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2015 void dw_free(void *ptr)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2016 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2017 free(ptr);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2018 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2019
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2020 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2021 * Allocates and initializes a dialog struct.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2022 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2023 * data: User defined data to be passed to functions.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2024 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2025 DWDialog *dw_dialog_new(void *data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2026 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2027 DWDialog *tmp = malloc(sizeof(DWDialog));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2028
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2029 if ( tmp )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2030 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2031 tmp->eve = dw_event_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2032 dw_event_reset(tmp->eve);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2033 tmp->data = data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2034 tmp->done = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2035 tmp->method = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2036 tmp->result = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2037 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2038 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2039 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2040
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2041 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2042 * Accepts a dialog struct and returns the given data to the
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2043 * initial called of dw_dialog_wait().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2044 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2045 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2046 * result: Data to be returned by dw_dialog_wait().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2047 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2048 int dw_dialog_dismiss(DWDialog *dialog, void *result)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2049 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2050 dialog->result = result;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2051 if(dialog->method)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2052 gtk_main_quit();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2053 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2054 dw_event_post(dialog->eve);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2055 dialog->done = TRUE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2056 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2057 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2058
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2059 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2060 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2061 * called by a signal handler with the given dialog struct.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2062 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2063 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2064 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2065 void *dw_dialog_wait(DWDialog *dialog)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2066 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2067 void *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2068 int newprocess = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2069
1886
f7d408a47752 Fix a couple of errors reported by the static analyzer on Mac....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1884
diff changeset
2070 if(!dialog)
f7d408a47752 Fix a couple of errors reported by the static analyzer on Mac....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1884
diff changeset
2071 return NULL;
f7d408a47752 Fix a couple of errors reported by the static analyzer on Mac....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1884
diff changeset
2072
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2073 /* _dw_thread will be -1 if dw_main hasn't been run yet. */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2074 if(_dw_thread == (pthread_t)-1)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2075 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2076 _dw_thread = pthread_self();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2077 newprocess = 1;
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
2078 _dw_gdk_threads_enter();
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2079 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2080
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2081 if(pthread_self() == _dw_thread)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2082 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2083 dialog->method = TRUE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2084 gtk_main();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2085 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2086 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2087 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2088 dialog->method = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2089 dw_event_wait(dialog->eve, -1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2090 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2091
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2092 if(newprocess)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2093 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2094 _dw_thread = (pthread_t)-1;
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
2095 _dw_gdk_threads_leave();
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2096 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2097
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2098 dw_event_close(&dialog->eve);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2099 tmp = dialog->result;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2100 free(dialog);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2101 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2102 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2103
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2104 static int _dw_ok_func(HWND window, void *data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2105 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2106 DWDialog *dwwait = (DWDialog *)data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2107
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2108 if(!dwwait)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2109 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2110
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2111 dw_window_destroy((HWND)dwwait->data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2112 dw_dialog_dismiss((DWDialog *)data, (void *)DW_MB_RETURN_OK);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2113 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2114 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2115
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2116 int _dw_yes_func(HWND window, void *data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2117 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2118 DWDialog *dwwait = (DWDialog *)data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2119
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2120 if(!dwwait)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2121 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2122
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2123 dw_window_destroy((HWND)dwwait->data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2124 dw_dialog_dismiss((DWDialog *)data, (void *)DW_MB_RETURN_YES);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2125 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2126 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2127
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2128 int _dw_no_func(HWND window, void *data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2129 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2130 DWDialog *dwwait = (DWDialog *)data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2131
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2132 if(!dwwait)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2133 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2134
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2135 dw_window_destroy((HWND)dwwait->data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2136 dw_dialog_dismiss((DWDialog *)data, (void *)DW_MB_RETURN_NO);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2137 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2138 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2139
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2140 int _dw_cancel_func(HWND window, void *data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2141 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2142 DWDialog *dwwait = (DWDialog *)data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2143
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2144 if(!dwwait)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2145 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2146
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2147 dw_window_destroy((HWND)dwwait->data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2148 dw_dialog_dismiss((DWDialog *)data, (void *)DW_MB_RETURN_CANCEL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2149 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2150 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2151
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2152 /*
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
2153 * Displays a debug message on the console...
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
2154 * Parameters:
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
2155 * format: printf style format string.
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
2156 * ...: Additional variables for use in the format.
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
2157 */
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
2158 void API dw_debug(char *format, ...)
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
2159 {
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
2160 va_list args;
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
2161 char outbuf[1025] = {0};
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
2162
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
2163 va_start(args, format);
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
2164 vsnprintf(outbuf, 1024, format, args);
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
2165 va_end(args);
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
2166
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
2167 fprintf(stderr, "%s", outbuf);
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
2168 }
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
2169
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
2170 /*
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2171 * Displays a Message Box with given text and title..
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2172 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2173 * title: The title of the message box.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2174 * flags: Defines buttons and icons to display
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2175 * format: printf style format string.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2176 * ...: Additional variables for use in the format.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2177 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2178 int dw_messagebox(char *title, int flags, char *format, ...)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2179 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2180 HWND entrywindow, texttargetbox, imagetextbox, mainbox, okbutton, nobutton, yesbutton, cancelbutton, buttonbox, stext;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2181 ULONG flStyle = DW_FCF_TITLEBAR | DW_FCF_SHELLPOSITION | DW_FCF_SIZEBORDER;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2182 DWDialog *dwwait;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2183 va_list args;
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
2184 char outbuf[1025] = {0};
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2185 char **xpm_data = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2186 int x, y, extra_width=0,text_width,text_height;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2187 int width,height;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2188
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2189 va_start(args, format);
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
2190 vsnprintf(outbuf, 1024, format, args);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2191 va_end(args);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2192
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2193 entrywindow = dw_window_new(HWND_DESKTOP, title, flStyle);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2194 mainbox = dw_box_new(DW_VERT, 10);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2195 dw_box_pack_start(entrywindow, mainbox, 0, 0, TRUE, TRUE, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2196
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2197 /* determine if an icon is to be used - if so we need another HORZ box */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2198 if((flags & DW_MB_ERROR) | (flags & DW_MB_WARNING) | (flags & DW_MB_INFORMATION) | (flags & DW_MB_QUESTION))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2199 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2200 imagetextbox = dw_box_new(DW_HORZ, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2201 dw_box_pack_start(mainbox, imagetextbox, 0, 0, TRUE, TRUE, 2);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2202 texttargetbox = imagetextbox;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2203 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2204 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2205 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2206 imagetextbox = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2207 texttargetbox = mainbox;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2208 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2209
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2210 if(flags & DW_MB_ERROR)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2211 xpm_data = (char **)_dw_messagebox_error;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2212 else if(flags & DW_MB_WARNING)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2213 xpm_data = (char **)_dw_messagebox_warning;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2214 else if(flags & DW_MB_INFORMATION)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2215 xpm_data = (char **)_dw_messagebox_information;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2216 else if(flags & DW_MB_QUESTION)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2217 xpm_data = (char **)_dw_messagebox_question;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2218
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2219 if(xpm_data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2220 extra_width = 32;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2221
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2222 if(texttargetbox == imagetextbox)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2223 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2224 HWND handle = dw_bitmap_new( 100 );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2225 GdkPixbuf *icon_pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)xpm_data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2226
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2227 gtk_image_set_from_pixbuf(GTK_IMAGE(handle), icon_pixbuf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2228
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2229 dw_box_pack_start( texttargetbox, handle, 32, 32, FALSE, FALSE, 2);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2230 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2231
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2232 /* Create text */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2233 text_width = 240;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2234 text_height = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2235 stext = dw_text_new(outbuf, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2236 dw_window_set_style(stext, DW_DT_WORDBREAK, DW_DT_WORDBREAK);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2237 dw_font_text_extents_get(stext, NULL, outbuf, &width, &height);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
2238
784
fb21fdd6b839 Slight code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 783
diff changeset
2239 text_width = min( width, dw_screen_width() - extra_width - 100 );
fb21fdd6b839 Slight code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 783
diff changeset
2240 text_height = min( height, dw_screen_height() );
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
2241
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2242 dw_box_pack_start(texttargetbox, stext, text_width, text_height, TRUE, TRUE, 2);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2243
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2244 /* Buttons */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2245 buttonbox = dw_box_new(DW_HORZ, 10);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2246
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2247 dw_box_pack_start(mainbox, buttonbox, 0, 0, TRUE, FALSE, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2248
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2249 dwwait = dw_dialog_new((void *)entrywindow);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2250
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2251 /* which buttons ? */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2252 if(flags & DW_MB_OK)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2253 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2254 okbutton = dw_button_new("Ok", 1001L);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2255 dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, FALSE, 2);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2256 dw_signal_connect(okbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_ok_func), (void *)dwwait);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2257 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2258 else if(flags & DW_MB_OKCANCEL)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2259 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2260 okbutton = dw_button_new("Ok", 1001L);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2261 dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, FALSE, 2);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2262 dw_signal_connect(okbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_ok_func), (void *)dwwait);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2263 cancelbutton = dw_button_new("Cancel", 1002L);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2264 dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, FALSE, 2);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2265 dw_signal_connect(cancelbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_cancel_func), (void *)dwwait);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2266 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2267 else if(flags & DW_MB_YESNO)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2268 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2269 yesbutton = dw_button_new("Yes", 1001L);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2270 dw_box_pack_start(buttonbox, yesbutton, 50, 30, TRUE, FALSE, 2);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2271 dw_signal_connect(yesbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_yes_func), (void *)dwwait);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2272 nobutton = dw_button_new("No", 1002L);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2273 dw_box_pack_start(buttonbox, nobutton, 50, 30, TRUE, FALSE, 2);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2274 dw_signal_connect(nobutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_no_func), (void *)dwwait);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2275 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2276 else if(flags & DW_MB_YESNOCANCEL)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2277 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2278 yesbutton = dw_button_new("Yes", 1001L);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2279 dw_box_pack_start(buttonbox, yesbutton, 50, 30, TRUE, FALSE, 2);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2280 dw_signal_connect(yesbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_yes_func), (void *)dwwait);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2281 nobutton = dw_button_new("No", 1002L);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2282 dw_box_pack_start(buttonbox, nobutton, 50, 30, TRUE, FALSE, 2);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2283 dw_signal_connect(nobutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_no_func), (void *)dwwait);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2284 cancelbutton = dw_button_new("Cancel", 1003L);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2285 dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, FALSE, 2);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2286 dw_signal_connect(cancelbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_cancel_func), (void *)dwwait);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2287 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2288
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2289 height = max(50,text_height)+100;
1121
fb92778105b2 Fixes some major window positioning problems in GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1118
diff changeset
2290 x = (dw_screen_width() - (text_width+60+extra_width))/2;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2291 y = (dw_screen_height() - height)/2;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2292
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2293 dw_window_set_pos_size(entrywindow, x, y, (text_width+60+extra_width), height);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2294
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2295 dw_window_show(entrywindow);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2296
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
2297 return GPOINTER_TO_INT(dw_dialog_wait(dwwait));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2298 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2299
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2300 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2301 * Minimizes or Iconifies a top-level window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2302 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2303 * handle: The window handle to minimize.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2304 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2305 int dw_window_minimize(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2306 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2307 int _locked_by_me = FALSE;
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
2308 #ifdef DW_INCLUDE_DEPRECATED
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2309 GtkWidget *mdi = NULL;
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
2310 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2311
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2312 if(!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2313 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2314
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2315 DW_MUTEX_LOCK;
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
2316 #ifdef DW_INCLUDE_DEPRECATED
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2317 if((mdi = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_mdi")) && GTK_IS_MDI(mdi))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2318 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2319 gtk_mdi_set_state(GTK_MDI(mdi), handle, CHILD_ICONIFIED);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2320 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2321 else
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
2322 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2323 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2324 gtk_window_iconify( GTK_WINDOW(handle) );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2325 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2326 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2327 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2328 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2329
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2330 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2331 * Makes the window topmost.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2332 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2333 * handle: The window handle to make topmost.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2334 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2335 int dw_window_raise(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2336 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2337 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2338
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2339 if(!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2340 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2341
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2342 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2343 gdk_window_raise(gtk_widget_get_window(GTK_WIDGET(handle)));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2344 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2345 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2346 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2347
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2348 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2349 * Makes the window bottommost.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2350 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2351 * handle: The window handle to make bottommost.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2352 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2353 int dw_window_lower(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2354 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2355 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2356
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2357 if(!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2358 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2359
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2360 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2361 gdk_window_lower(gtk_widget_get_window(GTK_WIDGET(handle)));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2362 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2363 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2364 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2365
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2366 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2367 * Makes the window visible.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2368 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2369 * handle: The window handle to make visible.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2370 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2371 int dw_window_show(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2372 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2373 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2374 GtkWidget *defaultitem;
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
2375 #ifdef DW_INCLUDE_DEPRECATED
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2376 GtkWidget *mdi;
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
2377 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2378
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2379 if (!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2380 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2381
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2382 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2383 gtk_widget_show(handle);
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
2384 #ifdef DW_INCLUDE_DEPRECATED
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2385 if ((mdi = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_mdi")) && GTK_IS_MDI(mdi))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2386 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2387 gtk_mdi_set_state(GTK_MDI(mdi), handle, CHILD_NORMAL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2388 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2389 else
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
2390 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2391 {
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2392 GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(handle));
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2393 if (window && gtk_widget_get_mapped(handle))
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2394 {
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
2395 int width = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_width"));
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
2396 int height = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_height"));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2397
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2398 /* If we had a size request before shown */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2399 if (width || height)
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2400 {
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2401 /* Call the size function again now that we are realized */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2402 dw_window_set_size(handle, width, height);
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2403 /* Clear out the data so we don't do it again */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2404 g_object_set_data(G_OBJECT(handle), "_dw_width", NULL);
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2405 g_object_set_data(G_OBJECT(handle), "_dw_height", NULL);
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2406 }
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2407
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2408 /* If we had a position request before shown */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2409 if (g_object_get_data(G_OBJECT(handle), "_dw_pos"))
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2410 {
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2411 int x = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_x"));
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2412 int y = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_y"));
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2413
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2414 /* Call the position function again now that we are realized */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2415 dw_window_set_pos(handle, x, y);
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2416 /* Clear out the data so we don't do it again */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2417 g_object_set_data(G_OBJECT(handle), "_dw_pos", NULL);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2418 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2419
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2420 gdk_window_raise(window);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2421 gdk_flush();
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
2422 gdk_window_show(window);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2423 gdk_flush();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2424 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2425 defaultitem = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_defaultitem");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2426 if (defaultitem)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2427 gtk_widget_grab_focus(defaultitem);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2428 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2429 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2430 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2431 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2432
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2433 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2434 * Makes the window invisible.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2435 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2436 * handle: The window handle to make visible.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2437 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2438 int dw_window_hide(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2439 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2440 int _locked_by_me = FALSE;
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
2441 #ifdef DW_INCLUDE_DEPRECATED
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2442 GtkWidget *mdi = NULL;
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
2443 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2444
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2445 if(!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2446 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2447
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2448 DW_MUTEX_LOCK;
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
2449 #ifdef DW_INCLUDE_DEPRECATED
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2450 if((mdi = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_mdi")) && GTK_IS_MDI(mdi))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2451 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2452 gtk_mdi_set_state(GTK_MDI(mdi), handle, CHILD_ICONIFIED);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2453 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2454 else
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
2455 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2456 gtk_widget_hide(handle);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2457 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2458 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2459 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2460
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2461 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2462 * Destroys a window and all of it's children.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2463 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2464 * handle: The window handle to destroy.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2465 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2466 int dw_window_destroy(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2467 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2468 int _locked_by_me = FALSE;
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
2469 #ifdef DW_INCLUDE_DEPRECATED
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2470 GtkWidget *mdi = NULL;
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
2471 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2472
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2473 if(!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2474 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2475
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2476 DW_MUTEX_LOCK;
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
2477 #ifdef DW_INCLUDE_DEPRECATED
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2478 if((mdi = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_mdi")) && GTK_IS_MDI(mdi))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2479 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2480 gtk_mdi_remove(GTK_MDI(mdi), handle);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2481 }
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
2482 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2483 if(GTK_IS_WIDGET(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2484 {
1656
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
2485 GtkWidget *box, *handle2 = handle;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2486 GtkWidget *eventbox = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_eventbox");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2487
1656
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
2488 /* Handle the invisible event box if it exists */
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2489 if(eventbox && GTK_IS_WIDGET(eventbox))
1656
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
2490 handle2 = eventbox;
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
2491
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
2492 /* Check if we are removing a widget from a box */
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
2493 if((box = gtk_widget_get_parent(handle2)) && GTK_IS_GRID(box))
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
2494 {
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
2495 /* Get the number of items in the box... */
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
2496 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount"));
1890
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2497 #if GTK_CHECK_VERSION(3,10,0)
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2498 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype"));
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2499 int z;
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2500
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2501 /* Figure out where in the grid this widget is and remove that row/column */
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2502 if(boxtype == DW_VERT)
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2503 {
1891
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
2504 for(z=0;z<boxcount;z++)
1890
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2505 {
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2506 if(gtk_grid_get_child_at(GTK_GRID(box), 0, z) == handle2)
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2507 {
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2508 gtk_grid_remove_row(GTK_GRID(box), z);
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2509 break;
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2510 }
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2511 }
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2512 }
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2513 else
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2514 {
1891
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
2515 for(z=0;z<boxcount;z++)
1890
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2516 {
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2517 if(gtk_grid_get_child_at(GTK_GRID(box), z, 0) == handle2)
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2518 {
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2519 gtk_grid_remove_column(GTK_GRID(box), z);
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2520 break;
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2521 }
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2522 }
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2523 }
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
2524 #endif
1656
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
2525
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
2526 if(boxcount > 0)
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
2527 {
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
2528 /* Decrease the count by 1 */
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
2529 boxcount--;
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
2530 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount));
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
2531 }
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
2532 }
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
2533 /* Finally destroy the widget */
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
2534 gtk_widget_destroy(handle2);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2535 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2536 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2537 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2538 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2539
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2540 /* Causes entire window to be invalidated and redrawn.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2541 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2542 * handle: Toplevel window handle to be redrawn.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2543 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2544 void dw_window_redraw(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2545 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2546 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2547
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2548 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2549 * Changes a window's parent to newparent.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2550 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2551 * handle: The window handle to destroy.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2552 * newparent: The window's new parent window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2553 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2554 void dw_window_reparent(HWND handle, HWND newparent)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2555 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2556 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2557
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2558 DW_MUTEX_LOCK;
1124
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
2559 gdk_window_reparent(gtk_widget_get_window(GTK_WIDGET(handle)), newparent ? gtk_widget_get_window(GTK_WIDGET(newparent)) : gdk_get_default_root_window(), 0, 0);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2560 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2561 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2562
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2563 /*
1076
dbaf1b11c301 Added stub dw_font_set_default() functions for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1072
diff changeset
2564 * Sets the default font used on text based widgets.
dbaf1b11c301 Added stub dw_font_set_default() functions for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1072
diff changeset
2565 * Parameters:
dbaf1b11c301 Added stub dw_font_set_default() functions for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1072
diff changeset
2566 * fontname: Font name in Dynamic Windows format.
dbaf1b11c301 Added stub dw_font_set_default() functions for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1072
diff changeset
2567 */
dbaf1b11c301 Added stub dw_font_set_default() functions for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1072
diff changeset
2568 void API dw_font_set_default(char *fontname)
dbaf1b11c301 Added stub dw_font_set_default() functions for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1072
diff changeset
2569 {
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
2570 char *oldfont = _DWDefaultFont;
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
2571
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
2572 _DWDefaultFont = strdup(fontname);
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
2573
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
2574 if(oldfont)
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
2575 free(oldfont);
1076
dbaf1b11c301 Added stub dw_font_set_default() functions for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1072
diff changeset
2576 }
dbaf1b11c301 Added stub dw_font_set_default() functions for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1072
diff changeset
2577
1240
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
2578 /* Convert DW style font to pango style */
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
2579 void _convert_font(char *font)
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
2580 {
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
2581 char *name = strchr(font, '.');
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
2582
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
2583 /* Detect Dynamic Windows style font name...
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
2584 * Format: ##.Fontname
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
2585 * and convert to a Pango name
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
2586 */
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
2587 if(name && isdigit(*font))
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
2588 {
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
2589 int size = atoi(font);
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
2590 *name = 0;
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
2591 name++;
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
2592 sprintf(font, "%s %d", name, size);
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
2593 }
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
2594 }
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
2595
1915
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2596 /* Internal functions to convert to GTK3 style CSS */
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2597 static void _dw_override_color(GtkWidget *widget, const char *element, GdkRGBA *color)
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2598 {
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2599 if(color)
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2600 {
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2601 GtkCssProvider *provider = gtk_css_provider_new();
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2602 gchar *scolor = gdk_rgba_to_string(color);
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2603 gchar *css = g_strdup_printf ("* { %s: %s; }", element, scolor);
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2604
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2605 g_free(scolor);
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2606 gtk_css_provider_load_from_data(provider, css, -1, NULL);
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2607 g_free(css);
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2608 gtk_style_context_add_provider(gtk_widget_get_style_context(widget), GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2609 g_object_unref(provider);
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2610 }
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2611 }
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2612
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2613 static void _dw_override_font(GtkWidget *widget, const char *font)
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2614 {
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2615 GtkCssProvider *provider = gtk_css_provider_new();
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2616 gchar *css = g_strdup_printf ("* { font: %s; }", font);
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2617
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2618 gtk_css_provider_load_from_data(provider, css, -1, NULL);
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2619 g_free(css);
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2620 gtk_style_context_add_provider(gtk_widget_get_style_context(widget), GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2621 g_object_unref(provider);
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2622 }
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2623
1076
dbaf1b11c301 Added stub dw_font_set_default() functions for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1072
diff changeset
2624 /*
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2625 * Sets the font used by a specified window (widget) handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2626 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2627 * handle: The window (widget) handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2628 * fontname: Name and size of the font in the form "size.fontname"
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2629 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2630 int dw_window_set_font(HWND handle, char *fontname)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2631 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2632 GtkWidget *handle2 = handle;
1001
4ef0e878fe06 Added support for Dynamic Windows style font names for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 998
diff changeset
2633 char *font = strdup(fontname);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2634 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2635 gpointer data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2636
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2637 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2638 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2639 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2640 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2641 if(tmp)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2642 handle2 = tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2643 }
1038
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2644 /* If it is a groupox we want to operate on the frame label */
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2645 else if(GTK_IS_FRAME(handle))
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2646 {
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2647 GtkWidget *tmp = gtk_frame_get_label_widget(GTK_FRAME(handle));
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2648 if(tmp)
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2649 handle2 = tmp;
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2650 }
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
2651 else if(GTK_IS_COMBO_BOX(handle) || GTK_IS_BUTTON(handle))
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
2652 {
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
2653 GtkWidget *tmp = gtk_bin_get_child(GTK_BIN(handle));
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
2654 if(tmp)
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
2655 handle2 = tmp;
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
2656 }
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
2657
1240
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
2658 _convert_font(font);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2659
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2660 /* Free old font name if one is allocated */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2661 data = g_object_get_data(G_OBJECT(handle2), "_dw_fontname");
1240
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
2662 g_object_set_data(G_OBJECT(handle2), "_dw_fontname", (gpointer)font);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2663 if(data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2664 free(data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2665
1915
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2666 _dw_override_font(handle2, font);
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2667
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2668 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2669 return TRUE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2670 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2671
1053
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2672 /* Allows the user to choose a font using the system's font chooser dialog.
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2673 * Parameters:
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2674 * currfont: current font
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2675 * Returns:
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2676 * A malloced buffer with the selected font or NULL on error.
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2677 */
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2678 char * API dw_font_choose(char *currfont)
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2679 {
1576
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2680 GtkFontChooser *fd;
1053
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2681 char *font = currfont ? strdup(currfont) : NULL;
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2682 char *name = font ? strchr(font, '.') : NULL;
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2683 int _locked_by_me = FALSE;
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2684 char *retfont = NULL;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
2685
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
2686 /* Detect Dynamic Windows style font name...
1053
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2687 * Format: ##.Fontname
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2688 * and convert to a Pango name
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2689 */
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2690 if(name && isdigit(*font))
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2691 {
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2692 int size = atoi(font);
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2693 *name = 0;
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2694 name++;
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2695 sprintf(font, "%s %d", name, size);
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2696 }
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2697
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2698 DW_MUTEX_LOCK;
1576
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2699 fd = (GtkFontChooser *)gtk_font_chooser_dialog_new("Choose font", NULL);
1057
0cd0089ee17d Fix issue with using/freeing the wrong variable in GTK3 font chooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1054
diff changeset
2700 if(font)
0cd0089ee17d Fix issue with using/freeing the wrong variable in GTK3 font chooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1054
diff changeset
2701 {
1576
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2702 gtk_font_chooser_set_font(fd, font);
1057
0cd0089ee17d Fix issue with using/freeing the wrong variable in GTK3 font chooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1054
diff changeset
2703 free(font);
1053
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2704 }
1576
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2705
1053
0725114533fe Changes to the GTK3 font chooser... this version doesn't block the rest of the app.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1052
diff changeset
2706 gtk_widget_show(GTK_WIDGET(fd));
1576
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2707
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2708 if(gtk_dialog_run(GTK_DIALOG(fd)) == GTK_RESPONSE_OK)
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2709 {
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2710 char *fontname = gtk_font_chooser_get_font(fd);
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2711 if(fontname && (retfont = strdup(fontname)))
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2712 {
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2713 int len = strlen(fontname);
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2714 /* Convert to Dynamic Windows format if we can... */
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2715 if(len > 0 && isdigit(fontname[len-1]))
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2716 {
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2717 int size, x=len-1;
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2718
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2719 while(x > 0 && fontname[x] != ' ')
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2720 {
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2721 x--;
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2722 }
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2723 size = atoi(&fontname[x]);
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2724 /* If we were able to find a valid size... */
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2725 if(size > 0)
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2726 {
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2727 /* Null terminate after the name...
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2728 * and create the Dynamic Windows style font.
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2729 */
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2730 fontname[x] = 0;
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2731 snprintf(retfont, len+1, "%d.%s", size, fontname);
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2732 }
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2733 }
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2734 g_free(fontname);
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2735 }
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2736 }
85fa989dc833 Switched to using new GtkFontChooserDialog for GTK3 since GtkFontSelectionDialog is deprecated.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1575
diff changeset
2737 gtk_widget_destroy(GTK_WIDGET(fd));
1052
c008a186b735 Added dw_font_choose() on GTK3 for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1046
diff changeset
2738 DW_MUTEX_UNLOCK;
c008a186b735 Added dw_font_choose() on GTK3 for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1046
diff changeset
2739 return retfont;
c008a186b735 Added dw_font_choose() on GTK3 for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1046
diff changeset
2740 }
c008a186b735 Added dw_font_choose() on GTK3 for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1046
diff changeset
2741
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2742 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2743 * Gets the font used by a specified window (widget) handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2744 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2745 * handle: The window (widget) handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2746 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2747 char *dw_window_get_font(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2748 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2749 PangoFontDescription *pfont;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2750 PangoContext *pcontext;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2751 GtkWidget *handle2 = handle;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2752 char *font;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2753 char *retfont=NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2754 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2755
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2756 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2757 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2758 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2759 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2760 if(tmp)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2761 handle2 = tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2762 }
1038
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2763 /* If it is a groupox we want to operate on the frame label */
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2764 else if(GTK_IS_FRAME(handle))
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2765 {
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2766 GtkWidget *tmp = gtk_frame_get_label_widget(GTK_FRAME(handle));
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2767 if(tmp)
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2768 handle2 = tmp;
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2769 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2770
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2771 pcontext = gtk_widget_get_pango_context( handle2 );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2772 if ( pcontext )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2773 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2774 pfont = pango_context_get_font_description( pcontext );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2775 if ( pfont )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2776 {
1038
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2777 int len, x;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
2778
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2779 font = pango_font_description_to_string( pfont );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2780 retfont = strdup(font);
1038
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2781 len = strlen(font);
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2782 /* Convert to Dynamic Windows format if we can... */
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2783 if(len > 0 && isdigit(font[len-1]))
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2784 {
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2785 int size;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
2786
1038
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2787 x=len-1;
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2788 while(x > 0 && font[x] != ' ')
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2789 {
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2790 x--;
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2791 }
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2792 size = atoi(&font[x]);
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2793 /* If we were able to find a valid size... */
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2794 if(size > 0)
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2795 {
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2796 /* Null terminate after the name...
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2797 * and create the Dynamic Windows style font.
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2798 */
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2799 font[x] = 0;
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2800 snprintf(retfont, len+1, "%d.%s", size, font);
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2801 }
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
2802 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2803 g_free( font );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2804 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2805 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2806 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2807 return retfont;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2808 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2809
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2810 void _free_gdk_colors(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2811 {
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
2812 GdkRGBA *old = (GdkRGBA *)g_object_get_data(G_OBJECT(handle), "_dw_foregdk");
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2813
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2814 if(old)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2815 free(old);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2816
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
2817 old = (GdkRGBA *)g_object_get_data(G_OBJECT(handle), "_dw_backgdk");
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2818
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2819 if(old)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2820 free(old);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2821 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2822
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2823 /* Free old color pointers and allocate new ones */
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
2824 static void _save_gdk_colors(HWND handle, GdkRGBA fore, GdkRGBA back)
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
2825 {
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
2826 GdkRGBA *foregdk = malloc(sizeof(GdkRGBA));
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
2827 GdkRGBA *backgdk = malloc(sizeof(GdkRGBA));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2828
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2829 _free_gdk_colors(handle);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2830
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2831 *foregdk = fore;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2832 *backgdk = back;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2833
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2834 g_object_set_data(G_OBJECT(handle), "_dw_foregdk", (gpointer)foregdk);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2835 g_object_set_data(G_OBJECT(handle), "_dw_backgdk", (gpointer)backgdk);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2836 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2837
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2838 static int _set_color(HWND handle, unsigned long fore, unsigned long back)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2839 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2840 /* Remember that each color component in X11 use 16 bit no matter
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2841 * what the destination display supports. (and thus GDK)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2842 */
1847
ff80ad40a5d6 Initial attempt at allowing DW_CLR_DEFAULT clear color style overrides on GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1832
diff changeset
2843 GdkRGBA forecolor = {0}, backcolor = {0};
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2844
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2845 if(fore & DW_RGB_COLOR)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2846 {
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
2847 forecolor.alpha = 1.0;
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
2848 forecolor.red = (gdouble)DW_RED_VALUE(fore) / 255.0;
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
2849 forecolor.green = (gdouble)DW_GREEN_VALUE(fore) / 255.0;
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
2850 forecolor.blue = (gdouble)DW_BLUE_VALUE(fore) / 255.0;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2851 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2852 else if(fore != DW_CLR_DEFAULT)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2853 forecolor = _colors[fore];
1847
ff80ad40a5d6 Initial attempt at allowing DW_CLR_DEFAULT clear color style overrides on GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1832
diff changeset
2854
1915
98579be1198e Experimental change to use CSS to change widget colors on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1913
diff changeset
2855 _dw_override_color(handle, "color", fore != DW_CLR_DEFAULT ? &forecolor : NULL);
1847
ff80ad40a5d6 Initial attempt at allowing DW_CLR_DEFAULT clear color style overrides on GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1832
diff changeset
2856
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2857 if(back & DW_RGB_COLOR)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2858 {
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
2859 backcolor.alpha = 1.0;
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
2860 backcolor.red = (gdouble)DW_RED_VALUE(back) / 255.0;
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
2861 backcolor.green = (gdouble)DW_GREEN_VALUE(back) / 255.0;
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
2862 backcolor.blue = (gdouble)DW_BLUE_VALUE(back) / 255.0;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2863 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2864 else if(back != DW_CLR_DEFAULT)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2865 backcolor = _colors[back];
1847
ff80ad40a5d6 Initial attempt at allowing DW_CLR_DEFAULT clear color style overrides on GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1832
diff changeset
2866
1916
eafaab13d0db Minor fix to that last commit, and remove call to gtk_tree_view_set_rules_hint()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1915
diff changeset
2867 _dw_override_color(handle, "background-color", back != DW_CLR_DEFAULT ? &backcolor : NULL);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2868
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2869 _save_gdk_colors(handle, forecolor, backcolor);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2870
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2871 return TRUE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2872 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2873 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2874 * Sets the colors used by a specified window (widget) handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2875 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2876 * handle: The window (widget) handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2877 * fore: Foreground color in RGB format.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2878 * back: Background color in RGB format.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2879 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2880 int dw_window_set_color(HWND handle, unsigned long fore, unsigned long back)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2881 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2882 GtkWidget *handle2 = handle;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2883 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2884
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2885 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2886
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2887 if(GTK_IS_SCROLLED_WINDOW(handle) || GTK_IS_BOX(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2888 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2889 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2890 if(tmp)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2891 handle2 = tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2892 }
1124
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
2893 else if(GTK_IS_GRID(handle))
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2894 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2895 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_eventbox");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2896 if(tmp)
1637
c8a0daa53e49 In GTK 3.4 foreground colors are now inherited from the parent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1634
diff changeset
2897 {
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2898 handle2 = tmp;
1637
c8a0daa53e49 In GTK 3.4 foreground colors are now inherited from the parent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1634
diff changeset
2899 fore = DW_CLR_DEFAULT;
c8a0daa53e49 In GTK 3.4 foreground colors are now inherited from the parent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1634
diff changeset
2900 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2901 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2902
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2903 _set_color(handle2, fore, back);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2904
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2905 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2906 return TRUE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2907 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2908
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2909 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2910 * Sets the font used by a specified window (widget) handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2911 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2912 * handle: The window (widget) handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2913 * border: Size of the window border in pixels.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2914 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2915 int dw_window_set_border(HWND handle, int border)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2916 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2917 /* TODO */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2918 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2919 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2920
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
2921 static GdkDeviceManager *manager = NULL;
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
2922
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2923 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2924 * Captures the mouse input to this window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2925 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2926 * handle: Handle to receive mouse input.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2927 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2928 void dw_window_capture(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2929 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2930 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2931
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2932 DW_MUTEX_LOCK;
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
2933 manager = gdk_display_get_device_manager(gtk_widget_get_display(handle));
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
2934 gdk_device_grab(gdk_device_manager_get_client_pointer(manager),
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
2935 gtk_widget_get_window(handle),
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
2936 GDK_OWNERSHIP_WINDOW,
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
2937 FALSE,
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
2938 GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK,
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
2939 NULL,
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
2940 GDK_CURRENT_TIME);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2941 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2942 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2943
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2944 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2945 * Changes the appearance of the mouse pointer.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2946 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2947 * handle: Handle to widget for which to change.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2948 * cursortype: ID of the pointer you want.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2949 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2950 void dw_window_set_pointer(HWND handle, int pointertype)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2951 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2952 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2953 GdkCursor *cursor;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2954
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2955 DW_MUTEX_LOCK;
976
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
2956 if(pointertype > 65535)
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
2957 {
1106
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
2958 GdkPixbuf *pixbuf = _find_pixbuf(GINT_TO_POINTER(pointertype), NULL, NULL);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2959 cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), pixbuf, 8, 8);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2960 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2961 else if(!pointertype)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2962 cursor = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2963 else
1912
5035750bcc65 Fix some deprecation warnings in recent GTK3 versions...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1900
diff changeset
2964 cursor = gdk_cursor_new_for_display(gdk_display_get_default(), pointertype);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2965 if(handle && gtk_widget_get_window(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2966 gdk_window_set_cursor(gtk_widget_get_window(handle), cursor);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2967 if(cursor)
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
2968 g_object_unref(cursor);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2969 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2970 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2971
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2972 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2973 * Releases previous mouse capture.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2974 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2975 void dw_window_release(void)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2976 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2977 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2978
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2979 DW_MUTEX_LOCK;
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
2980 gdk_device_ungrab(gdk_device_manager_get_client_pointer(manager), GDK_CURRENT_TIME);
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
2981 manager = NULL;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2982 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2983 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2984
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2985 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2986 * Create a new Window Frame.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2987 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2988 * owner: The Owner's window handle or HWND_DESKTOP.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2989 * title: The Window title.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2990 * flStyle: Style flags, see the PM reference.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2991 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2992 HWND dw_window_new(HWND hwndOwner, char *title, unsigned long flStyle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2993 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2994 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2995 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2996 int flags = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2997
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2998 DW_MUTEX_LOCK;
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
2999 #ifdef DW_INCLUDE_DEPRECATED
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3000 if(hwndOwner && GTK_IS_MDI(hwndOwner))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3001 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3002 GtkWidget *label;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3003
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3004 tmp = dw_box_new(DW_VERT, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3005
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3006 label = gtk_label_new(title);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3007 gtk_widget_show(label);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3008 g_object_set_data(G_OBJECT(tmp), "_dw_mdi_child", GINT_TO_POINTER(1));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3009 g_object_set_data(G_OBJECT(tmp), "_dw_mdi_title", (gpointer)label);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3010 g_object_set_data(G_OBJECT(tmp), "_dw_mdi", (gpointer)hwndOwner);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3011
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3012 gtk_mdi_put(GTK_MDI(hwndOwner), tmp, 100, 75, label);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3013 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3014 else
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
3015 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3016 {
1451
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3017 GtkWidget *box = dw_box_new(DW_VERT, 0);
1452
dbe16031ffb4 Changes for GTK to make top-level windows act more like on other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1451
diff changeset
3018 GtkWidget *grid = gtk_grid_new();
dbe16031ffb4 Changes for GTK to make top-level windows act more like on other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1451
diff changeset
3019
dbe16031ffb4 Changes for GTK to make top-level windows act more like on other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1451
diff changeset
3020 gtk_widget_show_all(grid);
dbe16031ffb4 Changes for GTK to make top-level windows act more like on other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1451
diff changeset
3021
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3022 last_window = tmp = gtk_window_new(GTK_WINDOW_TOPLEVEL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3023
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3024 gtk_window_set_title(GTK_WINDOW(tmp), title);
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
3025 gtk_window_set_resizable(GTK_WINDOW(tmp), (flStyle & DW_FCF_SIZEBORDER) ? TRUE : FALSE);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3026
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3027 gtk_widget_realize(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3028
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3029 if(flStyle & DW_FCF_TITLEBAR)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3030 flags |= GDK_DECOR_TITLE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3031
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3032 if(flStyle & DW_FCF_MINMAX)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3033 flags |= GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3034
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3035 if(flStyle & DW_FCF_SIZEBORDER)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3036 flags |= GDK_DECOR_RESIZEH | GDK_DECOR_BORDER;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3037
1491
d77b8cf25f04 Code cleanup and removed some erroneous code for GTK in dw_window_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1486
diff changeset
3038 if(flStyle & (DW_FCF_BORDER | DW_FCF_DLGBORDER))
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3039 flags |= GDK_DECOR_BORDER;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3040
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3041 if(flStyle & DW_FCF_MAXIMIZE)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3042 gtk_window_maximize(GTK_WINDOW(tmp));
1491
d77b8cf25f04 Code cleanup and removed some erroneous code for GTK in dw_window_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1486
diff changeset
3043
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3044 if(flStyle & DW_FCF_MINIMIZE)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3045 gtk_window_iconify(GTK_WINDOW(tmp));
1491
d77b8cf25f04 Code cleanup and removed some erroneous code for GTK in dw_window_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1486
diff changeset
3046
1388
8fe15c1648c9 Fix windows on GTK that aren't supposed to have a close button..
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
3047 /* Either the CLOSEBUTTON or SYSMENU flags should make it deletable */
1491
d77b8cf25f04 Code cleanup and removed some erroneous code for GTK in dw_window_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1486
diff changeset
3048 gtk_window_set_deletable(GTK_WINDOW(tmp), (flStyle & (DW_FCF_CLOSEBUTTON | DW_FCF_SYSMENU)) ? TRUE : FALSE);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3049
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3050 gdk_window_set_decorations(gtk_widget_get_window(tmp), flags);
1482
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
3051 if(!flags)
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
3052 gtk_window_set_decorated(GTK_WINDOW(tmp), FALSE);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3053
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3054 if(hwndOwner)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3055 gdk_window_reparent(gtk_widget_get_window(GTK_WIDGET(tmp)), gtk_widget_get_window(GTK_WIDGET(hwndOwner)), 0, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3056
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3057 if(flStyle & DW_FCF_SIZEBORDER)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3058 g_object_set_data(G_OBJECT(tmp), "_dw_size", GINT_TO_POINTER(1));
1451
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3059
1452
dbe16031ffb4 Changes for GTK to make top-level windows act more like on other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1451
diff changeset
3060 gtk_grid_attach(GTK_GRID(grid), box, 0, 1, 1, 1);
dbe16031ffb4 Changes for GTK to make top-level windows act more like on other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1451
diff changeset
3061 gtk_container_add(GTK_CONTAINER(tmp), grid);
1451
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3062 g_object_set_data(G_OBJECT(tmp), "_dw_boxhandle", (gpointer)box);
1452
dbe16031ffb4 Changes for GTK to make top-level windows act more like on other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1451
diff changeset
3063 g_object_set_data(G_OBJECT(tmp), "_dw_grid", (gpointer)grid);
1510
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
3064 gtk_widget_add_events(GTK_WIDGET(tmp), GDK_PROPERTY_CHANGE_MASK);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3065 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3066 g_object_set_data(G_OBJECT(tmp), "_dw_style", GINT_TO_POINTER(flStyle));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3067 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3068 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3069 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3070
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3071 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3072 * Create a new Box to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3073 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3074 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3075 * pad: Number of pixels to pad around the box.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3076 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3077 HWND dw_box_new(int type, int pad)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3078 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3079 GtkWidget *tmp, *eventbox;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3080 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3081
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3082 DW_MUTEX_LOCK;
1124
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
3083 tmp = gtk_grid_new();
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3084 eventbox = gtk_event_box_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3085
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3086 gtk_widget_show(eventbox);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3087 g_object_set_data(G_OBJECT(tmp), "_dw_eventbox", (gpointer)eventbox);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3088 g_object_set_data(G_OBJECT(tmp), "_dw_boxtype", GINT_TO_POINTER(type));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3089 g_object_set_data(G_OBJECT(tmp), "_dw_boxpad", GINT_TO_POINTER(pad));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3090 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3091 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3092 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3093 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3094
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3095 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3096 * Create a new scrollable Box to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3097 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3098 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3099 * pad: Number of pixels to pad around the box.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3100 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3101 HWND dw_scrollbox_new( int type, int pad )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3102 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3103 GtkWidget *tmp, *box, *eventbox;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3104 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3105
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3106 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3107 tmp = gtk_scrolled_window_new(NULL, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3108 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3109
1124
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
3110 box = gtk_grid_new();
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3111 eventbox = gtk_event_box_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3112
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3113 gtk_widget_show(eventbox);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3114 g_object_set_data(G_OBJECT(box), "_dw_eventbox", (gpointer)eventbox);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3115 g_object_set_data(G_OBJECT(box), "_dw_boxtype", GINT_TO_POINTER(type));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3116 g_object_set_data(G_OBJECT(box), "_dw_boxpad", GINT_TO_POINTER(pad));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3117 g_object_set_data(G_OBJECT(tmp), "_dw_boxhandle", (gpointer)box);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3118
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
3119 #if GTK_CHECK_VERSION(3,8,0)
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
3120 gtk_container_add(GTK_CONTAINER(tmp), box);
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
3121 #else
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3122 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp),box);
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
3123 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3124 g_object_set_data(G_OBJECT(tmp), "_dw_user", box);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3125 gtk_widget_show(box);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3126 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3127
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3128 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3129 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3130 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3131
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3132 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3133 * Returns the position of the scrollbar in the scrollbox
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3134 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3135 * handle: Handle to the scrollbox to be queried.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3136 * orient: The vertical or horizontal scrollbar.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3137 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3138 int dw_scrollbox_get_pos(HWND handle, int orient)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3139 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3140 int val = -1, _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3141 GtkAdjustment *adjustment;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3142
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3143 if (!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3144 return -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3145
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3146 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3147 if ( orient == DW_HORZ )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3148 adjustment = gtk_scrolled_window_get_hadjustment( GTK_SCROLLED_WINDOW(handle) );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3149 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3150 adjustment = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(handle) );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3151 if (adjustment)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3152 val = _round_value(gtk_adjustment_get_value(adjustment));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3153 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3154 return val;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3155 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3156
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3157 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3158 * Gets the range for the scrollbar in the scrollbox.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3159 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3160 * handle: Handle to the scrollbox to be queried.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3161 * orient: The vertical or horizontal scrollbar.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3162 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3163 int API dw_scrollbox_get_range(HWND handle, int orient)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3164 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3165 int range = -1, _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3166 GtkAdjustment *adjustment;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3167
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3168 if (!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3169 return -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3170
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3171 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3172 if ( orient == DW_HORZ )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3173 adjustment = gtk_scrolled_window_get_hadjustment( GTK_SCROLLED_WINDOW(handle) );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3174 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3175 adjustment = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(handle) );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3176 if (adjustment)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3177 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3178 range = _round_value(gtk_adjustment_get_upper(adjustment));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3179 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3180 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3181 return range;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3182 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3183
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3184 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3185 * Create a new Group Box to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3186 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3187 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3188 * pad: Number of pixels to pad around the box.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3189 * title: Text to be displayined in the group outline.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3190 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3191 HWND dw_groupbox_new(int type, int pad, char *title)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3192 {
1038
2c2fcfeeffcc Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1022
diff changeset
3193 GtkWidget *tmp, *frame;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3194 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3195
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3196 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3197 frame = gtk_frame_new(NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3198 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3199 gtk_frame_set_label(GTK_FRAME(frame), title && *title ? title : NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3200
1124
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
3201 tmp = gtk_grid_new();
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3202 gtk_container_set_border_width(GTK_CONTAINER(tmp), pad);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3203 g_object_set_data(G_OBJECT(tmp), "_dw_boxtype", GINT_TO_POINTER(type));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3204 g_object_set_data(G_OBJECT(tmp), "_dw_boxpad", GINT_TO_POINTER(pad));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3205 g_object_set_data(G_OBJECT(frame), "_dw_boxhandle", (gpointer)tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3206 gtk_container_add(GTK_CONTAINER(frame), tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3207 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3208 gtk_widget_show(frame);
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
3209 if(_DWDefaultFont)
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
3210 dw_window_set_font(frame, _DWDefaultFont);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3211 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3212 return frame;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3213 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3214
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
3215 #ifdef DW_INCLUDE_DEPRECATED
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3216 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3217 * Create a new MDI Frame to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3218 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3219 * id: An ID to be used with dw_window_from_id or 0L.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3220 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3221 HWND dw_mdi_new(unsigned long id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3222 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3223 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3224 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3225
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3226 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3227 tmp = gtk_mdi_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3228 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3229 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3230 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3231 }
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
3232 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3233
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3234 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3235 * Create a bitmap object to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3236 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3237 * id: An ID to be used with dw_window_from_id() or 0L.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3238 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3239 HWND dw_bitmap_new(unsigned long id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3240 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3241 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3242 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3243
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3244 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3245 tmp = gtk_image_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3246 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3247 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3248 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3249 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3250 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3251
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3252 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3253 * Create a notebook object to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3254 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3255 * id: An ID to be used for getting the resource from the
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3256 * resource file.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3257 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3258 HWND dw_notebook_new(unsigned long id, int top)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3259 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3260 GtkWidget *tmp, **pagearray = calloc(sizeof(GtkWidget *), 256);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3261 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3262
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3263 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3264 tmp = gtk_notebook_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3265 if(top)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3266 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_TOP);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3267 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3268 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_BOTTOM);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3269 gtk_notebook_set_scrollable(GTK_NOTEBOOK(tmp), TRUE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3270 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3271 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3272 g_object_set_data(G_OBJECT(tmp), "_dw_pagearray", (gpointer)pagearray);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3273 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3274 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3275 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3276
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3277 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3278 * Create a menu object to be popped up.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3279 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3280 * id: An ID to be used for getting the resource from the
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3281 * resource file.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3282 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3283 HMENUI dw_menu_new(unsigned long id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3284 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3285 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3286 GtkAccelGroup *accel_group;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3287 HMENUI tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3288
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3289 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3290 tmp = gtk_menu_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3291 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3292 accel_group = gtk_accel_group_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3293 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3294 g_object_set_data(G_OBJECT(tmp), "_dw_accel", (gpointer)accel_group);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3295 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3296 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3297 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3298
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3299 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3300 * Create a menubar on a window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3301 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3302 * location: Handle of a window frame to be attached to.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3303 * If there is no box already packed into the "location", the menu will not appear
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3304 * so tell the user.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3305 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3306 HMENUI dw_menubar_new(HWND location)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3307 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3308 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3309 GtkAccelGroup *accel_group;
1451
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3310 GtkWidget *box;
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3311 HMENUI tmp = 0;
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3312
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3313 DW_MUTEX_LOCK;
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3314 if(GTK_IS_WINDOW(location) &&
1452
dbe16031ffb4 Changes for GTK to make top-level windows act more like on other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1451
diff changeset
3315 (box = (GtkWidget *)g_object_get_data(G_OBJECT(location), "_dw_grid")))
1451
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3316 {
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3317 /* If there is an existing menu bar, remove it */
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3318 GtkWidget *oldmenu = (GtkWidget *)g_object_get_data(G_OBJECT(location), "_dw_menubar");
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3319 if(oldmenu)
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3320 gtk_widget_destroy(oldmenu);
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3321 /* Create a new menu bar */
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3322 tmp = gtk_menu_bar_new();
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3323 gtk_widget_show(tmp);
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3324 accel_group = gtk_accel_group_new();
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3325 g_object_set_data(G_OBJECT(tmp), "_dw_accel", (gpointer)accel_group);
1452
dbe16031ffb4 Changes for GTK to make top-level windows act more like on other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1451
diff changeset
3326 /* Save pointers to each other */
1451
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3327 g_object_set_data(G_OBJECT(location), "_dw_menubar", (gpointer)tmp);
1452
dbe16031ffb4 Changes for GTK to make top-level windows act more like on other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1451
diff changeset
3328 g_object_set_data(G_OBJECT(tmp), "_dw_window", (gpointer)location);
dbe16031ffb4 Changes for GTK to make top-level windows act more like on other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1451
diff changeset
3329 gtk_grid_attach(GTK_GRID(box), tmp, 0, 0, 1, 1);
1451
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3330 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3331 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3332 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3333 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3334
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3335 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3336 * Destroys a menu created with dw_menubar_new or dw_menu_new.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3337 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3338 * menu: Handle of a menu.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3339 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3340 void dw_menu_destroy(HMENUI *menu)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3341 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3342 if(menu && *menu)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3343 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3344 int _locked_by_me = FALSE;
1452
dbe16031ffb4 Changes for GTK to make top-level windows act more like on other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1451
diff changeset
3345 GtkWidget *window;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3346
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3347 DW_MUTEX_LOCK;
1452
dbe16031ffb4 Changes for GTK to make top-level windows act more like on other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1451
diff changeset
3348 /* If it is a menu bar, try to delete the reference to it */
dbe16031ffb4 Changes for GTK to make top-level windows act more like on other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1451
diff changeset
3349 if(GTK_IS_MENU_BAR(*menu) &&
dbe16031ffb4 Changes for GTK to make top-level windows act more like on other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1451
diff changeset
3350 (window = (GtkWidget *)g_object_get_data(G_OBJECT(*menu), "_dw_window")))
dbe16031ffb4 Changes for GTK to make top-level windows act more like on other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1451
diff changeset
3351 g_object_set_data(G_OBJECT(window), "_dw_menubar", NULL);
dbe16031ffb4 Changes for GTK to make top-level windows act more like on other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1451
diff changeset
3352 /* Actually destroy the menu */
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3353 gtk_widget_destroy(*menu);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3354 *menu = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3355 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3356 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3357 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3358
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3359 char _removetilde(char *dest, char *src)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3360 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3361 int z, cur=0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3362 char accel = '\0';
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3363
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3364 for(z=0;z<strlen(src);z++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3365 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3366 if(src[z] != '~')
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3367 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3368 dest[cur] = src[z];
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3369 cur++;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3370 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3371 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3372 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3373 dest[cur] = '_';
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3374 accel = src[z+1];
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3375 cur++;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3376 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3377 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3378 dest[cur] = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3379 return accel;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3380 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3381
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3382 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3383 * Adds a menuitem or submenu to an existing menu.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3384 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3385 * menu: The handle to the existing menu.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3386 * title: The title text on the menu item to be added.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3387 * id: An ID to be used for message passing.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3388 * flags: Extended attributes to set on the menu.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3389 * end: If TRUE memu is positioned at the end of the menu.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3390 * check: If TRUE menu is "check"able.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3391 * submenu: Handle to an existing menu to be a submenu or NULL.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3392 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3393 HWND dw_menu_append_item(HMENUI menu, char *title, unsigned long id, unsigned long flags, int end, int check, HMENUI submenu)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3394 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3395 GtkWidget *tmphandle;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3396 char accel, *tempbuf = malloc(strlen(title)+1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3397 int _locked_by_me = FALSE, submenucount;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3398 GtkAccelGroup *accel_group;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3399
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3400 if (!menu)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3401 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3402 free(tempbuf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3403 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3404 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3405
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3406 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3407 accel = _removetilde(tempbuf, title);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3408
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3409 accel_group = (GtkAccelGroup *)g_object_get_data(G_OBJECT(menu), "_dw_accel");
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
3410 submenucount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menu), "_dw_submenucount"));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3411
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3412 if (strlen(tempbuf) == 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3413 tmphandle=gtk_menu_item_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3414 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3415 {
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
3416 char numbuf[11] = {0};
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
3417
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3418 if (check)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3419 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3420 tmphandle = gtk_check_menu_item_new_with_label(tempbuf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3421 if (accel && accel_group)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3422 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3423 gtk_label_set_use_underline(GTK_LABEL(gtk_bin_get_child(GTK_BIN(tmphandle))), TRUE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3424 #if 0 /* TODO: This isn't working right */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3425 gtk_widget_add_accelerator(tmphandle, "activate", accel_group, tmp_key, GDK_MOD1_MASK, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3426 #endif
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3427 }
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
3428 snprintf(numbuf, 10, "%lu", id);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3429 g_object_set_data(G_OBJECT(menu), numbuf, (gpointer)tmphandle);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3430 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3431 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3432 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3433 tmphandle=gtk_menu_item_new_with_label(tempbuf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3434 if (accel && accel_group)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3435 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3436 gtk_label_set_use_underline(GTK_LABEL(gtk_bin_get_child(GTK_BIN(tmphandle))), TRUE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3437 #if 0 /* TODO: This isn't working right */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3438 gtk_widget_add_accelerator(tmphandle, "activate", accel_group, tmp_key, GDK_MOD1_MASK, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3439 #endif
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3440 }
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
3441 snprintf(numbuf, 10, "%lu", id);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3442 g_object_set_data(G_OBJECT(menu), numbuf, (gpointer)tmphandle);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3443 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3444 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3445
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3446 gtk_widget_show(tmphandle);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3447
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3448 if (submenu)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3449 {
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
3450 char tempbuf[101] = {0};
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
3451
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
3452 snprintf(tempbuf, 100, "_dw_submenu%d", submenucount);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3453 submenucount++;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3454 gtk_menu_item_set_submenu(GTK_MENU_ITEM(tmphandle), submenu);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3455 g_object_set_data(G_OBJECT(menu), tempbuf, (gpointer)submenu);
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
3456 g_object_set_data(G_OBJECT(menu), "_dw_submenucount", GINT_TO_POINTER(submenucount));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3457 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3458
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3459 if (GTK_IS_MENU_BAR(menu))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3460 gtk_menu_shell_append(GTK_MENU_SHELL(menu), tmphandle);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3461 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3462 gtk_menu_shell_append(GTK_MENU_SHELL(menu), tmphandle);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3463
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3464 g_object_set_data(G_OBJECT(tmphandle), "_dw_id", GINT_TO_POINTER(id));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3465 free(tempbuf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3466 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3467 * Set flags
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3468 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3469 if ( check && (flags & DW_MIS_CHECKED) )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3470 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3471 _dw_ignore_click = 1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3472 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(tmphandle), 1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3473 _dw_ignore_click = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3474 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3475
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3476 if ( flags & DW_MIS_DISABLED )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3477 gtk_widget_set_sensitive( tmphandle, FALSE );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3478
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3479 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3480 return tmphandle;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3481 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3482
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3483 GtkWidget *_find_submenu_id(GtkWidget *start, char *name)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3484 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3485 GtkWidget *tmp;
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
3486 int z, submenucount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(start), "_dw_submenucount"));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3487
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3488 if((tmp = g_object_get_data(G_OBJECT(start), name)))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3489 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3490
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3491 for(z=0;z<submenucount;z++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3492 {
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
3493 char tempbuf[101] = {0};
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3494 GtkWidget *submenu, *menuitem;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3495
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
3496 snprintf(tempbuf, 100, "_dw_submenu%d", z);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3497
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3498 if((submenu = g_object_get_data(G_OBJECT(start), tempbuf)))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3499 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3500 if((menuitem = _find_submenu_id(submenu, name)))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3501 return menuitem;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3502 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3503 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3504 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3505 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3506
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3507 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3508 * Sets the state of a menu item check.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3509 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3510 * menu: The handle the the existing menu.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3511 * id: Menuitem id.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3512 * check: TRUE for checked FALSE for not checked.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3513 * deprecated: use dw_menu_item_set_state()
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3514 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3515 void dw_menu_item_set_check(HMENUI menu, unsigned long id, int check)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3516 {
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
3517 char numbuf[11];
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3518 GtkWidget *tmphandle;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3519 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3520
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3521 if(!menu)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3522 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3523
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3524 DW_MUTEX_LOCK;
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
3525 snprintf(numbuf, 10, "%lu", id);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3526 tmphandle = _find_submenu_id(menu, numbuf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3527
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3528 if(tmphandle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3529 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3530 _dw_ignore_click = 1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3531 if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(tmphandle)) != check)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3532 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(tmphandle), check);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3533 _dw_ignore_click = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3534 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3535 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3536 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3537
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3538 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3539 * Sets the state of a menu item.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3540 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3541 * menu: The handle the the existing menu.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3542 * id: Menuitem id.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3543 * state: TRUE for checked FALSE for not checked.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3544 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3545 void dw_menu_item_set_state(HMENUI menu, unsigned long id, unsigned long state)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3546 {
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
3547 char numbuf[11] = {0};
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3548 GtkWidget *tmphandle;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3549 int check;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3550 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3551
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3552 if(!menu)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3553 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3554
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3555 DW_MUTEX_LOCK;
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
3556 snprintf(numbuf, 10, "%lu", id);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3557 tmphandle = _find_submenu_id(menu, numbuf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3558
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3559 if ( (state & DW_MIS_CHECKED) || (state & DW_MIS_UNCHECKED) )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3560 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3561 if ( state & DW_MIS_CHECKED )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3562 check = 1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3563 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3564 check = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3565
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3566 if (tmphandle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3567 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3568 _dw_ignore_click = 1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3569 if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(tmphandle)) != check)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3570 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(tmphandle), check);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3571 _dw_ignore_click = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3572 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3573 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3574 if ( (state & DW_MIS_ENABLED) || (state & DW_MIS_DISABLED) )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3575 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3576 if (tmphandle )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3577 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3578 _dw_ignore_click = 1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3579 if ( state & DW_MIS_ENABLED )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3580 gtk_widget_set_sensitive( tmphandle, TRUE );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3581 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3582 gtk_widget_set_sensitive( tmphandle, FALSE );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3583 _dw_ignore_click = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3584 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3585 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3586 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3587 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3588
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3589 /*
1373
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3590 * Deletes the menu item specified.
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3591 * Parameters:
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3592 * menu: The handle to the menu in which the item was appended.
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3593 * id: Menuitem id.
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3594 * Returns:
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3595 * DW_ERROR_NONE (0) on success or DW_ERROR_UNKNOWN on failure.
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3596 */
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3597 int API dw_menu_delete_item(HMENUI menu, unsigned long id)
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3598 {
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3599 char numbuf[11];
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3600 GtkWidget *tmphandle;
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3601 int _locked_by_me = FALSE;
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3602 int ret = DW_ERROR_UNKNOWN;
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3603
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3604 if(!menu)
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3605 return ret;
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3606
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3607 DW_MUTEX_LOCK;
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3608 snprintf(numbuf, 10, "%lu", id);
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3609 tmphandle = _find_submenu_id(menu, numbuf);
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3610
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3611 if(tmphandle)
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3612 {
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3613 gtk_widget_destroy(tmphandle);
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3614 g_object_set_data(G_OBJECT(menu), numbuf, NULL);
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3615 ret = DW_ERROR_NONE;
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3616 }
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3617 DW_MUTEX_UNLOCK;
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3618 return ret;
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3619 }
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3620
bad3e17ab6e5 Implemented dw_menu_delete_item() for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3621 /*
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3622 * Pops up a context menu at given x and y coordinates.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3623 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3624 * menu: The handle the the existing menu.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3625 * parent: Handle to the window initiating the popup.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3626 * x: X coordinate.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3627 * y: Y coordinate.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3628 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3629 void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3630 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3631 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3632
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3633 if(!menu || !*menu)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3634 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3635
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3636 popup = parent;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3637
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3638 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3639 gtk_menu_popup(GTK_MENU(*menu), NULL, NULL, NULL, NULL, 1, GDK_CURRENT_TIME);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3640 *menu = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3641 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3642 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3643
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3644
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3645 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3646 * Returns the current X and Y coordinates of the mouse pointer.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3647 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3648 * x: Pointer to variable to store X coordinate.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3649 * y: Pointer to variable to store Y coordinate.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3650 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3651 void dw_pointer_query_pos(long *x, long *y)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3652 {
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
3653 GdkModifierType state = 0;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3654 int gx, gy;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3655 int _locked_by_me = FALSE;
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
3656 GdkDisplay *display;
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
3657 GdkDeviceManager *manager;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3658
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3659 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3660 #ifdef GDK_WINDOWING_X11
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
3661 display = gdk_display_get_default();
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
3662 manager = gdk_display_get_device_manager(display);
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
3663 gdk_window_get_device_position (gdk_x11_window_lookup_for_display(display, GDK_ROOT_WINDOW()),
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
3664 gdk_device_manager_get_client_pointer(manager), &gx, &gy, &state);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3665 #endif
1122
e52c710e6d08 Minor change to allow dw_pointer_query_pos() to take NULL paramaters on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1121
diff changeset
3666 if(x)
e52c710e6d08 Minor change to allow dw_pointer_query_pos() to take NULL paramaters on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1121
diff changeset
3667 *x = gx;
e52c710e6d08 Minor change to allow dw_pointer_query_pos() to take NULL paramaters on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1121
diff changeset
3668 if(y)
e52c710e6d08 Minor change to allow dw_pointer_query_pos() to take NULL paramaters on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1121
diff changeset
3669 *y = gy;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3670 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3671 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3672
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3673 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3674 * Sets the X and Y coordinates of the mouse pointer.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3675 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3676 * x: X coordinate.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3677 * y: Y coordinate.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3678 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3679 void dw_pointer_set_pos(long x, long y)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3680 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3681 int _locked_by_me = FALSE;
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
3682 GdkDisplay *display;
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
3683 GdkDeviceManager *manager;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3684
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3685 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3686 #ifdef GDK_WINDOWING_X11
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
3687 display = gdk_display_get_default();
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
3688 manager = gdk_display_get_device_manager(display);
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
3689 gdk_device_warp( gdk_device_manager_get_client_pointer(manager), gdk_screen_get_default(), x, y );
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3690 #endif
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3691 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3692 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3693
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3694 #define _DW_TREE_CONTAINER 1
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3695 #define _DW_TREE_TREE 2
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3696 #define _DW_TREE_LISTBOX 3
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3697
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3698 GtkWidget *_tree_create(unsigned long id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3699 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3700 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3701
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3702 tmp = gtk_scrolled_window_new(NULL, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3703 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp),
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3704 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3705
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3706 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3707 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3708 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3709 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3710
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3711 GtkWidget *_tree_setup(GtkWidget *tmp, GtkTreeModel *store)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3712 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3713 GtkWidget *tree = gtk_tree_view_new_with_model(store);
900
2ba1f71e23fa Disable searching in GTK tree view based controls. It is very disconcerting.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 892
diff changeset
3714 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(tree), FALSE);
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
3715 #if GTK_CHECK_VERSION(3,8,0)
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
3716 gtk_container_add(GTK_CONTAINER(tmp), tree);
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
3717 #else
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3718 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp), tree);
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
3719 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3720 g_object_set_data(G_OBJECT(tmp), "_dw_user", (gpointer)tree);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3721 return tree;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3722 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3723
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3724 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3725 * Create a container object to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3726 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3727 * id: An ID to be used for getting the resource from the
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3728 * resource file.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3729 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3730 HWND dw_container_new(unsigned long id, int multi)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3731 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3732 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3733 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3734
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3735 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3736 if(!(tmp = _tree_create(id)))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3737 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3738 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3739 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3740 }
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
3741 g_object_set_data(G_OBJECT(tmp), "_dw_tree_type", GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3742 g_object_set_data(G_OBJECT(tmp), "_dw_multi_sel", GINT_TO_POINTER(multi));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3743 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3744 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3745 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3746
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3747 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3748 * Create a tree object to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3749 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3750 * id: An ID to be used for getting the resource from the
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3751 * resource file.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3752 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3753 HWND dw_tree_new(ULONG id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3754 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3755 GtkWidget *tmp, *tree;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3756 GtkTreeStore *store;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3757 GtkTreeViewColumn *col;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3758 GtkCellRenderer *rend;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3759 GtkTreeSelection *sel;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3760 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3761
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3762 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3763 if(!(tmp = _tree_create(id)))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3764 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3765 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3766 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3767 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3768 store = gtk_tree_store_new(4, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER, G_TYPE_POINTER);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3769 tree = _tree_setup(tmp, GTK_TREE_MODEL(store));
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
3770 g_object_set_data(G_OBJECT(tmp), "_dw_tree_type", GINT_TO_POINTER(_DW_TREE_TYPE_TREE));
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
3771 g_object_set_data(G_OBJECT(tree), "_dw_tree_type", GINT_TO_POINTER(_DW_TREE_TYPE_TREE));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3772 col = gtk_tree_view_column_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3773
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3774 rend = gtk_cell_renderer_pixbuf_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3775 gtk_tree_view_column_pack_start(col, rend, FALSE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3776 gtk_tree_view_column_add_attribute(col, rend, "pixbuf", 1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3777 rend = gtk_cell_renderer_text_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3778 gtk_tree_view_column_pack_start(col, rend, TRUE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3779 gtk_tree_view_column_add_attribute(col, rend, "text", 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3780
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3781 gtk_tree_view_append_column(GTK_TREE_VIEW (tree), col);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3782 gtk_tree_view_set_expander_column(GTK_TREE_VIEW(tree), col);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3783 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3784
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3785 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3786 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3787 gtk_widget_show(tree);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3788
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
3789 if(_DWDefaultFont)
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
3790 dw_window_set_font(tmp, _DWDefaultFont);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3791 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3792 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3793 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3794
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3795
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3796 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3797 * Create a new static text window (widget) to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3798 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3799 * text: The text to be display by the static text widget.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3800 * id: An ID to be used with dw_window_from_id() or 0L.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3801 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3802 HWND dw_text_new(char *text, unsigned long id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3803 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3804 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3805 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3806
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3807 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3808 tmp = gtk_label_new(text);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3809
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3810 /* Left and centered */
1917
933b5f7005a9 Fix building on GTK3 versions older than 3.16.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1916
diff changeset
3811 #if GTK_CHECK_VERSION(3,16,0)
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
3812 gtk_label_set_xalign(GTK_LABEL(tmp), 0.0f);
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
3813 gtk_label_set_yalign(GTK_LABEL(tmp), 0.5f);
1917
933b5f7005a9 Fix building on GTK3 versions older than 3.16.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1916
diff changeset
3814 #else
933b5f7005a9 Fix building on GTK3 versions older than 3.16.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1916
diff changeset
3815 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f);
933b5f7005a9 Fix building on GTK3 versions older than 3.16.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1916
diff changeset
3816 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3817 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3818 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
3819 if(_DWDefaultFont)
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
3820 dw_window_set_font(tmp, _DWDefaultFont);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3821 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3822 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3823 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3824
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3825 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3826 * Create a new status text window (widget) to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3827 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3828 * text: The text to be display by the static text widget.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3829 * id: An ID to be used with dw_window_from_id() or 0L.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3830 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3831 HWND dw_status_text_new(char *text, ULONG id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3832 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3833 GtkWidget *tmp, *frame;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3834 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3835
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3836 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3837 frame = gtk_frame_new(NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3838 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3839 tmp = gtk_label_new(text);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3840 gtk_container_add(GTK_CONTAINER(frame), tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3841 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3842 gtk_widget_show(frame);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3843
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3844 /* Left and centered */
1917
933b5f7005a9 Fix building on GTK3 versions older than 3.16.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1916
diff changeset
3845 #if GTK_CHECK_VERSION(3,16,0)
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
3846 gtk_label_set_xalign(GTK_LABEL(tmp), 0.0f);
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
3847 gtk_label_set_yalign(GTK_LABEL(tmp), 0.5f);
1917
933b5f7005a9 Fix building on GTK3 versions older than 3.16.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1916
diff changeset
3848 #else
933b5f7005a9 Fix building on GTK3 versions older than 3.16.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1916
diff changeset
3849 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f);
933b5f7005a9 Fix building on GTK3 versions older than 3.16.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1916
diff changeset
3850 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3851 g_object_set_data(G_OBJECT(frame), "_dw_id", GINT_TO_POINTER(id));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3852 g_object_set_data(G_OBJECT(frame), "_dw_label", (gpointer)tmp);
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
3853 if(_DWDefaultFont)
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
3854 dw_window_set_font(tmp, _DWDefaultFont);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3855 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3856 return frame;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3857 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3858
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3859 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3860 * Create a new Multiline Editbox window (widget) to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3861 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3862 * id: An ID to be used with dw_window_from_id() or 0L.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3863 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3864 HWND dw_mle_new(unsigned long id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3865 {
1124
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
3866 GtkWidget *tmp, *tmpbox;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3867 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3868
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3869 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3870 tmpbox = gtk_scrolled_window_new (NULL, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3871 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(tmpbox),
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3872 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3873 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(tmpbox), GTK_SHADOW_ETCHED_IN);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3874 tmp = gtk_text_view_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3875 gtk_container_add (GTK_CONTAINER(tmpbox), tmp);
1545
6edf3fce77f2 Initial support for container and MLE auto-sizing on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1539
diff changeset
3876 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), GTK_WRAP_WORD);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3877
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3878 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3879 g_object_set_data(G_OBJECT(tmpbox), "_dw_user", (gpointer)tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3880 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3881 gtk_widget_show(tmpbox);
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
3882 if(_DWDefaultFont)
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
3883 dw_window_set_font(tmpbox, _DWDefaultFont);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3884 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3885 return tmpbox;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3886 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3887
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3888 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3889 * Create a new Entryfield window (widget) to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3890 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3891 * text: The default text to be in the entryfield widget.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3892 * id: An ID to be used with dw_window_from_id() or 0L.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3893 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3894 HWND dw_entryfield_new(char *text, unsigned long id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3895 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3896 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3897 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3898
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3899 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3900 tmp = gtk_entry_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3901
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3902 gtk_entry_set_text(GTK_ENTRY(tmp), text);
1352
08de3c1f4ae4 Fix entryfields, comboboxes etc being too wide in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1330
diff changeset
3903 gtk_entry_set_width_chars(GTK_ENTRY(tmp), 0);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3904
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3905 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3906 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3907
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
3908 if(_DWDefaultFont)
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
3909 dw_window_set_font(tmp, _DWDefaultFont);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3910 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3911 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3912 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3913
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3914 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3915 * Create a new Entryfield (password) window (widget) to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3916 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3917 * text: The default text to be in the entryfield widget.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3918 * id: An ID to be used with dw_window_from_id() or 0L.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3919 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3920 HWND dw_entryfield_password_new(char *text, ULONG id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3921 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3922 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3923 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3924
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3925 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3926 tmp = gtk_entry_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3927
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3928 gtk_entry_set_visibility(GTK_ENTRY(tmp), FALSE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3929 gtk_entry_set_text(GTK_ENTRY(tmp), text);
1352
08de3c1f4ae4 Fix entryfields, comboboxes etc being too wide in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1330
diff changeset
3930 gtk_entry_set_width_chars(GTK_ENTRY(tmp), 0);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3931
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3932 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3933 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3934
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
3935 if(_DWDefaultFont)
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
3936 dw_window_set_font(tmp, _DWDefaultFont);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3937 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3938 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3939 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3940
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3941 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3942 * Create a new Combobox window (widget) to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3943 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3944 * text: The default text to be in the combpbox widget.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3945 * id: An ID to be used with dw_window_from_id() or 0L.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3946 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3947 HWND dw_combobox_new(char *text, unsigned long id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3948 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3949 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3950 GtkListStore *store;
780
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
3951 int _locked_by_me = FALSE;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3952
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3953 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3954 store = gtk_list_store_new(1, G_TYPE_STRING);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3955 tmp = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(store));
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
3956 gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(tmp), 0);
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
3957 gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(tmp))), text);
1352
08de3c1f4ae4 Fix entryfields, comboboxes etc being too wide in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1330
diff changeset
3958 gtk_entry_set_width_chars(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(tmp))), 0);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3959 gtk_widget_show(tmp);
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
3960 g_object_set_data(G_OBJECT(tmp), "_dw_tree_type", GINT_TO_POINTER(_DW_TREE_TYPE_COMBOBOX));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3961 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
3962 if(_DWDefaultFont)
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
3963 dw_window_set_font(tmp, _DWDefaultFont);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3964 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3965 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3966 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3967
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3968 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3969 * Create a new button window (widget) to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3970 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3971 * text: The text to be display by the static text widget.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3972 * id: An ID to be used with dw_window_from_id() or 0L.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3973 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3974 HWND dw_button_new(char *text, unsigned long id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3975 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3976 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3977 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3978
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3979 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3980 tmp = gtk_button_new_with_label(text);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3981 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3982 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
3983 if(_DWDefaultFont)
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
3984 dw_window_set_font(tmp, _DWDefaultFont);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3985 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3986 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3987 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3988
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3989 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3990 * Create a new bitmap button window (widget) to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3991 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3992 * text: Bubble help text to be displayed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3993 * id: An ID of a bitmap in the resource file.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3994 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3995 HWND dw_bitmapbutton_new(char *text, unsigned long id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3996 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3997 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3998 GtkWidget *bitmap;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3999 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4000
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4001 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4002 tmp = gtk_button_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4003 bitmap = dw_bitmap_new(id);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4004
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4005 if(bitmap)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4006 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4007 dw_window_set_bitmap(bitmap, id, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4008 gtk_container_add (GTK_CONTAINER(tmp), bitmap);
1069
a1deca9b0876 Attempt at scaling bitmaps if they are too big for where they are packed on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1066
diff changeset
4009 g_object_set_data(G_OBJECT(tmp), "_dw_bitmap", bitmap);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4010 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4011 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4012 if(text)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4013 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4014 gtk_widget_set_tooltip_text(tmp, text);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4015 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4016 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4017 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4018 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4019 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4020
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4021 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4022 * Create a new bitmap button window (widget) to be packed from a file.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4023 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4024 * label_text: Text to display on button. TBD when Windows works
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4025 * text: Bubble help text to be displayed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4026 * id: An ID to be used with dw_window_from_id() or 0L.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4027 * filename: Name of the file, omit extention to have
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4028 * DW pick the appropriate file extension.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4029 * (BMP on OS/2 or Windows, XPM on Unix)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4030 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4031 HWND dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4032 {
1830
6b90c7e9e520 Attempt at fixing GTK 2.x issue with dw_window_set_bitmap() when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1823
diff changeset
4033 GtkWidget *tmp;
1831
ce7543633fef Slight typo in that last commit fixed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1830
diff changeset
4034 GtkWidget *bitmap;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4035 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4036
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4037 DW_MUTEX_LOCK;
1069
a1deca9b0876 Attempt at scaling bitmaps if they are too big for where they are packed on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1066
diff changeset
4038 /* Create a new button */
1830
6b90c7e9e520 Attempt at fixing GTK 2.x issue with dw_window_set_bitmap() when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1823
diff changeset
4039 tmp = gtk_button_new();
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4040 /* Now on to the image stuff */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4041 bitmap = dw_bitmap_new(id);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4042 if(bitmap)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4043 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4044 dw_window_set_bitmap( bitmap, 0, filename );
1830
6b90c7e9e520 Attempt at fixing GTK 2.x issue with dw_window_set_bitmap() when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1823
diff changeset
4045 gtk_container_add (GTK_CONTAINER(tmp), bitmap);
6b90c7e9e520 Attempt at fixing GTK 2.x issue with dw_window_set_bitmap() when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1823
diff changeset
4046 g_object_set_data(G_OBJECT(tmp), "_dw_bitmap", bitmap);
6b90c7e9e520 Attempt at fixing GTK 2.x issue with dw_window_set_bitmap() when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1823
diff changeset
4047 }
1832
cd4ff1eb34a3 Accidentally removed a very important line from GTK 3.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1831
diff changeset
4048 gtk_widget_show(tmp);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4049 if(text)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4050 {
1830
6b90c7e9e520 Attempt at fixing GTK 2.x issue with dw_window_set_bitmap() when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1823
diff changeset
4051 gtk_widget_set_tooltip_text(tmp, text);
6b90c7e9e520 Attempt at fixing GTK 2.x issue with dw_window_set_bitmap() when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1823
diff changeset
4052 }
6b90c7e9e520 Attempt at fixing GTK 2.x issue with dw_window_set_bitmap() when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1823
diff changeset
4053 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
6b90c7e9e520 Attempt at fixing GTK 2.x issue with dw_window_set_bitmap() when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1823
diff changeset
4054 DW_MUTEX_UNLOCK;
6b90c7e9e520 Attempt at fixing GTK 2.x issue with dw_window_set_bitmap() when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1823
diff changeset
4055 return tmp;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4056 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4057
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4058 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4059 * Create a new bitmap button window (widget) to be packed from data.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4060 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4061 * text: Bubble help text to be displayed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4062 * id: An ID to be used with dw_window_from_id() or 0L.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4063 * data: Raw data of image.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4064 * (BMP on OS/2 or Windows, XPM on Unix)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4065 * len: Length of raw data
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4066 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4067 HWND dw_bitmapbutton_new_from_data(char *text, unsigned long id, char *data, int len)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4068 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4069 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4070 GtkWidget *bitmap;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4071 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4072
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4073 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4074 tmp = gtk_button_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4075 bitmap = dw_bitmap_new(id);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4076
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4077 if ( bitmap )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4078 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4079 dw_window_set_bitmap_from_data(bitmap, 0, data, len);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4080 gtk_container_add (GTK_CONTAINER(tmp), bitmap);
1069
a1deca9b0876 Attempt at scaling bitmaps if they are too big for where they are packed on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1066
diff changeset
4081 g_object_set_data(G_OBJECT(tmp), "_dw_bitmap", bitmap);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4082 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4083 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4084 if(text)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4085 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4086 gtk_widget_set_tooltip_text(tmp, text);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4087 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4088 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4089 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4090 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4091 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4092
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4093 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4094 * Create a new spinbutton window (widget) to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4095 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4096 * text: The text to be display by the static text widget.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4097 * id: An ID to be used with dw_window_from_id() or 0L.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4098 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4099 HWND dw_spinbutton_new(char *text, unsigned long id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4100 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4101 GtkAdjustment *adj;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4102 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4103 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4104
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4105 DW_MUTEX_LOCK;
1022
fa1a826348b3 Change the default range of spinbuttons to be -65536 to 65536 on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1021
diff changeset
4106 adj = (GtkAdjustment *)gtk_adjustment_new ((float)atoi(text), -65536.0, 65536.0, 1.0, 5.0, 0.0);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4107 tmp = gtk_spin_button_new (adj, 0, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4108 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(tmp), TRUE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4109 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(tmp), TRUE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4110 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4111 g_object_set_data(G_OBJECT(tmp), "_dw_adjustment", (gpointer)adj);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4112 g_object_set_data(G_OBJECT(adj), "_dw_spinbutton", (gpointer)tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4113 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
4114 if(_DWDefaultFont)
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
4115 dw_window_set_font(tmp, _DWDefaultFont);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4116 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4117 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4118 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4119
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4120 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4121 * Create a new radiobutton window (widget) to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4122 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4123 * text: The text to be display by the static text widget.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4124 * id: An ID to be used with dw_window_from_id() or 0L.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4125 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4126 HWND dw_radiobutton_new(char *text, ULONG id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4127 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4128 /* This will have to be fixed in the future. */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4129 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4130 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4131
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4132 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4133 tmp = gtk_radio_button_new_with_label(NULL, text);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4134 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4135 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4136
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
4137 if(_DWDefaultFont)
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
4138 dw_window_set_font(tmp, _DWDefaultFont);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4139 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4140 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4141 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4142
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4143 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4144 * Create a new slider window (widget) to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4145 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4146 * vertical: TRUE or FALSE if slider is vertical.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4147 * increments: Number of increments available.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4148 * id: An ID to be used with dw_window_from_id() or 0L.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4149 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4150 HWND dw_slider_new(int vertical, int increments, ULONG id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4151 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4152 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4153 GtkAdjustment *adjustment;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4154 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4155
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4156 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4157 adjustment = (GtkAdjustment *)gtk_adjustment_new(0, 0, (gfloat)increments, 1, 1, 1);
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4158 tmp = gtk_scale_new(vertical ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL, adjustment);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4159 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4160 gtk_scale_set_draw_value(GTK_SCALE(tmp), 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4161 gtk_scale_set_digits(GTK_SCALE(tmp), 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4162 g_object_set_data(G_OBJECT(tmp), "_dw_adjustment", (gpointer)adjustment);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4163 g_object_set_data(G_OBJECT(adjustment), "_dw_slider", (gpointer)tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4164 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4165 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4166 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4167 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4168
1793
2cfbfccbbafe Added code to disable Ubuntu overlay scrollbars
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1785
diff changeset
4169 #ifdef HAVE_OVERLAY_SCROLLBARS
2cfbfccbbafe Added code to disable Ubuntu overlay scrollbars
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1785
diff changeset
4170 gboolean ubuntu_overlay_scrollbar_get_enabled(void);
2cfbfccbbafe Added code to disable Ubuntu overlay scrollbars
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1785
diff changeset
4171 void ubuntu_overlay_scrollbar_set_enabled(gboolean enabled);
2cfbfccbbafe Added code to disable Ubuntu overlay scrollbars
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1785
diff changeset
4172 #endif
2cfbfccbbafe Added code to disable Ubuntu overlay scrollbars
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1785
diff changeset
4173
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4174 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4175 * Create a new scrollbar window (widget) to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4176 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4177 * vertical: TRUE or FALSE if scrollbar is vertical.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4178 * increments: Number of increments available.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4179 * id: An ID to be used with dw_window_from_id() or 0L.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4180 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4181 HWND dw_scrollbar_new(int vertical, ULONG id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4182 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4183 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4184 GtkAdjustment *adjustment;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4185 int _locked_by_me = FALSE;
1793
2cfbfccbbafe Added code to disable Ubuntu overlay scrollbars
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1785
diff changeset
4186 #ifdef HAVE_OVERLAY_SCROLLBARS
2cfbfccbbafe Added code to disable Ubuntu overlay scrollbars
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1785
diff changeset
4187 gboolean overlaysb;
2cfbfccbbafe Added code to disable Ubuntu overlay scrollbars
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1785
diff changeset
4188 #endif
2cfbfccbbafe Added code to disable Ubuntu overlay scrollbars
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1785
diff changeset
4189
2cfbfccbbafe Added code to disable Ubuntu overlay scrollbars
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1785
diff changeset
4190 DW_MUTEX_LOCK;
2cfbfccbbafe Added code to disable Ubuntu overlay scrollbars
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1785
diff changeset
4191 #ifdef HAVE_OVERLAY_SCROLLBARS
2cfbfccbbafe Added code to disable Ubuntu overlay scrollbars
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1785
diff changeset
4192 overlaysb = ubuntu_overlay_scrollbar_get_enabled();
2cfbfccbbafe Added code to disable Ubuntu overlay scrollbars
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1785
diff changeset
4193 ubuntu_overlay_scrollbar_set_enabled(FALSE);
2cfbfccbbafe Added code to disable Ubuntu overlay scrollbars
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1785
diff changeset
4194 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4195 adjustment = (GtkAdjustment *)gtk_adjustment_new(0, 0, 0, 1, 1, 1);
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4196 tmp = gtk_scrollbar_new(vertical ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL, adjustment);
1793
2cfbfccbbafe Added code to disable Ubuntu overlay scrollbars
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1785
diff changeset
4197 #ifdef HAVE_OVERLAY_SCROLLBARS
2cfbfccbbafe Added code to disable Ubuntu overlay scrollbars
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1785
diff changeset
4198 ubuntu_overlay_scrollbar_set_enabled(overlaysb);
2cfbfccbbafe Added code to disable Ubuntu overlay scrollbars
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1785
diff changeset
4199 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4200 gtk_widget_set_can_focus(tmp, FALSE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4201 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4202 g_object_set_data(G_OBJECT(tmp), "_dw_adjustment", (gpointer)adjustment);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4203 g_object_set_data(G_OBJECT(adjustment), "_dw_scrollbar", (gpointer)tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4204 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4205 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4206 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4207 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4208
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4209 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4210 * Create a new percent bar window (widget) to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4211 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4212 * id: An ID to be used with dw_window_from_id() or 0L.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4213 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4214 HWND dw_percent_new(unsigned long id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4215 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4216 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4217 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4218
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4219 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4220 tmp = gtk_progress_bar_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4221 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4222 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4223 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4224 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4225 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4226
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4227 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4228 * Create a new checkbox window (widget) to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4229 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4230 * text: The text to be display by the static text widget.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4231 * id: An ID to be used with dw_window_from_id() or 0L.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4232 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4233 HWND dw_checkbox_new(char *text, unsigned long id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4234 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4235 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4236 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4237
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4238 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4239 tmp = gtk_check_button_new_with_label(text);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4240 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4241 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
4242 if(_DWDefaultFont)
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
4243 dw_window_set_font(tmp, _DWDefaultFont);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4244 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4245 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4246 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4247
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4248 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4249 * Create a new listbox window (widget) to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4250 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4251 * id: An ID to be used with dw_window_from_id() or 0L.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4252 * multi: Multiple select TRUE or FALSE.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4253 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4254 HWND dw_listbox_new(unsigned long id, int multi)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4255 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4256 GtkWidget *tmp, *tree;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4257 GtkListStore *store;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4258 GtkTreeViewColumn *col;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4259 GtkCellRenderer *rend;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4260 GtkTreeSelection *sel;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4261 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4262
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4263 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4264 if(!(tmp = _tree_create(id)))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4265 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4266 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4267 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4268 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4269 store = gtk_list_store_new(1, G_TYPE_STRING);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4270 tree = _tree_setup(tmp, GTK_TREE_MODEL(store));
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
4271 g_object_set_data(G_OBJECT(tmp), "_dw_tree_type", GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX));
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
4272 g_object_set_data(G_OBJECT(tree), "_dw_tree_type", GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX));
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
4273
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4274 col = gtk_tree_view_column_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4275 rend = gtk_cell_renderer_text_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4276 gtk_tree_view_column_pack_start(col, rend, TRUE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4277 gtk_tree_view_column_add_attribute(col, rend, "text", 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4278
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4279 gtk_tree_view_append_column(GTK_TREE_VIEW (tree), col);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4280 gtk_tree_view_set_expander_column(GTK_TREE_VIEW(tree), col);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4281 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
4282
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4283 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4284 if(multi)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4285 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4286 gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4287 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4288 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4289 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4290 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4291 }
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
4292 gtk_widget_show(tree);
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
4293 if(_DWDefaultFont)
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
4294 dw_window_set_font(tmp, _DWDefaultFont);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4295 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4296 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4297 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4298
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4299 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4300 * Sets the icon used for a given window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4301 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4302 * handle: Handle to the window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4303 * id: An ID to be used to specify the icon.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4304 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4305 void dw_window_set_icon(HWND handle, HICN icon)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4306 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4307 GdkPixbuf *icon_pixbuf;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4308 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4309
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4310 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4311 icon_pixbuf = _find_pixbuf(icon, NULL, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4312
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4313 if(gtk_widget_get_window(handle) && icon_pixbuf)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4314 {
787
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
4315 GList *list = g_list_append(NULL, icon_pixbuf);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4316 gdk_window_set_icon_list(gtk_widget_get_window(handle), list);
787
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
4317 g_list_free(list);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4318 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4319 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4320 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4321
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4322 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4323 * Sets the bitmap used for a given static window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4324 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4325 * handle: Handle to the window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4326 * id: An ID to be used to specify the icon,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4327 * (pass 0 if you use the filename param)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4328 * filename: a path to a file (Bitmap on OS/2 or
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4329 * Windows and a pixmap on Unix, pass
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4330 * NULL if you use the id param)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4331 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4332 void dw_window_set_bitmap(HWND handle, unsigned long id, char *filename)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4333 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4334 GdkPixbuf *tmp = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4335 int found_ext = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4336 int i;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4337 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4338
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4339 if(!id && !filename)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4340 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4341
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4342 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4343 if(id)
976
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
4344 tmp = _find_pixbuf((HICN)id, NULL, NULL);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4345 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4346 {
1258
3df86772b625 Updated the list of supported image formats for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1245
diff changeset
4347 char *file = alloca(strlen(filename) + 6);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4348
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4349 if (!file)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4350 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4351 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4352 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4353 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4354
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4355 strcpy(file, filename);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4356
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4357 /* check if we can read from this file (it exists and read permission) */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4358 if ( access(file, 04 ) != 0 )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4359 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4360 /* Try with various extentions */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4361 for ( i = 0; i < NUM_EXTS; i++ )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4362 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4363 strcpy( file, filename );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4364 strcat( file, image_exts[i] );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4365 if ( access( file, 04 ) == 0 )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4366 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4367 found_ext = 1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4368 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4369 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4370 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4371 if ( found_ext == 0 )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4372 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4373 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4374 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4375 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4376 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4377 tmp = gdk_pixbuf_new_from_file(file, NULL );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4378 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4379
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4380 if (tmp)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4381 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4382 if ( GTK_IS_BUTTON(handle) )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4383 {
1823
9c77567c5b2d Fixed broken support in dw_window_set_bitmap() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
4384 GtkWidget *pixmap = (GtkWidget *)g_object_get_data( G_OBJECT(handle), "_dw_bitmap" );
9c77567c5b2d Fixed broken support in dw_window_set_bitmap() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
4385 if(pixmap)
9c77567c5b2d Fixed broken support in dw_window_set_bitmap() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
4386 {
9c77567c5b2d Fixed broken support in dw_window_set_bitmap() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
4387 gtk_image_set_from_pixbuf(GTK_IMAGE(pixmap), tmp);
9c77567c5b2d Fixed broken support in dw_window_set_bitmap() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
4388 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4389 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4390 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4391 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4392 gtk_image_set_from_pixbuf(GTK_IMAGE(handle), tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4393 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4394 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4395 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4396 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4397
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4398 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4399 * Sets the bitmap used for a given static window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4400 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4401 * handle: Handle to the window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4402 * id: An ID to be used to specify the icon,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4403 * (pass 0 if you use the filename param)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4404 * data: the image data
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4405 * Bitmap on Windows and a pixmap on Unix, pass
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4406 * NULL if you use the id param)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4407 * len: length of data
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4408 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4409 void dw_window_set_bitmap_from_data(HWND handle, unsigned long id, char *data, int len)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4410 {
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
4411 GdkPixbuf *tmp = NULL;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4412 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4413 char *file;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4414 FILE *fp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4415
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4416 if (!id && !data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4417 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4418
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4419 DW_MUTEX_LOCK;
1718
fae374a0055b Same fix for GTK2/3 as committed for OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1709
diff changeset
4420 if(data)
fae374a0055b Same fix for GTK2/3 as committed for OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1709
diff changeset
4421 {
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4422 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4423 * A real hack; create a temporary file and write the contents
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4424 * of the data to the file
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4425 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4426 file = tmpnam( NULL );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4427 fp = fopen( file, "wb" );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4428 if ( fp )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4429 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4430 fwrite( data, len, 1, fp );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4431 fclose( fp );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4432 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4433 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4434 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4435 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4436 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4437 }
1097
8e9db23a8c31 Fixed icons from data by merging tmp and pixbuf together in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1096
diff changeset
4438 tmp = gdk_pixbuf_new_from_file(file, NULL );
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4439 /* remove our temporary file */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4440 unlink (file );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4441 }
1718
fae374a0055b Same fix for GTK2/3 as committed for OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1709
diff changeset
4442 else if (id)
fae374a0055b Same fix for GTK2/3 as committed for OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1709
diff changeset
4443 tmp = _find_pixbuf((HICN)id, NULL, NULL);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4444
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4445 if(tmp)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4446 {
1823
9c77567c5b2d Fixed broken support in dw_window_set_bitmap() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
4447 if ( GTK_IS_BUTTON(handle) )
9c77567c5b2d Fixed broken support in dw_window_set_bitmap() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
4448 {
9c77567c5b2d Fixed broken support in dw_window_set_bitmap() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
4449 GtkWidget *pixmap = (GtkWidget *)g_object_get_data( G_OBJECT(handle), "_dw_bitmap" );
9c77567c5b2d Fixed broken support in dw_window_set_bitmap() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
4450 if(pixmap)
9c77567c5b2d Fixed broken support in dw_window_set_bitmap() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
4451 {
9c77567c5b2d Fixed broken support in dw_window_set_bitmap() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
4452 gtk_image_set_from_pixbuf(GTK_IMAGE(pixmap), tmp);
9c77567c5b2d Fixed broken support in dw_window_set_bitmap() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
4453 }
9c77567c5b2d Fixed broken support in dw_window_set_bitmap() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
4454 }
9c77567c5b2d Fixed broken support in dw_window_set_bitmap() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
4455 else
9c77567c5b2d Fixed broken support in dw_window_set_bitmap() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
4456 {
9c77567c5b2d Fixed broken support in dw_window_set_bitmap() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
4457 gtk_image_set_from_pixbuf(GTK_IMAGE(handle), tmp);
9c77567c5b2d Fixed broken support in dw_window_set_bitmap() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
4458 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4459 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4460 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4461 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4462
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4463 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4464 * Sets the text used for a given window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4465 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4466 * handle: Handle to the window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4467 * text: The text associated with a given window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4468 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4469 void dw_window_set_text(HWND handle, char *text)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4470 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4471 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4472 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4473
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4474 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4475 if((tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_mdi_title")))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4476 handle = tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4477 if(GTK_IS_ENTRY(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4478 gtk_entry_set_text(GTK_ENTRY(handle), text);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4479 else if(GTK_IS_COMBO_BOX(handle))
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
4480 gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(handle))), text);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4481 else if(GTK_IS_LABEL(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4482 gtk_label_set_text(GTK_LABEL(handle), text);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4483 else if(GTK_IS_BUTTON(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4484 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4485 gtk_button_set_label(GTK_BUTTON(handle), text);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4486 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4487 else if(gtk_widget_is_toplevel(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4488 gtk_window_set_title(GTK_WINDOW(handle), text);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4489 else if (GTK_IS_FRAME(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4490 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4491 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4492 * This is a groupbox or status_text
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4493 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4494 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_label");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4495 if ( tmp && GTK_IS_LABEL(tmp) )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4496 gtk_label_set_text(GTK_LABEL(tmp), text);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4497 else /* assume groupbox */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4498 gtk_frame_set_label(GTK_FRAME(handle), text && *text ? text : NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4499 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4500 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4501 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4502
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4503 /*
1389
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1388
diff changeset
4504 * Sets the text used for a given window's floating bubble help.
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1388
diff changeset
4505 * Parameters:
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1388
diff changeset
4506 * handle: Handle to the window (widget).
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1388
diff changeset
4507 * bubbletext: The text in the floating bubble tooltip.
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1388
diff changeset
4508 */
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1388
diff changeset
4509 void API dw_window_set_tooltip(HWND handle, char *bubbletext)
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1388
diff changeset
4510 {
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1388
diff changeset
4511 int _locked_by_me = FALSE;
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1388
diff changeset
4512
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1388
diff changeset
4513 DW_MUTEX_LOCK;
1400
ccd383e11ff8 Allow removing of tooltips by passing NULL or "" and prevent double tooltips on some platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1390
diff changeset
4514 if(bubbletext && *bubbletext)
ccd383e11ff8 Allow removing of tooltips by passing NULL or "" and prevent double tooltips on some platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1390
diff changeset
4515 gtk_widget_set_tooltip_text(handle, bubbletext);
ccd383e11ff8 Allow removing of tooltips by passing NULL or "" and prevent double tooltips on some platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1390
diff changeset
4516 else
ccd383e11ff8 Allow removing of tooltips by passing NULL or "" and prevent double tooltips on some platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1390
diff changeset
4517 gtk_widget_set_has_tooltip(handle, FALSE);
1389
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1388
diff changeset
4518 DW_MUTEX_UNLOCK;
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1388
diff changeset
4519 }
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1388
diff changeset
4520
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1388
diff changeset
4521 /*
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4522 * Gets the text used for a given window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4523 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4524 * handle: Handle to the window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4525 * Returns:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4526 * text: The text associsated with a given window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4527 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4528 char *dw_window_get_text(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4529 {
1742
cebf830e3da7 Minor GTK3 code cleanups from attempt at fixing combobox event order.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1718
diff changeset
4530 const char *possible = NULL;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4531 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4532
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4533 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4534 if(GTK_IS_ENTRY(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4535 possible = gtk_entry_get_text(GTK_ENTRY(handle));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4536 else if(GTK_IS_COMBO_BOX(handle))
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
4537 possible = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(handle))));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4538
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4539 DW_MUTEX_UNLOCK;
1742
cebf830e3da7 Minor GTK3 code cleanups from attempt at fixing combobox event order.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1718
diff changeset
4540 return strdup(possible ? possible : "");
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4541 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4542
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4543 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4544 * Disables given window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4545 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4546 * handle: Handle to the window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4547 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4548 void dw_window_disable(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4549 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4550 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4551
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4552 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4553 gtk_widget_set_sensitive(handle, FALSE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4554 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4555 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4556
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4557 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4558 * Enables given window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4559 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4560 * handle: Handle to the window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4561 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4562 void dw_window_enable(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4563 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4564 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4565
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4566 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4567 gtk_widget_set_sensitive(handle, TRUE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4568 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4569 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4570
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4571 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4572 * Gets the child window handle with specified ID.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4573 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4574 * handle: Handle to the parent window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4575 * id: Integer ID of the child.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4576 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4577 HWND API dw_window_from_id(HWND handle, int id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4578 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4579 GList *orig = NULL, *list = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4580 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4581
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4582 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4583 if(handle && GTK_IS_CONTAINER(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4584 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4585 orig = list = gtk_container_get_children(GTK_CONTAINER(handle));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4586 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4587 while(list)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4588 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4589 if(GTK_IS_WIDGET(list->data))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4590 {
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
4591 if(id == GPOINTER_TO_INT(g_object_get_data(G_OBJECT(list->data), "_dw_id")))
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4592 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4593 HWND ret = (HWND)list->data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4594 g_list_free(orig);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4595 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4596 return ret;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4597 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4598 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4599 list = list->next;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4600 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4601 if(orig)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4602 g_list_free(orig);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4603 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4604 return 0L;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4605 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4606
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4607 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4608 * Adds text to an MLE box and returns the current point.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4609 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4610 * handle: Handle to the MLE to be queried.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4611 * buffer: Text buffer to be imported.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4612 * startpoint: Point to start entering text.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4613 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4614 unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4615 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4616 unsigned int tmppoint = startpoint;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4617 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4618
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4619 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4620 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4621 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4622 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4623
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4624 if(tmp && GTK_IS_TEXT_VIEW(tmp))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4625 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4626 GtkTextBuffer *tbuffer;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4627 GtkTextIter iter;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4628
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4629 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4630 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, startpoint);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4631 gtk_text_buffer_place_cursor(tbuffer, &iter);
994
f1c7b03f944d Removed carriage return stripping from GTK3, it is not needed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 986
diff changeset
4632 gtk_text_buffer_insert_at_cursor(tbuffer, buffer, -1);
f1c7b03f944d Removed carriage return stripping from GTK3, it is not needed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 986
diff changeset
4633 tmppoint = (startpoint > -1 ? startpoint : 0) + strlen(buffer);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4634 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4635 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4636 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4637 return tmppoint;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4638 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4639
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4640 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4641 * Grabs text from an MLE box.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4642 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4643 * handle: Handle to the MLE to be queried.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4644 * buffer: Text buffer to be exported. MUST allow for trailing nul character.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4645 * startpoint: Point to start grabbing text.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4646 * length: Amount of text to be grabbed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4647 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4648 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4649 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4650 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4651 gchar *text;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4652
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4653 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4654 /* force the return value to nul in case the following tests fail */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4655 if(buffer)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4656 buffer[0] = '\0';
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4657 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4658 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4659 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4660
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4661 if(tmp && GTK_IS_TEXT_VIEW(tmp))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4662 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4663 GtkTextBuffer *tbuffer;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4664 GtkTextIter start, end;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4665
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4666 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4667 gtk_text_buffer_get_iter_at_offset(tbuffer, &start, startpoint);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4668 gtk_text_buffer_get_iter_at_offset(tbuffer, &end, startpoint + length);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4669 text = gtk_text_iter_get_text(&start, &end);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4670 if(text) /* Should this get freed? */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4671 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4672 if(buffer)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4673 strcpy(buffer, text);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4674 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4675 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4676 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4677 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4678 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4679
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4680 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4681 * Obtains information about an MLE box.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4682 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4683 * handle: Handle to the MLE to be queried.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4684 * bytes: A pointer to a variable to return the total bytes.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4685 * lines: A pointer to a variable to return the number of lines.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4686 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4687 void dw_mle_get_size(HWND handle, unsigned long *bytes, unsigned long *lines)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4688 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4689 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4690
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4691 if(bytes)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4692 *bytes = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4693 if(lines)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4694 *lines = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4695
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4696 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4697 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4698 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4699 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4700
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4701 if(tmp && GTK_IS_TEXT_VIEW(tmp))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4702 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4703 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmp));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4704
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4705 if(bytes)
998
f019c5e8511f Fixed GTK reporting wrong character and line counts. 1000 revisions!!!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 994
diff changeset
4706 *bytes = gtk_text_buffer_get_char_count(buffer);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4707 if(lines)
998
f019c5e8511f Fixed GTK reporting wrong character and line counts. 1000 revisions!!!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 994
diff changeset
4708 *lines = gtk_text_buffer_get_line_count(buffer);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4709 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4710 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4711 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4712 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4713
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4714 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4715 * Deletes text from an MLE box.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4716 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4717 * handle: Handle to the MLE to be deleted from.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4718 * startpoint: Point to start deleting text.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4719 * length: Amount of text to be deleted.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4720 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4721 void dw_mle_delete(HWND handle, int startpoint, int length)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4722 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4723 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4724
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4725 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4726 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4727 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4728 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4729
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4730 if(tmp && GTK_IS_TEXT_VIEW(tmp))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4731 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4732 GtkTextBuffer *tbuffer;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4733 GtkTextIter start, end;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4734
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4735 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4736 gtk_text_buffer_get_iter_at_offset(tbuffer, &start, startpoint);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4737 gtk_text_buffer_get_iter_at_offset(tbuffer, &end, startpoint + length);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4738 gtk_text_buffer_delete(tbuffer, &start, &end);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4739 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4740 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4741 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4742 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4743
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4744 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4745 * Clears all text from an MLE box.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4746 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4747 * handle: Handle to the MLE to be cleared.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4748 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4749 void dw_mle_clear(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4750 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4751 int length, _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4752
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4753 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4754 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4755 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4756 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4757
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4758 if(tmp && GTK_IS_TEXT_VIEW(tmp))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4759 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4760 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmp));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4761
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4762 length = -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4763 gtk_text_buffer_set_text(buffer, "", length);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4764 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4765 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4766 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4767 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4768
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4769 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4770 * Sets the visible line of an MLE box.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4771 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4772 * handle: Handle to the MLE.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4773 * line: Line to be visible.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4774 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4775 void dw_mle_set_visible(HWND handle, int line)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4776 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4777 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4778
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4779 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4780 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4781 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4782 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4783
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4784 if(tmp && GTK_IS_TEXT_VIEW(tmp))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4785 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4786 GtkTextBuffer *tbuffer;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4787 GtkTextIter iter;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4788 GtkTextMark *mark = (GtkTextMark *)g_object_get_data(G_OBJECT(handle), "_dw_mark");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4789
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4790 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4791 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4792 gtk_text_iter_set_line(&iter, line);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4793 if(!mark)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4794 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4795 mark = gtk_text_buffer_create_mark(tbuffer, NULL, &iter, FALSE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4796 g_object_set_data(G_OBJECT(handle), "_dw_mark", (gpointer)mark);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4797 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4798 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4799 gtk_text_buffer_move_mark(tbuffer, mark, &iter);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4800 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(tmp), mark,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4801 0, FALSE, 0, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4802 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4803 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4804 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4805 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4806
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4807 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4808 * Sets the editablity of an MLE box.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4809 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4810 * handle: Handle to the MLE.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4811 * state: TRUE if it can be edited, FALSE for readonly.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4812 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4813 void dw_mle_set_editable(HWND handle, int state)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4814 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4815 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4816
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4817 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4818 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4819 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4820 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4821
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4822 if(tmp && GTK_IS_TEXT_VIEW(tmp))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4823 gtk_text_view_set_editable(GTK_TEXT_VIEW(tmp), state);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4824 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4825 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4826 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4827
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4828 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4829 * Sets the word wrap state of an MLE box.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4830 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4831 * handle: Handle to the MLE.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4832 * state: TRUE if it wraps, FALSE if it doesn't.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4833 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4834 void dw_mle_set_word_wrap(HWND handle, int state)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4835 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4836 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4837
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4838 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4839 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4840 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4841 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4842
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4843 if(tmp && GTK_IS_TEXT_VIEW(tmp))
1545
6edf3fce77f2 Initial support for container and MLE auto-sizing on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1539
diff changeset
4844 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), state ? GTK_WRAP_WORD : GTK_WRAP_NONE);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4845 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4846 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4847 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4848
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4849 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4850 * Sets the current cursor position of an MLE box.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4851 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4852 * handle: Handle to the MLE to be positioned.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4853 * point: Point to position cursor.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4854 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4855 void dw_mle_set_cursor(HWND handle, int point)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4856 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4857 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4858
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4859 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4860 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4861 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4862 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4863
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4864 if(tmp && GTK_IS_TEXT_VIEW(tmp))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4865 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4866 GtkTextBuffer *tbuffer;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4867 GtkTextIter iter;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4868 GtkTextMark *mark = (GtkTextMark *)g_object_get_data(G_OBJECT(handle), "_dw_mark");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4869
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4870 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4871 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, point);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4872 if(!mark)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4873 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4874 mark = gtk_text_buffer_create_mark(tbuffer, NULL, &iter, FALSE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4875 g_object_set_data(G_OBJECT(handle), "_dw_mark", (gpointer)mark);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4876 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4877 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4878 gtk_text_buffer_move_mark(tbuffer, mark, &iter);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4879 gtk_text_buffer_place_cursor(tbuffer, &iter);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4880 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(tmp), mark,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4881 0, FALSE, 0, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4882 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4883 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4884 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4885 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4886
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4887 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4888 * Finds text in an MLE box.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4889 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4890 * handle: Handle to the MLE to be cleared.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4891 * text: Text to search for.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4892 * point: Start point of search.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4893 * flags: Search specific flags.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4894 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4895 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4896 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4897 int _locked_by_me = FALSE, retval = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4898
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4899 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4900 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4901 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4902 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4903
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4904 if(tmp && GTK_IS_TEXT_VIEW(tmp))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4905 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4906 GtkTextBuffer *tbuffer;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4907 GtkTextIter iter, found;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4908
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4909 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4910 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, point);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4911 gtk_text_iter_forward_search(&iter, text, GTK_TEXT_SEARCH_TEXT_ONLY, &found, NULL, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4912 retval = gtk_text_iter_get_offset(&found);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4913 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4914 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4915 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4916 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4917 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4918
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4919 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4920 * Stops redrawing of an MLE box.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4921 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4922 * handle: Handle to the MLE to freeze.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4923 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4924 void dw_mle_freeze(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4925 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4926 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4927
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4928 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4929 * Resumes redrawing of an MLE box.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4930 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4931 * handle: Handle to the MLE to thaw.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4932 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4933 void dw_mle_thaw(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4934 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4935 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4936
1190
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4937 /* Internal function to update the progress bar
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4938 * while in an indeterminate state.
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4939 */
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4940 gboolean _dw_update_progress_bar(gpointer data)
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4941 {
1191
40500dabb112 Compile fix and fix for returning wrong value from the timeout function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
4942 if(g_object_get_data(G_OBJECT(data), "_dw_alive"))
1190
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4943 {
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4944 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(data));
1191
40500dabb112 Compile fix and fix for returning wrong value from the timeout function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
4945 return TRUE;
40500dabb112 Compile fix and fix for returning wrong value from the timeout function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
4946 }
40500dabb112 Compile fix and fix for returning wrong value from the timeout function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
4947 return FALSE;
1190
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4948 }
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4949
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4950 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4951 * Sets the percent bar position.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4952 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4953 * handle: Handle to the percent bar to be set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4954 * position: Position of the percent bar withing the range.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4955 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4956 void dw_percent_set_pos(HWND handle, unsigned int position)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4957 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4958 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4959
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4960 DW_MUTEX_LOCK;
1190
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4961 if(position == DW_PERCENT_INDETERMINATE)
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4962 {
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4963 /* Check if we are indeterminate already */
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4964 if(!g_object_get_data(G_OBJECT(handle), "_dw_alive"))
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4965 {
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4966 /* If not become indeterminate... and start a timer to continue */
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4967 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(handle));
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4968 g_object_set_data(G_OBJECT(handle), "_dw_alive", GINT_TO_POINTER(1));
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4969 g_timeout_add(100, (GSourceFunc)_dw_update_progress_bar, (gpointer)handle);
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4970 }
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4971 }
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4972 else
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4973 {
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4974 /* Cancel the existing timer if one is there */
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4975 g_object_set_data(G_OBJECT(handle), "_dw_alive", NULL);
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4976 /* Set the position like normal */
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4977 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(handle), (gfloat)position/100);
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1185
diff changeset
4978 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4979 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4980 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4981
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4982 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4983 * Returns the position of the slider.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4984 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4985 * handle: Handle to the slider to be queried.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4986 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4987 unsigned int dw_slider_get_pos(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4988 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4989 int val = 0, _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4990 GtkAdjustment *adjustment;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4991
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4992 if(!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4993 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4994
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4995 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4996 adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(handle), "_dw_adjustment");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4997 if(adjustment)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4998 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4999 int max = _round_value(gtk_adjustment_get_upper(adjustment)) - 1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5000 int thisval = _round_value(gtk_adjustment_get_value(adjustment));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5001
1583
525c4c9d04c6 After switching to non-deprecated functions in GTK3 like...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1579
diff changeset
5002 if(gtk_orientable_get_orientation(GTK_ORIENTABLE(handle)) == GTK_ORIENTATION_VERTICAL)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5003 val = max - thisval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5004 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5005 val = thisval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5006 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5007 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5008 return val;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5009 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5010
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5011 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5012 * Sets the slider position.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5013 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5014 * handle: Handle to the slider to be set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5015 * position: Position of the slider withing the range.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5016 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5017 void dw_slider_set_pos(HWND handle, unsigned int position)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5018 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5019 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5020 GtkAdjustment *adjustment;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5021
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5022 if(!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5023 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5024
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5025 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5026 adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(handle), "_dw_adjustment");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5027 if(adjustment)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5028 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5029 int max = _round_value(gtk_adjustment_get_upper(adjustment)) - 1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5030
1583
525c4c9d04c6 After switching to non-deprecated functions in GTK3 like...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1579
diff changeset
5031 if(gtk_orientable_get_orientation(GTK_ORIENTABLE(handle)) == GTK_ORIENTATION_VERTICAL)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5032 gtk_adjustment_set_value(adjustment, (gfloat)(max - position));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5033 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5034 gtk_adjustment_set_value(adjustment, (gfloat)position);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5035 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5036 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5037 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5038
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5039 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5040 * Returns the position of the scrollbar.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5041 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5042 * handle: Handle to the scrollbar to be queried.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5043 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5044 unsigned int dw_scrollbar_get_pos(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5045 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5046 int val = 0, _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5047 GtkAdjustment *adjustment;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5048
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5049 if(!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5050 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5051
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5052 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5053 adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(handle), "_dw_adjustment");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5054 if(adjustment)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5055 val = _round_value(gtk_adjustment_get_value(adjustment));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5056 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5057 return val;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5058 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5059
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5060 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5061 * Sets the scrollbar position.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5062 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5063 * handle: Handle to the scrollbar to be set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5064 * position: Position of the scrollbar withing the range.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5065 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5066 void dw_scrollbar_set_pos(HWND handle, unsigned int position)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5067 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5068 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5069 GtkAdjustment *adjustment;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5070
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5071 if(!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5072 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5073
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5074 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5075 adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(handle), "_dw_adjustment");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5076 if(adjustment)
1486
5cfbf2715eec Code simplification on GTK2 and ported the fix to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1482
diff changeset
5077 {
5cfbf2715eec Code simplification on GTK2 and ported the fix to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1482
diff changeset
5078 g_object_set_data(G_OBJECT(adjustment), "_dw_suppress_value_changed_event", GINT_TO_POINTER(1));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5079 gtk_adjustment_set_value(adjustment, (gfloat)position);
1486
5cfbf2715eec Code simplification on GTK2 and ported the fix to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1482
diff changeset
5080 g_object_set_data(G_OBJECT(adjustment), "_dw_suppress_value_changed_event", GINT_TO_POINTER(0));
5cfbf2715eec Code simplification on GTK2 and ported the fix to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1482
diff changeset
5081 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5082 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5083 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5084
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5085 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5086 * Sets the scrollbar range.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5087 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5088 * handle: Handle to the scrollbar to be set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5089 * range: Maximum range value.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5090 * visible: Visible area relative to the range.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5091 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5092 void API dw_scrollbar_set_range(HWND handle, unsigned int range, unsigned int visible)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5093 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5094 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5095 GtkAdjustment *adjustment;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5096
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5097 if(!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5098 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5099
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5100 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5101 adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(handle), "_dw_adjustment");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5102 if(adjustment)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5103 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5104 gtk_adjustment_set_upper(adjustment, (gdouble)range);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5105 gtk_adjustment_set_page_increment(adjustment,(gdouble)visible);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5106 gtk_adjustment_set_page_size(adjustment, (gdouble)visible);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5107 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5108 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5109 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5110
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5111 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5112 * Sets the spinbutton value.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5113 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5114 * handle: Handle to the spinbutton to be set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5115 * position: Current value of the spinbutton.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5116 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5117 void dw_spinbutton_set_pos(HWND handle, long position)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5118 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5119 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5120
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5121 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5122 gtk_spin_button_set_value(GTK_SPIN_BUTTON(handle), (gfloat)position);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5123 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5124 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5125
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5126 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5127 * Sets the spinbutton limits.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5128 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5129 * handle: Handle to the spinbutton to be set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5130 * position: Current value of the spinbutton.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5131 * position: Current value of the spinbutton.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5132 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5133 void dw_spinbutton_set_limits(HWND handle, long upper, long lower)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5134 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5135 long curval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5136 GtkAdjustment *adj;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5137 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5138
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5139 curval = dw_spinbutton_get_pos(handle);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5140 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5141 adj = (GtkAdjustment *)gtk_adjustment_new((gfloat)curval, (gfloat)lower, (gfloat)upper, 1.0, 5.0, 0.0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5142 gtk_spin_button_set_adjustment(GTK_SPIN_BUTTON(handle), adj);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5143 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5144 * Set our internal relationships between the adjustment and the spinbutton
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5145 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5146 g_object_set_data(G_OBJECT(handle), "_dw_adjustment", (gpointer)adj);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5147 g_object_set_data(G_OBJECT(adj), "_dw_spinbutton", (gpointer)handle);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5148 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5149 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5150
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5151 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5152 * Sets the entryfield character limit.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5153 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5154 * handle: Handle to the spinbutton to be set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5155 * limit: Number of characters the entryfield will take.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5156 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5157 void dw_entryfield_set_limit(HWND handle, ULONG limit)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5158 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5159 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5160
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5161 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5162 gtk_entry_set_max_length(GTK_ENTRY(handle), limit);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5163 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5164 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5165
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5166 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5167 * Returns the current value of the spinbutton.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5168 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5169 * handle: Handle to the spinbutton to be queried.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5170 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5171 long dw_spinbutton_get_pos(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5172 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5173 long retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5174 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5175
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5176 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5177 retval = (long)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(handle));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5178 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5179
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5180 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5181 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5182
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5183 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5184 * Returns the state of the checkbox.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5185 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5186 * handle: Handle to the checkbox to be queried.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5187 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5188 int dw_checkbox_get(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5189 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5190 int retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5191 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5192
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5193 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5194 retval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(handle));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5195 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5196
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5197 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5198 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5199
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5200 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5201 * Sets the state of the checkbox.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5202 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5203 * handle: Handle to the checkbox to be queried.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5204 * value: TRUE for checked, FALSE for unchecked.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5205 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5206 void dw_checkbox_set(HWND handle, int value)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5207 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5208 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5209
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5210 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5211 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(handle), value);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5212 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5213 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5214
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5215 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5216 * Inserts an item into a tree window (widget) after another item.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5217 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5218 * handle: Handle to the tree to be inserted.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5219 * item: Handle to the item to be positioned after.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5220 * title: The text title of the entry.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5221 * icon: Handle to coresponding icon.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5222 * parent: Parent handle or 0 if root.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5223 * itemdata: Item specific data.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5224 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5225 HTREEITEM dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, HICN icon, HTREEITEM parent, void *itemdata)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5226 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5227 GtkWidget *tree;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5228 GtkTreeIter *iter;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5229 GtkTreeStore *store;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5230 GdkPixbuf *pixbuf;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5231 HTREEITEM retval = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5232 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5233
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5234 if(!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5235 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5236
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5237 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5238 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5239 && GTK_IS_TREE_VIEW(tree) &&
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5240 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5241 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5242 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5243
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5244 pixbuf = _find_pixbuf(icon, NULL, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5245
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5246 gtk_tree_store_insert_after(store, iter, (GtkTreeIter *)parent, (GtkTreeIter *)item);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5247 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5248 retval = (HTREEITEM)iter;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5249 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5250 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5251
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5252 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5253 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5254
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5255 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5256 * Inserts an item into a tree window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5257 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5258 * handle: Handle to the tree to be inserted.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5259 * title: The text title of the entry.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5260 * icon: Handle to coresponding icon.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5261 * parent: Parent handle or 0 if root.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5262 * itemdata: Item specific data.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5263 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5264 HTREEITEM dw_tree_insert(HWND handle, char *title, HICN icon, HTREEITEM parent, void *itemdata)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5265 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5266 GtkWidget *tree;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5267 GtkTreeIter *iter;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5268 GtkTreeStore *store;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5269 GdkPixbuf *pixbuf;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5270 HTREEITEM retval = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5271 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5272
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5273 if(!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5274 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5275
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5276 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5277 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5278 && GTK_IS_TREE_VIEW(tree) &&
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5279 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5280 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5281 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5282
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5283 pixbuf = _find_pixbuf(icon, NULL, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5284
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5285 gtk_tree_store_append (store, iter, (GtkTreeIter *)parent);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5286 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5287 retval = (HTREEITEM)iter;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5288 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5289 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5290
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5291 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5292 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5293
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5294 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5295 * Sets the text and icon of an item in a tree window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5296 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5297 * handle: Handle to the tree containing the item.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5298 * item: Handle of the item to be modified.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5299 * title: The text title of the entry.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5300 * icon: Handle to coresponding icon.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5301 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5302 void dw_tree_item_change(HWND handle, HTREEITEM item, char *title, HICN icon)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5303 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5304 GtkWidget *tree;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5305 GtkTreeStore *store;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5306 GdkPixbuf *pixbuf;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5307 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5308
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5309 if(!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5310 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5311
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5312 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5313 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5314 && GTK_IS_TREE_VIEW(tree) &&
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5315 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5316 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5317 pixbuf = _find_pixbuf(icon, NULL, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5318
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5319 gtk_tree_store_set(store, (GtkTreeIter *)item, 0, title, 1, pixbuf, -1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5320 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5321 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5322 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5323
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5324 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5325 * Sets the item data of a tree item.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5326 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5327 * handle: Handle to the tree containing the item.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5328 * item: Handle of the item to be modified.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5329 * itemdata: User defined data to be associated with item.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5330 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5331 void dw_tree_item_set_data(HWND handle, HTREEITEM item, void *itemdata)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5332 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5333 GtkWidget *tree;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5334 GtkTreeStore *store;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5335 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5336
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5337 if(!handle || !item)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5338 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5339
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5340 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5341 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5342 && GTK_IS_TREE_VIEW(tree) &&
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5343 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5344 gtk_tree_store_set(store, (GtkTreeIter *)item, 2, itemdata, -1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5345 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5346 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5347
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5348 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5349 * Gets the text an item in a tree window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5350 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5351 * handle: Handle to the tree containing the item.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5352 * item: Handle of the item to be modified.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5353 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5354 char * API dw_tree_get_title(HWND handle, HTREEITEM item)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5355 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5356 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5357 char *text = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5358 GtkWidget *tree;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5359 GtkTreeModel *store;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5360
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5361 if(!handle || !item)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5362 return text;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5363
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5364 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5365 tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5366
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5367 if(tree && GTK_IS_TREE_VIEW(tree) &&
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5368 (store = (GtkTreeModel *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
5369 gtk_tree_model_get(store, (GtkTreeIter *)item, _DW_DATA_TYPE_STRING, &text, -1);
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
5370 if(text)
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
5371 {
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
5372 char *temp = text;
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
5373 text = strdup(temp);
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
5374 g_free(temp);
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
5375 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5376 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5377 return text;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5378 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5379
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5380 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5381 * Gets the text an item in a tree window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5382 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5383 * handle: Handle to the tree containing the item.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5384 * item: Handle of the item to be modified.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5385 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5386 HTREEITEM API dw_tree_get_parent(HWND handle, HTREEITEM item)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5387 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5388 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5389 HTREEITEM parent = (HTREEITEM)0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5390 GtkWidget *tree;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5391 GtkTreeModel *store;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5392
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5393 if(!handle || !item)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5394 return parent;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5395
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5396 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5397 tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5398
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5399 if(tree && GTK_IS_TREE_VIEW(tree) &&
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5400 (store = (GtkTreeModel *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5401 {
1900
969f7bbc0ff5 Fixed memory leak in dw_tree_get_parent() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1894
diff changeset
5402 GtkTreeIter iter;
969f7bbc0ff5 Fixed memory leak in dw_tree_get_parent() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1894
diff changeset
5403
969f7bbc0ff5 Fixed memory leak in dw_tree_get_parent() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1894
diff changeset
5404 if(gtk_tree_model_iter_parent(store, &iter, (GtkTreeIter *)item))
969f7bbc0ff5 Fixed memory leak in dw_tree_get_parent() on GTK2/3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1894
diff changeset
5405 gtk_tree_model_get(store, &iter, 3, &parent, -1);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5406 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5407 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5408 return parent;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5409 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5410
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5411 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5412 * Gets the item data of a tree item.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5413 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5414 * handle: Handle to the tree containing the item.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5415 * item: Handle of the item to be modified.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5416 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5417 void *dw_tree_item_get_data(HWND handle, HTREEITEM item)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5418 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5419 void *ret = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5420 GtkWidget *tree;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5421 GtkTreeModel *store;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5422 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5423
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5424 if(!handle || !item)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5425 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5426
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5427 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5428 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5429 && GTK_IS_TREE_VIEW(tree) &&
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5430 (store = (GtkTreeModel *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5431 gtk_tree_model_get(store, (GtkTreeIter *)item, 2, &ret, -1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5432 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5433 return ret;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5434 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5435
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5436 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5437 * Sets this item as the active selection.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5438 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5439 * handle: Handle to the tree window (widget) to be selected.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5440 * item: Handle to the item to be selected.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5441 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5442 void dw_tree_item_select(HWND handle, HTREEITEM item)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5443 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5444 GtkWidget *tree;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5445 GtkTreeStore *store;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5446 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5447
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5448 if(!handle || !item)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5449 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5450
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5451 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5452 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5453 && GTK_IS_TREE_VIEW(tree) &&
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5454 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5455 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5456 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), (GtkTreeIter *)item);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5457 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5458
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5459 gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree), path, NULL, FALSE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5460 gtk_tree_selection_select_iter(sel, (GtkTreeIter *)item);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5461 gtk_tree_path_free(path);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5462 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5463 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5464 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5465
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5466 static void _dw_recursive_free(GtkTreeModel *store, GtkTreeIter parent)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5467 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5468 void *data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5469 GtkTreeIter iter;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5470
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5471 gtk_tree_model_get(store, &parent, 3, &data, -1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5472 if(data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5473 free(data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5474 gtk_tree_store_set(GTK_TREE_STORE(store), &parent, 3, NULL, -1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5475
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5476 if(gtk_tree_model_iter_children(store, &iter, &parent))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5477 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5478 do {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5479 _dw_recursive_free(GTK_TREE_MODEL(store), iter);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5480 } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5481 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5482 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5483
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5484 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5485 * Removes all nodes from a tree.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5486 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5487 * handle: Handle to the window (widget) to be cleared.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5488 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5489 void dw_tree_clear(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5490 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5491 GtkWidget *tree;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5492 GtkTreeStore *store;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5493 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5494
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5495 if(!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5496 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5497
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5498 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5499 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5500 && GTK_IS_TREE_VIEW(tree) &&
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5501 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5502 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5503 GtkTreeIter iter;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5504
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5505 if(gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5506 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5507 do {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5508 _dw_recursive_free(GTK_TREE_MODEL(store), iter);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5509 } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5510 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5511 gtk_tree_store_clear(store);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5512 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5513 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5514 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5515
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5516 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5517 * Expands a node on a tree.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5518 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5519 * handle: Handle to the tree window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5520 * item: Handle to node to be expanded.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5521 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5522 void dw_tree_item_expand(HWND handle, HTREEITEM item)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5523 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5524 GtkWidget *tree;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5525 GtkTreeStore *store;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5526 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5527
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5528 if(!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5529 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5530
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5531 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5532 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5533 && GTK_IS_TREE_VIEW(tree) &&
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5534 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5535 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5536 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), (GtkTreeIter *)item);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5537 gtk_tree_view_expand_row(GTK_TREE_VIEW(tree), path, FALSE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5538 gtk_tree_path_free(path);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5539 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5540 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5541 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5542
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5543 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5544 * Collapses a node on a tree.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5545 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5546 * handle: Handle to the tree window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5547 * item: Handle to node to be collapsed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5548 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5549 void dw_tree_item_collapse(HWND handle, HTREEITEM item)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5550 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5551 GtkWidget *tree;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5552 GtkTreeStore *store;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5553 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5554
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5555 if(!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5556 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5557
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5558 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5559 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5560 && GTK_IS_TREE_VIEW(tree) &&
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5561 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5562 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5563 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), (GtkTreeIter *)item);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5564 gtk_tree_view_collapse_row(GTK_TREE_VIEW(tree), path);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5565 gtk_tree_path_free(path);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5566 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5567 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5568 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5569
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5570 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5571 * Removes a node from a tree.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5572 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5573 * handle: Handle to the window (widget) to be cleared.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5574 * item: Handle to node to be deleted.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5575 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5576 void dw_tree_item_delete(HWND handle, HTREEITEM item)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5577 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5578 GtkWidget *tree;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5579 GtkTreeStore *store;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5580 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5581
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5582 if(!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5583 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5584
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5585 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5586 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5587 && GTK_IS_TREE_VIEW(tree) &&
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5588 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5589 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5590 gtk_tree_store_remove(store, (GtkTreeIter *)item);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5591 free(item);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5592 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5593 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5594 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5595
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5596 #define _DW_CONTAINER_STORE_EXTRA 2
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5597
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5598 static int _dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator, int extra)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5599 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5600 int z;
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
5601 char numbuf[21];
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5602 GtkWidget *tree;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5603 GtkListStore *store;
784
fb21fdd6b839 Slight code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 783
diff changeset
5604 GtkTreeViewColumn *col;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5605 GtkCellRenderer *rend;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5606 GtkTreeSelection *sel;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5607 int _locked_by_me = FALSE;
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5608 GType *array = calloc(count + _DW_CONTAINER_STORE_EXTRA + 1, sizeof(GType));
780
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
5609
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
5610 DW_MUTEX_LOCK;
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
5611 /* Save some of the info so it is easily accessible */
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
5612 g_object_set_data(G_OBJECT(handle), "_dw_cont_columns", GINT_TO_POINTER(count));
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5613 g_object_set_data(G_OBJECT(handle), "_dw_cont_extra", GINT_TO_POINTER(extra));
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
5614
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5615 /* First param is row title */
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5616 array[0] = G_TYPE_STRING;
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5617 /* Second param is row data */
883
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5618 array[1] = G_TYPE_POINTER;
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5619 array[2] = G_TYPE_POINTER;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5620 /* First loop... create array to create the store */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5621 for(z=0;z<count;z++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5622 {
883
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5623 if(z == 0 && flags[z] & DW_CFA_STRINGANDICON)
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5624 {
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5625 array[_DW_CONTAINER_STORE_EXTRA] = GDK_TYPE_PIXBUF;
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5626 array[_DW_CONTAINER_STORE_EXTRA+1] = G_TYPE_STRING;
883
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5627 }
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5628 else if(flags[z] & DW_CFA_BITMAPORICON)
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5629 {
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5630 array[z+_DW_CONTAINER_STORE_EXTRA+1] = GDK_TYPE_PIXBUF;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5631 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5632 else if(flags[z] & DW_CFA_STRING)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5633 {
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5634 array[z+_DW_CONTAINER_STORE_EXTRA+1] = G_TYPE_STRING;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5635 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5636 else if(flags[z] & DW_CFA_ULONG)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5637 {
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5638 array[z+_DW_CONTAINER_STORE_EXTRA+1] = G_TYPE_ULONG;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5639 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5640 else if(flags[z] & DW_CFA_TIME)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5641 {
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5642 array[z+_DW_CONTAINER_STORE_EXTRA+1] = G_TYPE_STRING;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5643 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5644 else if(flags[z] & DW_CFA_DATE)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5645 {
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5646 array[z+_DW_CONTAINER_STORE_EXTRA+1] = G_TYPE_STRING;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5647 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5648 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5649 /* Create the store and then the tree */
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5650 store = gtk_list_store_newv(count + _DW_CONTAINER_STORE_EXTRA + 1, array);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5651 tree = _tree_setup(handle, GTK_TREE_MODEL(store));
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
5652 g_object_set_data(G_OBJECT(tree), "_dw_tree_type", GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5653 /* Second loop... create the columns */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5654 for(z=0;z<count;z++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5655 {
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
5656 snprintf(numbuf, 20, "_dw_cont_col%d", z);
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5657 g_object_set_data(G_OBJECT(tree), numbuf, GINT_TO_POINTER(flags[z]));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5658 col = gtk_tree_view_column_new();
884
0f99520041c4 Implemented container column alignment on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 883
diff changeset
5659 rend = NULL;
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
5660 void **params = calloc(sizeof(void *), 3);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
5661
883
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5662 if(z == 0 && flags[z] & DW_CFA_STRINGANDICON)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5663 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5664 rend = gtk_cell_renderer_pixbuf_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5665 gtk_tree_view_column_pack_start(col, rend, FALSE);
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5666 gtk_tree_view_column_add_attribute(col, rend, "pixbuf", _DW_CONTAINER_STORE_EXTRA);
883
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5667 rend = gtk_cell_renderer_text_new();
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5668 gtk_tree_view_column_pack_start(col, rend, TRUE);
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5669 gtk_tree_view_column_add_attribute(col, rend, "text", _DW_CONTAINER_STORE_EXTRA+1);
883
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5670 }
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5671 else if(flags[z] & DW_CFA_BITMAPORICON)
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5672 {
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5673 rend = gtk_cell_renderer_pixbuf_new();
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5674 gtk_tree_view_column_pack_start(col, rend, FALSE);
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5675 gtk_tree_view_column_add_attribute(col, rend, "pixbuf", z+_DW_CONTAINER_STORE_EXTRA+1);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5676 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5677 else if(flags[z] & DW_CFA_STRING)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5678 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5679 rend = gtk_cell_renderer_text_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5680 gtk_tree_view_column_pack_start(col, rend, TRUE);
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5681 gtk_tree_view_column_add_attribute(col, rend, "text", z+_DW_CONTAINER_STORE_EXTRA+1);
784
fb21fdd6b839 Slight code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 783
diff changeset
5682 gtk_tree_view_column_set_resizable(col, TRUE);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5683 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5684 else if(flags[z] & DW_CFA_ULONG)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5685 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5686 rend = gtk_cell_renderer_text_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5687 gtk_tree_view_column_pack_start(col, rend, TRUE);
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5688 gtk_tree_view_column_add_attribute(col, rend, "text", z+_DW_CONTAINER_STORE_EXTRA+1);
784
fb21fdd6b839 Slight code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 783
diff changeset
5689 gtk_tree_view_column_set_resizable(col, TRUE);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5690 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5691 else if(flags[z] & DW_CFA_TIME)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5692 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5693 rend = gtk_cell_renderer_text_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5694 gtk_tree_view_column_pack_start(col, rend, TRUE);
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5695 gtk_tree_view_column_add_attribute(col, rend, "text", z+_DW_CONTAINER_STORE_EXTRA+1);
784
fb21fdd6b839 Slight code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 783
diff changeset
5696 gtk_tree_view_column_set_resizable(col, TRUE);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5697 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5698 else if(flags[z] & DW_CFA_DATE)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5699 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5700 rend = gtk_cell_renderer_text_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5701 gtk_tree_view_column_pack_start(col, rend, TRUE);
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
5702 gtk_tree_view_column_add_attribute(col, rend, "text", z+_DW_CONTAINER_STORE_EXTRA+1);
784
fb21fdd6b839 Slight code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 783
diff changeset
5703 gtk_tree_view_column_set_resizable(col, TRUE);
780
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
5704 }
883
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5705 g_object_set_data(G_OBJECT(col), "_dw_column", GINT_TO_POINTER(z));
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
5706 params[2] = tree;
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
5707 g_signal_connect_data(G_OBJECT(col), "clicked", G_CALLBACK(_column_click_event), (gpointer)params, _dw_signal_disconnect, 0);
780
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
5708 gtk_tree_view_column_set_title(col, titles[z]);
884
0f99520041c4 Implemented container column alignment on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 883
diff changeset
5709 if(flags[z] & DW_CFA_RIGHT)
0f99520041c4 Implemented container column alignment on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 883
diff changeset
5710 {
0f99520041c4 Implemented container column alignment on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 883
diff changeset
5711 gtk_tree_view_column_set_alignment(col, 1.0);
0f99520041c4 Implemented container column alignment on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 883
diff changeset
5712 if(rend)
0f99520041c4 Implemented container column alignment on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 883
diff changeset
5713 gtk_cell_renderer_set_alignment(rend, 1.0, 0.5);
0f99520041c4 Implemented container column alignment on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 883
diff changeset
5714 }
0f99520041c4 Implemented container column alignment on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 883
diff changeset
5715 else if(flags[z] & DW_CFA_CENTER)
0f99520041c4 Implemented container column alignment on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 883
diff changeset
5716 {
0f99520041c4 Implemented container column alignment on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 883
diff changeset
5717 gtk_tree_view_column_set_alignment(col, 0.5);
0f99520041c4 Implemented container column alignment on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 883
diff changeset
5718 if(rend)
0f99520041c4 Implemented container column alignment on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 883
diff changeset
5719 gtk_cell_renderer_set_alignment(rend, 0.5, 0.5);
0f99520041c4 Implemented container column alignment on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 883
diff changeset
5720 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5721 gtk_tree_view_append_column(GTK_TREE_VIEW (tree), col);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5722 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5723 /* Finish up */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5724 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), TRUE);
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
5725 gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(tree), TRUE);
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
5726 gtk_tree_view_set_rubber_banding(GTK_TREE_VIEW(tree), TRUE);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5727 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5728 if(g_object_get_data(G_OBJECT(handle), "_dw_multi_sel"))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5729 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5730 gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5731 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5732 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5733 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5734 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5735 }
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
5736 gtk_widget_show(tree);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5737 free(array);
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
5738 if(_DWDefaultFont)
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
5739 dw_window_set_font(handle, _DWDefaultFont);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5740 DW_MUTEX_UNLOCK;
986
87dc0f5f96d0 Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 976
diff changeset
5741 return DW_ERROR_NONE;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5742 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5743
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5744 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5745 * Sets up the container columns.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5746 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5747 * handle: Handle to the container to be configured.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5748 * flags: An array of unsigned longs with column flags.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5749 * titles: An array of strings with column text titles.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5750 * count: The number of columns (this should match the arrays).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5751 * separator: The column number that contains the main separator.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5752 * (this item may only be used in OS/2)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5753 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5754 int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5755 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5756 return _dw_container_setup(handle, flags, titles, count, separator, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5757 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5758
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5759 /*
1744
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1742
diff changeset
5760 * Configures the main filesystem columnn title for localization.
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1742
diff changeset
5761 * Parameters:
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1742
diff changeset
5762 * handle: Handle to the container to be configured.
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1742
diff changeset
5763 * title: The title to be displayed in the main column.
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1742
diff changeset
5764 */
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1742
diff changeset
5765 void API dw_filesystem_set_column_title(HWND handle, char *title)
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1742
diff changeset
5766 {
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1742
diff changeset
5767 char *newtitle = strdup(title ? title : "");
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1742
diff changeset
5768
1745
7dd1659c2693 Fixes for the new localization function on OS/2 and GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
5769 g_object_set_data(G_OBJECT(handle), "_dw_coltitle", newtitle);
1744
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1742
diff changeset
5770 }
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1742
diff changeset
5771
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1742
diff changeset
5772 /*
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5773 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5774 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5775 * handle: Handle to the container to be configured.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5776 * flags: An array of unsigned longs with column flags.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5777 * titles: An array of strings with column text titles.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5778 * count: The number of columns (this should match the arrays).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5779 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5780 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5781 {
883
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5782 char **newtitles = malloc(sizeof(char *) * (count + 1));
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5783 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 1));
1745
7dd1659c2693 Fixes for the new localization function on OS/2 and GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
5784 char *coltitle = (char *)g_object_get_data(G_OBJECT(handle), "_dw_coltitle");
1744
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1742
diff changeset
5785
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1742
diff changeset
5786 newtitles[0] = coltitle ? coltitle : "Filename";
883
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5787 newflags[0] = DW_CFA_STRINGANDICON | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR;
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5788
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5789 memcpy(&newtitles[1], titles, sizeof(char *) * count);
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5790 memcpy(&newflags[1], flags, sizeof(unsigned long) * count);
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5791
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5792 _dw_container_setup(handle, newflags, newtitles, count + 1, 1, 1);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5793
1744
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1742
diff changeset
5794 if(coltitle)
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1742
diff changeset
5795 {
1745
7dd1659c2693 Fixes for the new localization function on OS/2 and GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
5796 g_object_set_data(G_OBJECT(handle), "_dw_coltitle", NULL);
1744
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1742
diff changeset
5797 free(coltitle);
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1742
diff changeset
5798 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5799 if ( newtitles) free(newtitles);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5800 if ( newflags ) free(newflags);
986
87dc0f5f96d0 Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 976
diff changeset
5801 return DW_ERROR_NONE;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5802 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5803
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5804 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5805 * Obtains an icon from a module (or header in GTK).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5806 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5807 * module: Handle to module (DLL) in OS/2 and Windows.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5808 * id: A unsigned long id int the resources on OS/2 and
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5809 * Windows, on GTK this is converted to a pointer
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5810 * to an embedded XPM.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5811 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5812 HICN dw_icon_load(unsigned long module, unsigned long id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5813 {
976
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
5814 return (HICN)id;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5815 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5816
1706
fb6807b0ab0d Limit the size of an HICN to 24x24 on GTK... icons are used for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1679
diff changeset
5817 /* Internal function to keep HICNs from getting too big */
fb6807b0ab0d Limit the size of an HICN to 24x24 on GTK... icons are used for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1679
diff changeset
5818 GdkPixbuf *_icon_resize(GdkPixbuf *ret)
fb6807b0ab0d Limit the size of an HICN to 24x24 on GTK... icons are used for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1679
diff changeset
5819 {
1709
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1706
diff changeset
5820 if(ret)
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1706
diff changeset
5821 {
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1706
diff changeset
5822 int pwidth = gdk_pixbuf_get_width(ret);
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1706
diff changeset
5823 int pheight = gdk_pixbuf_get_height(ret);
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1706
diff changeset
5824
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1706
diff changeset
5825 if(pwidth > 24 || pheight > 24)
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1706
diff changeset
5826 {
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1706
diff changeset
5827 GdkPixbuf *orig = ret;
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1706
diff changeset
5828 ret = gdk_pixbuf_scale_simple(ret, pwidth > 24 ? 24 : pwidth, pheight > 24 ? 24 : pheight, GDK_INTERP_BILINEAR);
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1706
diff changeset
5829 g_object_unref(G_OBJECT(orig));
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1706
diff changeset
5830 }
1706
fb6807b0ab0d Limit the size of an HICN to 24x24 on GTK... icons are used for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1679
diff changeset
5831 }
fb6807b0ab0d Limit the size of an HICN to 24x24 on GTK... icons are used for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1679
diff changeset
5832 return ret;
fb6807b0ab0d Limit the size of an HICN to 24x24 on GTK... icons are used for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1679
diff changeset
5833 }
fb6807b0ab0d Limit the size of an HICN to 24x24 on GTK... icons are used for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1679
diff changeset
5834
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5835 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5836 * Obtains an icon from a file.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5837 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5838 * filename: Name of the file, omit extention to have
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5839 * DW pick the appropriate file extension.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5840 * (ICO on OS/2 or Windows, XPM on Unix)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5841 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5842 HICN API dw_icon_load_from_file(char *filename)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5843 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5844 int _locked_by_me = FALSE;
1258
3df86772b625 Updated the list of supported image formats for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1245
diff changeset
5845 char *file = alloca(strlen(filename) + 6);
976
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
5846 int i, found_ext = 0;
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
5847 HICN ret = 0;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5848
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5849 if (!file)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5850 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5851
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5852 strcpy(file, filename);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5853
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5854 /* check if we can read from this file (it exists and read permission) */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5855 if (access(file, 04) != 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5856 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5857 /* Try with various extentions */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5858 for ( i = 0; i < NUM_EXTS; i++ )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5859 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5860 strcpy( file, filename );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5861 strcat( file, image_exts[i] );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5862 if ( access( file, 04 ) == 0 )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5863 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5864 found_ext = 1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5865 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5866 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5867 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5868 if ( found_ext == 0 )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5869 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5870 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5871 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5872 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5873
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5874 DW_MUTEX_LOCK;
1706
fb6807b0ab0d Limit the size of an HICN to 24x24 on GTK... icons are used for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1679
diff changeset
5875 ret = _icon_resize(gdk_pixbuf_new_from_file(file, NULL));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5876 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5877 return ret;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5878 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5879
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5880 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5881 * Obtains an icon from data.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5882 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5883 * data: Source of data for image.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5884 * len: length of data
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5885 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5886 HICN API dw_icon_load_from_data(char *data, int len)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5887 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5888 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5889 char *file;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5890 FILE *fp;
976
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
5891 HICN ret = 0;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5892
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5893 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5894 * A real hack; create a temporary file and write the contents
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5895 * of the data to the file
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5896 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5897 file = tmpnam( NULL );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5898 fp = fopen( file, "wb" );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5899 if ( fp )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5900 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5901 fwrite( data, len, 1, fp );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5902 fclose( fp );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5903 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5904 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5905 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5906 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5907 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5908 DW_MUTEX_LOCK;
1706
fb6807b0ab0d Limit the size of an HICN to 24x24 on GTK... icons are used for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1679
diff changeset
5909 ret = _icon_resize(gdk_pixbuf_new_from_file(file, NULL));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5910 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5911 return ret;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5912 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5913
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5914 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5915 * Frees a loaded resource in OS/2 and Windows.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5916 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5917 * handle: Handle to icon returned by dw_icon_load().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5918 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5919 void dw_icon_free(HICN handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5920 {
1106
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
5921 int iicon = GPOINTER_TO_INT(handle);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
5922
976
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
5923 if(iicon > 65535)
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
5924 {
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
5925 g_object_unref(handle);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5926 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5927 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5928
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5929 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5930 * Allocates memory used to populate a container.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5931 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5932 * handle: Handle to the container window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5933 * rowcount: The number of items to be populated.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5934 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5935 void *dw_container_alloc(HWND handle, int rowcount)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5936 {
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5937 int z, prevrowcount = 0;
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5938 GtkWidget *cont;
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5939 GtkListStore *store = NULL;
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5940 int _locked_by_me = FALSE;
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5941
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5942 DW_MUTEX_LOCK;
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5943 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
5944
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5945 /* Make sure it is the correct tree type */
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5946 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5947 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5948
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5949 if(store)
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5950 {
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5951 GtkTreeIter iter;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
5952
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
5953 prevrowcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), "_dw_rowcount"));
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5954
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5955 for(z=0;z<rowcount;z++)
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5956 {
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5957 gtk_list_store_append(store, &iter);
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5958 }
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5959 g_object_set_data(G_OBJECT(cont), "_dw_insertpos", GINT_TO_POINTER(prevrowcount));
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5960 g_object_set_data(G_OBJECT(cont), "_dw_rowcount", GINT_TO_POINTER(rowcount + prevrowcount));
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5961 }
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5962 DW_MUTEX_UNLOCK;
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5963 return (void *)cont;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5964 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5965
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5966 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5967 * Internal representation of dw_container_set_item() extracted so we can pass
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5968 * two data pointers; icon and text for dw_filesystem_set_item().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5969 */
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5970 void _dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data)
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5971 {
1501
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
5972 char numbuf[21], textbuffer[101] = {0};
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5973 int flag = 0;
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5974 GtkWidget *cont;
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5975 GtkListStore *store = NULL;
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5976 int _locked_by_me = FALSE;
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5977
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5978 DW_MUTEX_LOCK;
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5979 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
5980
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5981 /* Make sure it is the correct tree type */
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5982 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5983 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5984
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5985 if(store)
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5986 {
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5987 GtkTreeIter iter;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
5988
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
5989 snprintf(numbuf, 20, "_dw_cont_col%d", column);
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
5990 flag = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), numbuf));
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5991 if(pointer)
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5992 {
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
5993 row += GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), "_dw_insertpos"));
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5994 }
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5995
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5996 if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, row))
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
5997 {
883
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5998 if(flag & DW_CFA_STRINGANDICON)
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
5999 {
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
6000 void **thisdata = (void **)data;
1501
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6001 HICN hicon = data ? *((HICN *)thisdata[0]) : 0;
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6002 char *tmp = data ? (char *)thisdata[1] : NULL;
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6003 GdkPixbuf *pixbuf = hicon ? _find_pixbuf(hicon, NULL, NULL) : NULL;
883
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
6004
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6005 gtk_list_store_set(store, &iter, _DW_CONTAINER_STORE_EXTRA, pixbuf, -1);
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6006 gtk_list_store_set(store, &iter, _DW_CONTAINER_STORE_EXTRA + 1, tmp, -1);
883
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
6007 }
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
6008 else if(flag & DW_CFA_BITMAPORICON)
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6009 {
1501
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6010 HICN hicon = data ? *((HICN *)data) : 0;
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6011 GdkPixbuf *pixbuf = hicon ? _find_pixbuf(hicon, NULL, NULL) : NULL;
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6012
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6013 gtk_list_store_set(store, &iter, column + _DW_CONTAINER_STORE_EXTRA + 1, pixbuf, -1);
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6014 }
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6015 else if(flag & DW_CFA_STRING)
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6016 {
1501
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6017 char *tmp = data ? *((char **)data) : NULL;
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6018 gtk_list_store_set(store, &iter, column + _DW_CONTAINER_STORE_EXTRA + 1, tmp, -1);
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6019 }
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6020 else if(flag & DW_CFA_ULONG)
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6021 {
1501
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6022 ULONG tmp = data ? *((ULONG *)data): 0;
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6023
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6024 gtk_list_store_set(store, &iter, column + _DW_CONTAINER_STORE_EXTRA + 1, tmp, -1);
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6025 }
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6026 else if(flag & DW_CFA_DATE)
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6027 {
1501
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6028 if(data)
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6029 {
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6030 struct tm curtm;
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6031 CDATE cdate = *((CDATE *)data);
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6032
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6033 memset( &curtm, 0, sizeof(curtm) );
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6034 curtm.tm_mday = cdate.day;
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6035 curtm.tm_mon = cdate.month - 1;
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6036 curtm.tm_year = cdate.year - 1900;
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6037
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6038 strftime(textbuffer, 100, "%x", &curtm);
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6039 }
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6040 gtk_list_store_set(store, &iter, column + _DW_CONTAINER_STORE_EXTRA + 1, textbuffer, -1);
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6041 }
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6042 else if(flag & DW_CFA_TIME)
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6043 {
1501
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6044 if(data)
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6045 {
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6046 struct tm curtm;
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6047 CTIME ctime = *((CTIME *)data);
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6048
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6049 memset( &curtm, 0, sizeof(curtm) );
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6050 curtm.tm_hour = ctime.hours;
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6051 curtm.tm_min = ctime.minutes;
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6052 curtm.tm_sec = ctime.seconds;
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6053
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6054 strftime(textbuffer, 100, "%X", &curtm);
7060e258e383 Allow passing NULL to the dw_container_change/set_item() APIs on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1499
diff changeset
6055 }
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6056 gtk_list_store_set(store, &iter, column + _DW_CONTAINER_STORE_EXTRA + 1, textbuffer, -1);
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6057 }
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6058 }
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6059 }
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6060 DW_MUTEX_UNLOCK;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6061 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6062
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6063 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6064 * Sets an item in specified row and column to the given data.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6065 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6066 * handle: Handle to the container window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6067 * pointer: Pointer to the allocated memory in dw_container_alloc().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6068 * column: Zero based column of data being set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6069 * row: Zero based row of data being set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6070 * data: Pointer to the data to be added.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6071 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6072 void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6073 {
835
82072ff08513 Removed some GTK_IS_TREE_VIEW checks that were erroneously dropping out of valid requests.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 830
diff changeset
6074 _dw_container_set_item(handle, pointer, column, row, data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6075 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6076
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6077 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6078 * Changes an existing item in specified row and column to the given data.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6079 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6080 * handle: Handle to the container window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6081 * column: Zero based column of data being set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6082 * row: Zero based row of data being set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6083 * data: Pointer to the data to be added.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6084 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6085 void dw_container_change_item(HWND handle, int column, int row, void *data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6086 {
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6087 _dw_container_set_item(handle, NULL, column, row, data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6088 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6089
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6090 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6091 * Changes an existing item in specified row and column to the given data.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6092 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6093 * handle: Handle to the container window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6094 * column: Zero based column of data being set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6095 * row: Zero based row of data being set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6096 * data: Pointer to the data to be added.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6097 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6098 void API dw_filesystem_change_item(HWND handle, int column, int row, void *data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6099 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6100 dw_filesystem_set_item(handle, NULL, column, row, data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6101 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6102
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6103 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6104 * Changes an item in specified row and column to the given data.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6105 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6106 * handle: Handle to the container window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6107 * pointer: Pointer to the allocated memory in dw_container_alloc().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6108 * column: Zero based column of data being set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6109 * row: Zero based row of data being set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6110 * data: Pointer to the data to be added.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6111 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6112 void API dw_filesystem_change_file(HWND handle, int row, char *filename, HICN icon)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6113 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6114 dw_filesystem_set_file(handle, NULL, row, filename, icon);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6115 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6116
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6117 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6118 * Sets an item in specified row and column to the given data.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6119 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6120 * handle: Handle to the container window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6121 * pointer: Pointer to the allocated memory in dw_container_alloc().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6122 * column: Zero based column of data being set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6123 * row: Zero based row of data being set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6124 * data: Pointer to the data to be added.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6125 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6126 void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, HICN icon)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6127 {
883
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
6128 void *data[2] = { (void *)&icon, (void *)filename };
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6129
883
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
6130 _dw_container_set_item(handle, pointer, 0, row, (void *)data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6131 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6132
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6133 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6134 * Sets an item in specified row and column to the given data.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6135 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6136 * handle: Handle to the container window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6137 * pointer: Pointer to the allocated memory in dw_container_alloc().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6138 * column: Zero based column of data being set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6139 * row: Zero based row of data being set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6140 * data: Pointer to the data to be added.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6141 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6142 void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6143 {
883
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
6144 _dw_container_set_item(handle, pointer, column + 1, row, data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6145 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6146
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6147 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6148 * Gets column type for a container column
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6149 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6150 * handle: Handle to the container window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6151 * column: Zero based column.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6152 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6153 int dw_container_get_column_type(HWND handle, int column)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6154 {
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6155 char numbuf[20];
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
6156 int flag, rc = 0;
786
0e251c2f5d08 Implemented the column click event handler...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 785
diff changeset
6157 GtkWidget *cont = handle;
781
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6158 int _locked_by_me = FALSE;
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6159
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6160 DW_MUTEX_LOCK;
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6161 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
df6091308b3f Have the basics of containers working now with the tree view widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 780
diff changeset
6162 if(!cont)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6163 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6164 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6165 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6166 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6167
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
6168 snprintf(numbuf, 20, "_dw_cont_col%d", column);
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
6169 flag = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), numbuf));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6170
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6171 if(flag & DW_CFA_BITMAPORICON)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6172 rc = DW_CFA_BITMAPORICON;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6173 else if(flag & DW_CFA_STRING)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6174 rc = DW_CFA_STRING;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6175 else if(flag & DW_CFA_ULONG)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6176 rc = DW_CFA_ULONG;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6177 else if(flag & DW_CFA_DATE)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6178 rc = DW_CFA_DATE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6179 else if(flag & DW_CFA_TIME)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6180 rc = DW_CFA_TIME;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6181 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6182 rc = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6183 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6184 return rc;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6185 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6186
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6187 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6188 * Gets column type for a filesystem container column
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6189 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6190 * handle: Handle to the container window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6191 * column: Zero based column.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6192 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6193 int API dw_filesystem_get_column_type(HWND handle, int column)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6194 {
883
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
6195 return dw_container_get_column_type( handle, column + 1 );
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6196 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6197
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6198 /*
1207
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6199 * Sets the alternating row colors for container window (widget) handle.
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6200 * Parameters:
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6201 * handle: The window (widget) handle.
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6202 * oddcolor: Odd row background color in DW_RGB format or a default color index.
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6203 * evencolor: Even row background color in DW_RGB format or a default color index.
1211
70dca53cb071 Updated GTK3 with the behavior change just commited for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1207
diff changeset
6204 * DW_RGB_TRANSPARENT will disable coloring rows.
70dca53cb071 Updated GTK3 with the behavior change just commited for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1207
diff changeset
6205 * DW_CLR_DEFAULT will use the system default alternating row colors.
1207
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6206 */
1291
b99b0b2c2826 Renamed dw_container_set_row_bg() to dw_container_set_stripe().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1289
diff changeset
6207 void API dw_container_set_stripe(HWND handle, unsigned long oddcolor, unsigned long evencolor)
1207
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6208 {
1916
eafaab13d0db Minor fix to that last commit, and remove call to gtk_tree_view_set_rules_hint()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1915
diff changeset
6209 #if !GTK_CHECK_VERSION(3,14,0)
1207
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6210 GtkWidget *cont;
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6211 int _locked_by_me = FALSE;
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6212 DW_MUTEX_LOCK;
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6213 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6214
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6215 /* Make sure it is the correct tree type */
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6216 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6217 {
1211
70dca53cb071 Updated GTK3 with the behavior change just commited for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1207
diff changeset
6218 if(oddcolor == DW_RGB_TRANSPARENT && evencolor == DW_RGB_TRANSPARENT)
1207
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6219 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(cont), FALSE);
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6220 else
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6221 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(cont), TRUE);
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6222 }
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6223 DW_MUTEX_UNLOCK;
1916
eafaab13d0db Minor fix to that last commit, and remove call to gtk_tree_view_set_rules_hint()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1915
diff changeset
6224 #endif
1207
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6225 }
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6226
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6227 /*
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6228 * Sets the width of a column in the container.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6229 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6230 * handle: Handle to window (widget) of container.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6231 * column: Zero based column of width being set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6232 * width: Width of column in pixels.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6233 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6234 void dw_container_set_column_width(HWND handle, int column, int width)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6235 {
830
43e6282463fa Implemented dw_container_set_column_width().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 820
diff changeset
6236 GtkWidget *cont;
43e6282463fa Implemented dw_container_set_column_width().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 820
diff changeset
6237 int _locked_by_me = FALSE;
43e6282463fa Implemented dw_container_set_column_width().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 820
diff changeset
6238
43e6282463fa Implemented dw_container_set_column_width().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 820
diff changeset
6239 DW_MUTEX_LOCK;
43e6282463fa Implemented dw_container_set_column_width().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 820
diff changeset
6240 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
1207
423da07c8f05 Basic support for row colors on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1203
diff changeset
6241
830
43e6282463fa Implemented dw_container_set_column_width().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 820
diff changeset
6242 /* Make sure it is the correct tree type */
43e6282463fa Implemented dw_container_set_column_width().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 820
diff changeset
6243 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
43e6282463fa Implemented dw_container_set_column_width().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 820
diff changeset
6244 {
43e6282463fa Implemented dw_container_set_column_width().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 820
diff changeset
6245 GtkTreeViewColumn *col = gtk_tree_view_get_column(GTK_TREE_VIEW(cont), column);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6246
830
43e6282463fa Implemented dw_container_set_column_width().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 820
diff changeset
6247 if(col && GTK_IS_TREE_VIEW_COLUMN(col))
43e6282463fa Implemented dw_container_set_column_width().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 820
diff changeset
6248 {
43e6282463fa Implemented dw_container_set_column_width().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 820
diff changeset
6249 gtk_tree_view_column_set_fixed_width(GTK_TREE_VIEW_COLUMN(col), width);
43e6282463fa Implemented dw_container_set_column_width().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 820
diff changeset
6250 }
43e6282463fa Implemented dw_container_set_column_width().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 820
diff changeset
6251 }
43e6282463fa Implemented dw_container_set_column_width().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 820
diff changeset
6252 DW_MUTEX_UNLOCK;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6253 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6254
820
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6255 /* Internal version for both */
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6256 void _dw_container_set_row_data(HWND handle, void *pointer, int row, int type, void *data)
820
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6257 {
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6258 GtkWidget *cont = handle;
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6259 GtkListStore *store = NULL;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6260 int _locked_by_me = FALSE;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6261
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6262 DW_MUTEX_LOCK;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6263 /* Make sure it is the correct tree type */
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6264 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6265 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6266
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6267 if(store)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6268 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6269 GtkTreeIter iter;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6270
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6271 if(pointer)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6272 {
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
6273 row += GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), "_dw_insertpos"));
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6274 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6275
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6276 if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, row))
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6277 {
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6278 gtk_list_store_set(store, &iter, type, (gpointer)data, -1);
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6279 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6280 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6281 DW_MUTEX_UNLOCK;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6282 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6283
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6284 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6285 * Sets the title of a row in the container.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6286 * Parameters:
820
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6287 * pointer: Pointer to the allocated memory in dw_container_alloc().
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6288 * row: Zero based row of data being set.
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6289 * title: String title of the item.
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6290 */
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6291 void dw_container_set_row_title(void *pointer, int row, char *title)
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6292 {
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6293 _dw_container_set_row_data(pointer, pointer, row, _DW_DATA_TYPE_STRING, title);
820
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6294 }
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6295
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6296 /*
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6297 * Changes the title of a row already inserted in the container.
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6298 * Parameters:
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6299 * handle: Handle to window (widget) of container.
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6300 * row: Zero based row of data being set.
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6301 * title: String title of the item.
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6302 */
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6303 void dw_container_change_row_title(HWND handle, int row, char *title)
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6304 {
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6305 _dw_container_set_row_data(handle, NULL, row, _DW_DATA_TYPE_STRING, title);
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6306 }
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6307
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6308 /*
1875
fb137f7f91e4 Initial commit of GTK2 code changes (untested) ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1873
diff changeset
6309 * Sets the data of a row in the container.
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6310 * Parameters:
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6311 * pointer: Pointer to the allocated memory in dw_container_alloc().
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6312 * row: Zero based row of data being set.
1875
fb137f7f91e4 Initial commit of GTK2 code changes (untested) ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1873
diff changeset
6313 * data: Data pointer.
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6314 */
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6315 void dw_container_set_row_data(void *pointer, int row, void *data)
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6316 {
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6317 _dw_container_set_row_data(pointer, pointer, row, _DW_DATA_TYPE_POINTER, data);
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6318 }
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6319
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6320 /*
1875
fb137f7f91e4 Initial commit of GTK2 code changes (untested) ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1873
diff changeset
6321 * Changes the data of a row already inserted in the container.
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6322 * Parameters:
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6323 * handle: Handle to window (widget) of container.
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6324 * row: Zero based row of data being set.
1875
fb137f7f91e4 Initial commit of GTK2 code changes (untested) ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1873
diff changeset
6325 * data: Data pointer.
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6326 */
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6327 void dw_container_change_row_data(HWND handle, int row, void *data)
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6328 {
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6329 _dw_container_set_row_data(handle, NULL, row, _DW_DATA_TYPE_POINTER, data);
820
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6330 }
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6331
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6332 /*
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6333 * Sets the title of a row in the container.
19a632499344 GTK2/3 changes for similar dw_container_set_item() and dw_container_change_item() misbehavior.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 818
diff changeset
6334 * Parameters:
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6335 * handle: Handle to the container window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6336 * pointer: Pointer to the allocated memory in dw_container_alloc().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6337 * rowcount: The number of rows to be inserted.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6338 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6339 void dw_container_insert(HWND handle, void *pointer, int rowcount)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6340 {
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6341 /* Don't need to do anything here */
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6342 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6343
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6344 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6345 * Removes the first x rows from a container.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6346 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6347 * handle: Handle to the window (widget) to be deleted from.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6348 * rowcount: The number of rows to be deleted.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6349 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6350 void dw_container_delete(HWND handle, int rowcount)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6351 {
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6352 GtkWidget *cont;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6353 GtkListStore *store = NULL;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6354 int _locked_by_me = FALSE;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6355
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6356 DW_MUTEX_LOCK;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6357 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6358
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6359 /* Make sure it is the correct tree type */
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6360 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6361 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6362
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6363 if(store)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6364 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6365 GtkTreeIter iter;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6366 int rows, z;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6367
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
6368 rows = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), "_dw_rowcount"));
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6369
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6370 for(z=0;z<rowcount;z++)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6371 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6372 if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, 0))
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6373 gtk_list_store_remove(store, &iter);
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6374 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6375
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6376 if(rows - rowcount < 0)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6377 rows = 0;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6378 else
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6379 rows -= rowcount;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6380
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6381 g_object_set_data(G_OBJECT(cont), "_dw_rowcount", GINT_TO_POINTER(rows));
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6382 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6383 DW_MUTEX_UNLOCK;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6384 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6385
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6386 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6387 * Removes all rows from a container.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6388 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6389 * handle: Handle to the window (widget) to be cleared.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6390 * redraw: TRUE to cause the container to redraw immediately.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6391 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6392 void dw_container_clear(HWND handle, int redraw)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6393 {
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6394 GtkWidget *cont;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6395 GtkListStore *store = NULL;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6396 int _locked_by_me = FALSE;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6397
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6398 DW_MUTEX_LOCK;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6399 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6400
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6401 /* Make sure it is the correct tree type */
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6402 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6403 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6404
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6405 if(store)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6406 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6407 g_object_set_data(G_OBJECT(cont), "_dw_rowcount", GINT_TO_POINTER(0));
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6408 g_object_set_data(G_OBJECT(cont), "_dw_insertpos", GINT_TO_POINTER(0));
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6409
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6410 gtk_list_store_clear(store);
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6411 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6412 DW_MUTEX_UNLOCK;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6413 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6414
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6415 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6416 * Scrolls container up or down.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6417 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6418 * handle: Handle to the window (widget) to be scrolled.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6419 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6420 * DW_SCROLL_BOTTOM. (rows is ignored for last two)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6421 * rows: The number of rows to be scrolled.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6422 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6423 void dw_container_scroll(HWND handle, int direction, long rows)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6424 {
861
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6425 GtkWidget *cont;
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6426 int _locked_by_me = FALSE;
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6427
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6428 DW_MUTEX_LOCK;
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6429 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6430
861
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6431 /* Make sure it is the correct tree type */
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6432 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6433 {
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
6434 GtkAdjustment *adjust = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(cont));
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6435
861
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6436 if(adjust)
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6437 {
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
6438 gint rowcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), "_dw_rowcount"));
861
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6439 gdouble currpos = gtk_adjustment_get_value(adjust);
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6440 gdouble upper = gtk_adjustment_get_upper(adjust);
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6441 gdouble lower = gtk_adjustment_get_lower(adjust);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6442 gdouble change;
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6443
861
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6444 /* Safety check */
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6445 if(rowcount < 1)
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6446 {
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6447 DW_MUTEX_UNLOCK;
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6448 return;
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6449 }
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6450
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6451 change = ((gdouble)rows/(gdouble)rowcount) * (upper - lower);
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6452
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6453 switch(direction)
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6454 {
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6455 case DW_SCROLL_TOP:
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6456 {
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6457 gtk_adjustment_set_value(adjust, lower);
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6458 break;
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6459 }
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6460 case DW_SCROLL_BOTTOM:
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6461 {
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6462 gtk_adjustment_set_value(adjust, upper);
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6463 break;
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6464 }
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6465 case DW_SCROLL_UP:
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6466 {
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6467 gdouble newpos = currpos - change;
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6468 if(newpos < lower)
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6469 {
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6470 newpos = lower;
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6471 }
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6472 gtk_adjustment_set_value(adjust, newpos);
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6473 break;
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6474 }
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6475 case DW_SCROLL_DOWN:
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6476 {
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6477 gdouble newpos = currpos + change;
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6478 if(newpos > upper)
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6479 {
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6480 newpos = upper;
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6481 }
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6482 gtk_adjustment_set_value(adjust, newpos);
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6483 break;
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6484 }
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6485 }
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6486 }
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6487 }
8f2722696a8e Implemented dw_container_scroll() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6488 DW_MUTEX_UNLOCK;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6489 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6490
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6491 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6492 * Starts a new query of a container.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6493 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6494 * handle: Handle to the window (widget) to be queried.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6495 * flags: If this parameter is DW_CRA_SELECTED it will only
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6496 * return items that are currently selected. Otherwise
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6497 * it will return all records in the container.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6498 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6499 char *dw_container_query_start(HWND handle, unsigned long flags)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6500 {
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6501 GtkWidget *cont;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6502 GtkListStore *store = NULL;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6503 char *retval = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6504 int _locked_by_me = FALSE;
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6505 int type = flags & DW_CR_RETDATA ? _DW_DATA_TYPE_POINTER : _DW_DATA_TYPE_STRING;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6506
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6507 DW_MUTEX_LOCK;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6508 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6509
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6510 /* Make sure it is the correct tree type */
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6511 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6512 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6513
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6514 if(store)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6515 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6516 /* These should be separate but right now this will work */
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6517 if(flags & DW_CRA_SELECTED)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6518 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6519 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(cont));
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6520 GList *list = gtk_tree_selection_get_selected_rows(sel, NULL);
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6521 if(list)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6522 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6523 GtkTreePath *path = g_list_nth_data(list, 0);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6524
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6525 if(path)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6526 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6527 gint *indices = gtk_tree_path_get_indices(path);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6528
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6529 if(indices)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6530 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6531 GtkTreeIter iter;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6532
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6533 if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, indices[0]))
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6534 {
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6535 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, type, &retval, -1);
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6536 g_object_set_data(G_OBJECT(cont), "_dw_querypos", GINT_TO_POINTER(1));
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6537 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6538 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6539 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6540 g_list_foreach(list, (GFunc) gtk_tree_path_free, NULL);
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6541 g_list_free(list);
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6542 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6543 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6544 else if(flags & DW_CRA_CURSORED)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6545 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6546 GtkTreePath *path;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6547
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6548 gtk_tree_view_get_cursor(GTK_TREE_VIEW(cont), &path, NULL);
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6549 if(path)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6550 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6551 GtkTreeIter iter;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6552
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6553 if(gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path))
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6554 {
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6555 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, type, &retval, -1);
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6556 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6557 gtk_tree_path_free(path);
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6558 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6559 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6560 else
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6561 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6562 GtkTreeIter iter;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6563
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6564 if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, 0))
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6565 {
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6566 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, type, &retval, -1);
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6567 g_object_set_data(G_OBJECT(cont), "_dw_querypos", GINT_TO_POINTER(1));
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6568 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6569 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6570 }
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6571 /* If there is a title, duplicate it and free the temporary copy */
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6572 if(retval && type == _DW_DATA_TYPE_STRING)
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6573 {
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6574 char *temp = retval;
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6575 retval = strdup(temp);
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6576 g_free(temp);
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6577 }
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6578 DW_MUTEX_UNLOCK;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6579 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6580 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6581
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6582 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6583 * Continues an existing query of a container.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6584 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6585 * handle: Handle to the window (widget) to be queried.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6586 * flags: If this parameter is DW_CRA_SELECTED it will only
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6587 * return items that are currently selected. Otherwise
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6588 * it will return all records in the container.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6589 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6590 char *dw_container_query_next(HWND handle, unsigned long flags)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6591 {
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6592 GtkWidget *cont;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6593 GtkListStore *store = NULL;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6594 char *retval = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6595 int _locked_by_me = FALSE;
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6596 int type = flags & DW_CR_RETDATA ? _DW_DATA_TYPE_POINTER : _DW_DATA_TYPE_STRING;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6597
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6598 DW_MUTEX_LOCK;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6599 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6600
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6601 /* Make sure it is the correct tree type */
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6602 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6603 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6604
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6605 if(store)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6606 {
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
6607 int pos = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), "_dw_querypos"));
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6608 int count = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6609
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6610 /* These should be separate but right now this will work */
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6611 if(flags & DW_CRA_SELECTED)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6612 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6613 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(cont));
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6614 GList *list = gtk_tree_selection_get_selected_rows(sel, NULL);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6615
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6616 if(list)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6617 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6618 GtkTreePath *path = g_list_nth_data(list, pos);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6619
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6620 if(path)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6621 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6622 gint *indices = gtk_tree_path_get_indices(path);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6623
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6624 if(indices)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6625 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6626 GtkTreeIter iter;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6627
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6628 if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, indices[0]))
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6629 {
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6630 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, type, &retval, -1);
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6631 g_object_set_data(G_OBJECT(cont), "_dw_querypos", GINT_TO_POINTER(pos+1));
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6632 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6633 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6634 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6635 g_list_foreach(list, (GFunc) gtk_tree_path_free, NULL);
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6636 g_list_free(list);
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6637 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6638 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6639 else if(flags & DW_CRA_CURSORED)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6640 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6641 /* There will only be one item cursored,
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6642 * retrieve it with dw_container_query_start()
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6643 */
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6644 retval = NULL;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6645 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6646 else
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6647 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6648 GtkTreeIter iter;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6649
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6650 if(pos < count && gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, pos))
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6651 {
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6652 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, type, &retval, -1);
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6653 g_object_set_data(G_OBJECT(cont), "_dw_querypos", GINT_TO_POINTER(pos+1));
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6654 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6655 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6656 }
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6657 /* If there is a title, duplicate it and free the temporary copy */
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6658 if(retval && type == _DW_DATA_TYPE_STRING)
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6659 {
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6660 char *temp = retval;
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6661 retval = strdup(temp);
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6662 g_free(temp);
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6663 }
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6664 DW_MUTEX_UNLOCK;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6665 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6666 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6667
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6668 int _find_iter(GtkListStore *store, GtkTreeIter *iter, void *data, int textcomp)
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6669 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6670 int z, rows = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL);
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6671 void *thisdata;
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6672 int retval = FALSE;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6673
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6674 for(z=0;z<rows;z++)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6675 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6676 if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), iter, NULL, z))
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6677 {
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6678 /* Get either string from position 0 or pointer from position 1 */
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6679 gtk_tree_model_get(GTK_TREE_MODEL(store), iter, textcomp ? _DW_DATA_TYPE_STRING : _DW_DATA_TYPE_POINTER, &thisdata, -1);
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6680 if((textcomp && thisdata && strcmp((char *)thisdata, (char *)data) == 0) || (!textcomp && thisdata == data))
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6681 {
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6682 retval = TRUE;
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6683 z = rows;
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6684 }
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6685 if(textcomp && thisdata)
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6686 g_free(thisdata);
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6687 }
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6688 }
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
6689 return retval;
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6690 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6691
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6692 void _dw_container_cursor(HWND handle, void *data, int textcomp)
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6693 {
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6694 GtkWidget *cont;
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6695 GtkListStore *store = NULL;
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6696 int _locked_by_me = FALSE;
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6697
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6698 DW_MUTEX_LOCK;
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6699 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6700
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6701 /* Make sure it is the correct tree type */
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6702 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6703 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6704
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6705 if(store)
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6706 {
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6707 GtkTreeIter iter;
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6708
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6709 if(_find_iter(store, &iter, data, textcomp))
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6710 {
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6711 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6712
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6713 if(path)
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6714 {
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6715 gtk_tree_view_row_activated(GTK_TREE_VIEW(cont), path, NULL);
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6716 gtk_tree_path_free(path);
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6717 }
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6718 }
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6719 }
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6720 DW_MUTEX_UNLOCK;
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6721 }
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6722
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6723 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6724 * Cursors the item with the text speficied, and scrolls to that item.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6725 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6726 * handle: Handle to the window (widget) to be queried.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6727 * text: Text usually returned by dw_container_query().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6728 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6729 void dw_container_cursor(HWND handle, char *text)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6730 {
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6731 _dw_container_cursor(handle, text, TRUE);
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6732 }
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6733
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6734 /*
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6735 * Cursors the item with the text speficied, and scrolls to that item.
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6736 * Parameters:
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6737 * handle: Handle to the window (widget) to be queried.
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6738 * text: Text usually returned by dw_container_query().
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6739 */
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6740 void dw_container_cursor_by_data(HWND handle, void *data)
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6741 {
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6742 _dw_container_cursor(handle, data, FALSE);
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6743 }
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6744
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6745 void _dw_container_delete_row(HWND handle, void *data, int textcomp)
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6746 {
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6747 GtkWidget *cont;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6748 GtkListStore *store = NULL;
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6749 int _locked_by_me = FALSE;
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6750
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6751 DW_MUTEX_LOCK;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6752 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6753
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6754 /* Make sure it is the correct tree type */
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6755 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6756 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6757
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6758 if(store)
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6759 {
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6760 GtkTreeIter iter;
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6761 int rows = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), "_dw_rowcount"));
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6762
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6763 if(_find_iter(store, &iter, data, textcomp))
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6764 {
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6765 gtk_list_store_remove(store, &iter);
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6766 rows--;
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6767 }
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6768
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6769 g_object_set_data(G_OBJECT(cont), "_dw_rowcount", GINT_TO_POINTER(rows));
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6770 }
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6771 DW_MUTEX_UNLOCK;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6772 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6773
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6774 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6775 * Deletes the item with the text speficied.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6776 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6777 * handle: Handle to the window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6778 * text: Text usually returned by dw_container_query().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6779 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6780 void dw_container_delete_row(HWND handle, char *text)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6781 {
1873
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6782 _dw_container_delete_row(handle, text, TRUE);
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6783 }
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6784
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6785 /*
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6786 * Deletes the item with the text speficied.
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6787 * Parameters:
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6788 * handle: Handle to the window (widget).
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6789 * text: Text usually returned by dw_container_query().
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6790 */
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6791 void dw_container_delete_row_by_data(HWND handle, void *data)
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6792 {
15d24b5300ec Third GTK3 round of changes to split string and data
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
6793 _dw_container_delete_row(handle, data, FALSE);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6794 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6795
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6796 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6797 * Optimizes the column widths so that all data is visible.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6798 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6799 * handle: Handle to the window (widget) to be optimized.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6800 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6801 void dw_container_optimize(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6802 {
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6803 GtkWidget *cont;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6804 int _locked_by_me = FALSE;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6805
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6806 DW_MUTEX_LOCK;
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6807 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6808
782
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6809 /* Make sure it is the correct tree type */
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6810 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6811 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(cont));
5a4bfe989f50 Most of the dw_container_* functions now implemented but many untested.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 781
diff changeset
6812 DW_MUTEX_UNLOCK;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6813 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6814
1223
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6815 /* Translate the status message into a message on our buddy window */
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6816 static void _status_translate(GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data)
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6817 {
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6818 GdkEventButton event = { 0 };
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6819 long x, y;
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6820 gboolean retval;
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6821
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6822 dw_pointer_query_pos(&x, &y);
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6823
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6824 event.button = button;
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6825 event.x = x;
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6826 event.y = y;
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6827
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6828 g_signal_emit_by_name(G_OBJECT(user_data), "button_press_event", &event, &retval);
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6829 }
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6830
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6831 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6832 * Inserts an icon into the taskbar.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6833 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6834 * handle: Window handle that will handle taskbar icon messages.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6835 * icon: Icon handle to display in the taskbar.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6836 * bubbletext: Text to show when the mouse is above the icon.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6837 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6838 void dw_taskbar_insert(HWND handle, HICN icon, char *bubbletext)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6839 {
1223
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6840 GtkStatusIcon *status;
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6841 GdkPixbuf *pixbuf;
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6842 int _locked_by_me = FALSE;
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6843
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6844 DW_MUTEX_LOCK;
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6845 pixbuf = _find_pixbuf(icon, NULL, NULL);
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6846 status = gtk_status_icon_new_from_pixbuf(pixbuf);
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6847 if(bubbletext)
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6848 gtk_status_icon_set_tooltip_text(status, bubbletext);
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6849 g_object_set_data(G_OBJECT(handle), "_dw_taskbar", status);
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6850 g_signal_connect(G_OBJECT (status), "popup-menu", G_CALLBACK (_status_translate), handle);
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6851 gtk_status_icon_set_visible(status, TRUE);
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6852 DW_MUTEX_UNLOCK;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6853 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6854
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6855 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6856 * Deletes an icon from the taskbar.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6857 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6858 * handle: Window handle that was used with dw_taskbar_insert().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6859 * icon: Icon handle that was used with dw_taskbar_insert().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6860 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6861 void dw_taskbar_delete(HWND handle, HICN icon)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6862 {
1223
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6863 GtkStatusIcon *status;
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6864 int _locked_by_me = FALSE;
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6865
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6866 DW_MUTEX_LOCK;
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6867 status = g_object_get_data(G_OBJECT(handle), "_dw_taskbar");
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6868 g_object_unref(G_OBJECT(status));
1255ba41adad Added taskbar support for GTK...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6869 DW_MUTEX_UNLOCK;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6870 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6871
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6872 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6873 * Creates a rendering context widget (window) to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6874 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6875 * id: An id to be used with dw_window_from_id.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6876 * Returns:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6877 * A handle to the widget or NULL on failure.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6878 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6879 HWND dw_render_new(unsigned long id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6880 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6881 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6882 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6883
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6884 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6885 tmp = gtk_drawing_area_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6886 gtk_widget_set_events(tmp, GDK_EXPOSURE_MASK
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6887 | GDK_LEAVE_NOTIFY_MASK
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6888 | GDK_BUTTON_PRESS_MASK
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6889 | GDK_BUTTON_RELEASE_MASK
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6890 | GDK_KEY_PRESS_MASK
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6891 | GDK_POINTER_MOTION_MASK
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6892 | GDK_POINTER_MOTION_HINT_MASK);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6893 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6894 gtk_widget_set_can_focus(tmp, TRUE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6895 gtk_widget_show(tmp);
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
6896 if(_DWDefaultFont)
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
6897 dw_window_set_font(tmp, _DWDefaultFont);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6898 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6899 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6900 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6901
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
6902 /* Returns a GdkRGBA from a DW color */
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
6903 static GdkRGBA _internal_color(unsigned long value)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6904 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6905 if(DW_RGB_COLOR & value)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6906 {
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
6907 GdkRGBA color = { (gfloat)DW_RED_VALUE(value) / 255.0, (gfloat)DW_GREEN_VALUE(value) / 255.0, (gfloat)DW_BLUE_VALUE(value) / 255.0, 1.0 };
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6908 return color;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6909 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6910 if (value < 16)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6911 return _colors[value];
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6912 return _colors[0];
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6913 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6914
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6915 /* Sets the current foreground drawing color.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6916 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6917 * red: red value.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6918 * green: green value.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6919 * blue: blue value.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6920 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6921 void dw_color_foreground_set(unsigned long value)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6922 {
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
6923 GdkRGBA color = _internal_color(value);
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
6924 GdkRGBA *foreground = pthread_getspecific(_dw_fg_color_key);
971
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
6925
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
6926 *foreground = color;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6927 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6928
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6929 /* Sets the current background drawing color.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6930 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6931 * red: red value.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6932 * green: green value.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6933 * blue: blue value.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6934 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6935 void dw_color_background_set(unsigned long value)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6936 {
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
6937 GdkRGBA *background = pthread_getspecific(_dw_bg_color_key);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
6938
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6939 if(value == DW_CLR_DEFAULT)
971
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
6940 {
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
6941 if(background)
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
6942 {
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
6943 pthread_setspecific(_dw_bg_color_key, NULL);
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
6944 free(background);
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
6945 }
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
6946 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6947 else
971
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
6948 {
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
6949 GdkRGBA color = _internal_color(value);
971
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
6950
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
6951 if(!background)
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
6952 {
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
6953 background = malloc(sizeof(GdkRGBA));
972
32830f1683c9 Fixed an issue where dw_color_background_set() would not function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 971
diff changeset
6954 pthread_setspecific(_dw_bg_color_key, background);
971
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
6955 }
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
6956 *background = color;
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
6957 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6958 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6959
1597
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6960 #if GTK_CHECK_VERSION(3,3,11)
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6961 /* Allows the user to choose a color using the system's color chooser dialog.
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6962 * Parameters:
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6963 * value: current color
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6964 * Returns:
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6965 * The selected color or the current color if cancelled.
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6966 */
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6967 unsigned long API dw_color_choose(unsigned long value)
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6968 {
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6969 GtkColorChooser *cd;
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6970 GdkRGBA color = _internal_color(value);
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6971 int _locked_by_me = FALSE;
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6972 unsigned long retcolor = value;
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6973
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6974 DW_MUTEX_LOCK;
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6975 cd = (GtkColorChooser *)gtk_color_chooser_dialog_new("Choose color", NULL);
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6976 gtk_color_chooser_set_use_alpha(cd, FALSE);
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6977 gtk_color_chooser_set_rgba(cd, &color);
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6978
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6979 gtk_widget_show(GTK_WIDGET(cd));
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6980
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6981 if(gtk_dialog_run(GTK_DIALOG(cd)) == GTK_RESPONSE_OK)
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6982 {
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6983 gtk_color_chooser_get_rgba(cd, &color);
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6984 retcolor = DW_RGB((int)(color.red * 255), (int)(color.green * 255), (int)(color.blue * 255));
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6985 }
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6986 gtk_widget_destroy(GTK_WIDGET(cd));
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6987 DW_MUTEX_UNLOCK;
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6988 return retcolor;
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6989 }
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6990 #else
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6991 static int _dw_color_active = 0;
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
6992
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6993 /* Internal function to handle the color OK press */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6994 static gint _gtk_color_ok(GtkWidget *widget, DWDialog *dwwait)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6995 {
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
6996 GdkRGBA color;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6997 unsigned long dw_color;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6998 GtkColorSelection *colorsel;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6999
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7000 if(!dwwait)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7001 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7002
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7003 colorsel = (GtkColorSelection *)gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(dwwait->data));
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7004 gtk_color_selection_get_current_rgba(colorsel, &color);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7005 gtk_widget_destroy(GTK_WIDGET(dwwait->data));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7006 _dw_color_active = 0;
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7007 dw_color = DW_RGB((int)(color.red * 255), (int)(color.green * 255), (int)(color.blue * 255));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7008 dw_dialog_dismiss(dwwait, (void *)dw_color);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7009 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7010 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7011
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7012 /* Internal function to handle the color Cancel press */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7013 static gint _gtk_color_cancel(GtkWidget *widget, DWDialog *dwwait)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7014 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7015 if(!dwwait)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7016 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7017
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7018 gtk_widget_destroy(GTK_WIDGET(dwwait->data));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7019 _dw_color_active = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7020 dw_dialog_dismiss(dwwait, (void *)-1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7021 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7022 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7023
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7024 /* Allows the user to choose a color using the system's color chooser dialog.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7025 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7026 * value: current color
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7027 * Returns:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7028 * The selected color or the current color if cancelled.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7029 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7030 unsigned long API dw_color_choose(unsigned long value)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7031 {
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
7032 GtkWidget *colorw, *ok_button, *cancel_button;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7033 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7034 DWDialog *dwwait;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7035 GtkColorSelection *colorsel;
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7036 GdkRGBA color = _internal_color(value);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7037 unsigned long dw_color;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7038
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7039 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7040
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7041 /* The DW mutex should be sufficient for
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7042 * insuring no thread changes this unknowingly.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7043 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7044 if(_dw_color_active)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7045 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7046 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7047 return value;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7048 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7049
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7050 _dw_color_active = 1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7051
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7052 colorw = gtk_color_selection_dialog_new("Select Color");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7053
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7054 dwwait = dw_dialog_new((void *)colorw);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7055
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7056 colorsel = (GtkColorSelection *)gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(colorw));
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
7057 g_object_get(G_OBJECT(colorw), "ok-button", &ok_button, "cancel-button", &cancel_button, NULL);
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
7058 g_signal_connect(G_OBJECT(ok_button), "clicked", G_CALLBACK(_gtk_color_ok), dwwait);
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
7059 g_signal_connect(G_OBJECT(cancel_button), "clicked", G_CALLBACK(_gtk_color_cancel), dwwait);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7060
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7061 gtk_color_selection_set_previous_rgba(colorsel,&color);
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7062 gtk_color_selection_set_current_rgba(colorsel,&color);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7063 gtk_color_selection_set_has_palette(colorsel,TRUE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7064
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7065 gtk_widget_show(colorw);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7066
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7067 dw_color = (unsigned long)dw_dialog_wait(dwwait);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7068 if ((unsigned long)dw_color == -1)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7069 dw_color = value;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7070 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7071 return (unsigned long)dw_color;
1597
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
7072 }
ed09531b7f0e Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1583
diff changeset
7073 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7074
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7075 /* Draw a point on a window (preferably a render window).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7076 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7077 * handle: Handle to the window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7078 * pixmap: Handle to the pixmap. (choose only one of these)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7079 * x: X coordinate.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7080 * y: Y coordinate.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7081 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7082 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7083 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7084 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7085 cairo_t *cr = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7086
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7087 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7088 if(handle)
818
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7089 {
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7090 GdkWindow *window = gtk_widget_get_window(handle);
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7091 /* Safety check for non-existant windows */
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7092 if(!window || !GDK_IS_WINDOW(window))
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7093 {
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7094 DW_MUTEX_UNLOCK;
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7095 return;
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7096 }
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7097 cr = gdk_cairo_create(window);
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7098 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7099 else if(pixmap)
815
c1e93dd575a5 Initial implementation of a slightly disjointed dual cairo_surface gdkpixbuf image model.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 814
diff changeset
7100 cr = cairo_create(pixmap->image);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7101 if(cr)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7102 {
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7103 GdkRGBA *foreground = pthread_getspecific(_dw_fg_color_key);
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7104
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7105 gdk_cairo_set_source_rgba(cr, foreground);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7106 cairo_set_line_width(cr, 1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7107 cairo_move_to(cr, x, y);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7108 cairo_stroke(cr);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7109 cairo_destroy(cr);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7110 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7111 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7112 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7113
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7114 /* Draw a line on a window (preferably a render window).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7115 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7116 * handle: Handle to the window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7117 * pixmap: Handle to the pixmap. (choose only one of these)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7118 * x1: First X coordinate.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7119 * y1: First Y coordinate.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7120 * x2: Second X coordinate.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7121 * y2: Second Y coordinate.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7122 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7123 void dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7124 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7125 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7126 cairo_t *cr = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7127
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7128 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7129 if(handle)
818
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7130 {
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7131 GdkWindow *window = gtk_widget_get_window(handle);
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7132 /* Safety check for non-existant windows */
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7133 if(!window || !GDK_IS_WINDOW(window))
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7134 {
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7135 DW_MUTEX_UNLOCK;
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7136 return;
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7137 }
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7138 cr = gdk_cairo_create(window);
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7139 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7140 else if(pixmap)
815
c1e93dd575a5 Initial implementation of a slightly disjointed dual cairo_surface gdkpixbuf image model.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 814
diff changeset
7141 cr = cairo_create(pixmap->image);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7142 if(cr)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7143 {
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7144 GdkRGBA *foreground = pthread_getspecific(_dw_fg_color_key);
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7145
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7146 gdk_cairo_set_source_rgba(cr, foreground);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7147 cairo_set_line_width(cr, 1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7148 cairo_move_to(cr, x1, y1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7149 cairo_line_to(cr, x2, y2);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7150 cairo_stroke(cr);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7151 cairo_destroy(cr);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7152 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7153 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7154 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7155
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7156 /* Draw a closed polygon on a window (preferably a render window).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7157 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7158 * handle: Handle to the window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7159 * pixmap: Handle to the pixmap. (choose only one of these)
1275
0b34e2cf0706 Updated dw_draw_rect and dw_draw_polygon to accept flags the same way as dw_draw_arc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1271
diff changeset
7160 * flags: DW_DRAW_FILL (1) to fill the polygon or DW_DRAW_DEFAULT (0).
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7161 * number of points
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7162 * x[]: X coordinates.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7163 * y[]: Y coordinates.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7164 */
1275
0b34e2cf0706 Updated dw_draw_rect and dw_draw_polygon to accept flags the same way as dw_draw_arc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1271
diff changeset
7165 void dw_draw_polygon(HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7166 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7167 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7168 cairo_t *cr = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7169 int z;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7170
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7171 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7172 if(handle)
818
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7173 {
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7174 GdkWindow *window = gtk_widget_get_window(handle);
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7175 /* Safety check for non-existant windows */
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7176 if(!window || !GDK_IS_WINDOW(window))
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7177 {
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7178 DW_MUTEX_UNLOCK;
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7179 return;
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7180 }
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7181 cr = gdk_cairo_create(window);
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7182 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7183 else if(pixmap)
815
c1e93dd575a5 Initial implementation of a slightly disjointed dual cairo_surface gdkpixbuf image model.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 814
diff changeset
7184 cr = cairo_create(pixmap->image);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7185 if(cr)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7186 {
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7187 GdkRGBA *foreground = pthread_getspecific(_dw_fg_color_key);
1524
010e1d916ee7 Added DW_DRAW_NOAA support on GTK3 for both pixmaps and windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1510
diff changeset
7188
010e1d916ee7 Added DW_DRAW_NOAA support on GTK3 for both pixmaps and windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1510
diff changeset
7189 if(flags & DW_DRAW_NOAA)
010e1d916ee7 Added DW_DRAW_NOAA support on GTK3 for both pixmaps and windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1510
diff changeset
7190 cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
010e1d916ee7 Added DW_DRAW_NOAA support on GTK3 for both pixmaps and windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1510
diff changeset
7191
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7192 gdk_cairo_set_source_rgba(cr, foreground);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7193 cairo_set_line_width(cr, 1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7194 cairo_move_to(cr, x[0], y[0]);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7195 for(z=1;z<npoints;z++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7196 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7197 cairo_line_to(cr, x[z], y[z]);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7198 }
1275
0b34e2cf0706 Updated dw_draw_rect and dw_draw_polygon to accept flags the same way as dw_draw_arc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1271
diff changeset
7199 if(flags & DW_DRAW_FILL)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7200 cairo_fill(cr);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7201 cairo_stroke(cr);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7202 cairo_destroy(cr);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7203 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7204 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7205 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7206
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7207 /* Draw a rectangle on a window (preferably a render window).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7208 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7209 * handle: Handle to the window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7210 * pixmap: Handle to the pixmap. (choose only one of these)
1275
0b34e2cf0706 Updated dw_draw_rect and dw_draw_polygon to accept flags the same way as dw_draw_arc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1271
diff changeset
7211 * flags: DW_DRAW_FILL (1) to fill the box or DW_DRAW_DEFAULT (0).
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7212 * x: X coordinate.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7213 * y: Y coordinate.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7214 * width: Width of rectangle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7215 * height: Height of rectangle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7216 */
1275
0b34e2cf0706 Updated dw_draw_rect and dw_draw_polygon to accept flags the same way as dw_draw_arc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1271
diff changeset
7217 void dw_draw_rect(HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7218 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7219 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7220 cairo_t *cr = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7221
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7222 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7223 if(handle)
818
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7224 {
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7225 GdkWindow *window = gtk_widget_get_window(handle);
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7226 /* Safety check for non-existant windows */
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7227 if(!window || !GDK_IS_WINDOW(window))
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7228 {
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7229 DW_MUTEX_UNLOCK;
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7230 return;
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7231 }
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7232 cr = gdk_cairo_create(window);
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7233 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7234 else if(pixmap)
815
c1e93dd575a5 Initial implementation of a slightly disjointed dual cairo_surface gdkpixbuf image model.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 814
diff changeset
7235 cr = cairo_create(pixmap->image);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7236 if(cr)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7237 {
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7238 GdkRGBA *foreground = pthread_getspecific(_dw_fg_color_key);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
7239
1524
010e1d916ee7 Added DW_DRAW_NOAA support on GTK3 for both pixmaps and windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1510
diff changeset
7240 if(flags & DW_DRAW_NOAA)
010e1d916ee7 Added DW_DRAW_NOAA support on GTK3 for both pixmaps and windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1510
diff changeset
7241 cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
010e1d916ee7 Added DW_DRAW_NOAA support on GTK3 for both pixmaps and windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1510
diff changeset
7242
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7243 gdk_cairo_set_source_rgba(cr, foreground);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7244 cairo_set_line_width(cr, 1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7245 cairo_move_to(cr, x, y);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7246 cairo_line_to(cr, x, y + height);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7247 cairo_line_to(cr, x + width, y + height);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7248 cairo_line_to(cr, x + width, y);
1275
0b34e2cf0706 Updated dw_draw_rect and dw_draw_polygon to accept flags the same way as dw_draw_arc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1271
diff changeset
7249 if(flags & DW_DRAW_FILL)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7250 cairo_fill(cr);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7251 cairo_stroke(cr);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7252 cairo_destroy(cr);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7253 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7254 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7255 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7256
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7257 /* Draw an arc on a window (preferably a render window).
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7258 * Parameters:
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7259 * handle: Handle to the window.
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7260 * pixmap: Handle to the pixmap. (choose only one of these)
1275
0b34e2cf0706 Updated dw_draw_rect and dw_draw_polygon to accept flags the same way as dw_draw_arc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1271
diff changeset
7261 * flags: DW_DRAW_FILL (1) to fill the arc or DW_DRAW_DEFAULT (0).
0b34e2cf0706 Updated dw_draw_rect and dw_draw_polygon to accept flags the same way as dw_draw_arc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1271
diff changeset
7262 * DW_DRAW_FULL will draw a complete circle/elipse.
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7263 * xorigin: X coordinate of center of arc.
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7264 * yorigin: Y coordinate of center of arc.
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7265 * x1: X coordinate of first segment of arc.
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7266 * y1: Y coordinate of first segment of arc.
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7267 * x2: X coordinate of second segment of arc.
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7268 * y2: Y coordinate of second segment of arc.
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7269 */
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7270 void API dw_draw_arc(HWND handle, HPIXMAP pixmap, int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2)
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7271 {
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7272 int _locked_by_me = FALSE;
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7273 cairo_t *cr = NULL;
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7274
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7275 DW_MUTEX_LOCK;
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7276 if(handle)
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7277 {
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7278 GdkWindow *window = gtk_widget_get_window(handle);
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7279 /* Safety check for non-existant windows */
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7280 if(!window || !GDK_IS_WINDOW(window))
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7281 {
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7282 DW_MUTEX_UNLOCK;
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7283 return;
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7284 }
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7285 cr = gdk_cairo_create(window);
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7286 }
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7287 else if(pixmap)
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7288 cr = cairo_create(pixmap->image);
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7289 if(cr)
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7290 {
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7291 GdkRGBA *foreground = pthread_getspecific(_dw_fg_color_key);
1634
c3e08322b8f6 Fixed issues drawing arcs on GTK3 and GTK2 for printing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1597
diff changeset
7292 int width = abs(x2-x1);
c3e08322b8f6 Fixed issues drawing arcs on GTK3 and GTK2 for printing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1597
diff changeset
7293 float scale = fabs((float)(y2-y1))/(float)width;
1524
010e1d916ee7 Added DW_DRAW_NOAA support on GTK3 for both pixmaps and windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1510
diff changeset
7294
010e1d916ee7 Added DW_DRAW_NOAA support on GTK3 for both pixmaps and windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1510
diff changeset
7295 if(flags & DW_DRAW_NOAA)
010e1d916ee7 Added DW_DRAW_NOAA support on GTK3 for both pixmaps and windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1510
diff changeset
7296 cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
010e1d916ee7 Added DW_DRAW_NOAA support on GTK3 for both pixmaps and windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1510
diff changeset
7297
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7298 gdk_cairo_set_source_rgba(cr, foreground);
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7299 cairo_set_line_width(cr, 1);
1283
87d6d11b6323 Initial support for ellipses on GTK3 and GTK2 Printing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1281
diff changeset
7300 if(scale != 1.0)
87d6d11b6323 Initial support for ellipses on GTK3 and GTK2 Printing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1281
diff changeset
7301 cairo_scale(cr, 1.0, scale);
1271
8655753e2bc4 Implemented DW_DRAW_FULL and DW_DRAW_FILL for GTK3 and GTK2 printing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1266
diff changeset
7302 if(flags & DW_DRAW_FULL)
1634
c3e08322b8f6 Fixed issues drawing arcs on GTK3 and GTK2 for printing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1597
diff changeset
7303 cairo_arc(cr, xorigin, yorigin / scale, width/2, 0, M_PI*2);
1271
8655753e2bc4 Implemented DW_DRAW_FULL and DW_DRAW_FILL for GTK3 and GTK2 printing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1266
diff changeset
7304 else
1634
c3e08322b8f6 Fixed issues drawing arcs on GTK3 and GTK2 for printing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1597
diff changeset
7305 {
c3e08322b8f6 Fixed issues drawing arcs on GTK3 and GTK2 for printing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1597
diff changeset
7306 double dx = xorigin - x1;
c3e08322b8f6 Fixed issues drawing arcs on GTK3 and GTK2 for printing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1597
diff changeset
7307 double dy = yorigin - y1;
c3e08322b8f6 Fixed issues drawing arcs on GTK3 and GTK2 for printing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1597
diff changeset
7308 double r = sqrt(dx*dx + dy*dy);
c3e08322b8f6 Fixed issues drawing arcs on GTK3 and GTK2 for printing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1597
diff changeset
7309 double a1 = atan2((y1-yorigin), (x1-xorigin));
c3e08322b8f6 Fixed issues drawing arcs on GTK3 and GTK2 for printing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1597
diff changeset
7310 double a2 = atan2((y2-yorigin), (x2-xorigin));
c3e08322b8f6 Fixed issues drawing arcs on GTK3 and GTK2 for printing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1597
diff changeset
7311
1271
8655753e2bc4 Implemented DW_DRAW_FULL and DW_DRAW_FILL for GTK3 and GTK2 printing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1266
diff changeset
7312 cairo_arc(cr, xorigin, yorigin, r, a1, a2);
1634
c3e08322b8f6 Fixed issues drawing arcs on GTK3 and GTK2 for printing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1597
diff changeset
7313 }
1271
8655753e2bc4 Implemented DW_DRAW_FULL and DW_DRAW_FILL for GTK3 and GTK2 printing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1266
diff changeset
7314 if(flags & DW_DRAW_FILL)
8655753e2bc4 Implemented DW_DRAW_FULL and DW_DRAW_FILL for GTK3 and GTK2 printing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1266
diff changeset
7315 cairo_fill(cr);
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7316 cairo_stroke(cr);
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7317 cairo_destroy(cr);
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7318 }
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7319 DW_MUTEX_UNLOCK;
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7320 }
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1258
diff changeset
7321
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7322 /* Draw text on a window (preferably a render window).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7323 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7324 * handle: Handle to the window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7325 * pixmap: Handle to the pixmap. (choose only one of these)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7326 * x: X coordinate.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7327 * y: Y coordinate.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7328 * text: Text to be displayed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7329 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7330 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7331 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7332 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7333 cairo_t *cr = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7334 PangoFontDescription *font;
1232
db21c0081387 Fixes for dw_font_text_extents_get() on GTK not honoring the font set by dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1223
diff changeset
7335 char *tmpname, *fontname = "monospace 10";
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7336
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7337 if(!text)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7338 return;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
7339
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7340 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7341 if(handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7342 {
818
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7343 GdkWindow *window = gtk_widget_get_window(handle);
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7344 /* Safety check for non-existant windows */
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7345 if(!window || !GDK_IS_WINDOW(window))
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7346 {
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7347 DW_MUTEX_UNLOCK;
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7348 return;
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7349 }
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7350 cr = gdk_cairo_create(window);
1148
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7351 if((tmpname = (char *)g_object_get_data(G_OBJECT(handle), "_dw_fontname")))
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7352 fontname = tmpname;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7353 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7354 else if(pixmap)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7355 {
1148
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7356 if(pixmap->font)
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7357 fontname = pixmap->font;
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7358 else if(pixmap->handle && (tmpname = (char *)g_object_get_data(G_OBJECT(pixmap->handle), "_dw_fontname")))
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7359 fontname = tmpname;
815
c1e93dd575a5 Initial implementation of a slightly disjointed dual cairo_surface gdkpixbuf image model.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 814
diff changeset
7360 cr = cairo_create(pixmap->image);
c1e93dd575a5 Initial implementation of a slightly disjointed dual cairo_surface gdkpixbuf image model.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 814
diff changeset
7361 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7362 if(cr)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7363 {
1148
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7364 font = pango_font_description_from_string(fontname);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7365 if(font)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7366 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7367 PangoContext *context = pango_cairo_create_context(cr);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7368
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7369 if(context)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7370 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7371 PangoLayout *layout = pango_layout_new(context);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7372
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7373 if(layout)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7374 {
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7375 GdkRGBA *foreground = pthread_getspecific(_dw_fg_color_key);
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7376 GdkRGBA *background = pthread_getspecific(_dw_bg_color_key);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7377
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7378 pango_layout_set_font_description(layout, font);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7379 pango_layout_set_text(layout, text, strlen(text));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7380
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7381 gdk_cairo_set_source_rgba(cr, foreground);
892
82f68adde8a0 Fix for dw_draw_text() not using the background color on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 885
diff changeset
7382 /* Create a background color attribute if required */
971
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
7383 if(background)
892
82f68adde8a0 Fix for dw_draw_text() not using the background color on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 885
diff changeset
7384 {
82f68adde8a0 Fix for dw_draw_text() not using the background color on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 885
diff changeset
7385 PangoAttrList *list = pango_layout_get_attributes(layout);
1554
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7386 PangoAttribute *attr = pango_attr_background_new((guint16)(background->red * 65535),
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7387 (guint16)(background->green * 65535),
e39e9e67110d Switched to using GdkRGBA from GdkColor int GTK3 since the GdkColor APIs
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1545
diff changeset
7388 (guint16)(background->blue* 65535));
892
82f68adde8a0 Fix for dw_draw_text() not using the background color on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 885
diff changeset
7389 if(!list)
82f68adde8a0 Fix for dw_draw_text() not using the background color on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 885
diff changeset
7390 {
82f68adde8a0 Fix for dw_draw_text() not using the background color on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 885
diff changeset
7391 list = pango_attr_list_new();
82f68adde8a0 Fix for dw_draw_text() not using the background color on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 885
diff changeset
7392 }
82f68adde8a0 Fix for dw_draw_text() not using the background color on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 885
diff changeset
7393 pango_attr_list_change(list, attr);
82f68adde8a0 Fix for dw_draw_text() not using the background color on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 885
diff changeset
7394 pango_layout_set_attributes(layout, list);
82f68adde8a0 Fix for dw_draw_text() not using the background color on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 885
diff changeset
7395 }
82f68adde8a0 Fix for dw_draw_text() not using the background color on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 885
diff changeset
7396 /* Do the drawing */
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7397 cairo_move_to(cr, x, y);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7398 pango_cairo_show_layout (cr, layout);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
7399
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7400 g_object_unref(layout);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7401 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7402 g_object_unref(context);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7403 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7404 pango_font_description_free(font);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7405 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7406 cairo_destroy(cr);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7407 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7408 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7409 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7410
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7411 /* Query the width and height of a text string.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7412 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7413 * handle: Handle to the window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7414 * pixmap: Handle to the pixmap. (choose only one of these)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7415 * text: Text to be queried.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7416 * width: Pointer to a variable to be filled in with the width.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7417 * height Pointer to a variable to be filled in with the height.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7418 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7419 void dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7420 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7421 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7422 PangoFontDescription *font;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7423 char *fontname = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7424 int free_fontname = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7425
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7426 if(!text)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7427 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7428
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7429 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7430 if(handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7431 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7432 fontname = (char *)g_object_get_data(G_OBJECT(handle), "_dw_fontname");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7433 if ( fontname == NULL )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7434 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7435 fontname = dw_window_get_font(handle);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7436 free_fontname = 1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7437 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7438 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7439 else if(pixmap)
1232
db21c0081387 Fixes for dw_font_text_extents_get() on GTK not honoring the font set by dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1223
diff changeset
7440 {
db21c0081387 Fixes for dw_font_text_extents_get() on GTK not honoring the font set by dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1223
diff changeset
7441 if(pixmap->font)
db21c0081387 Fixes for dw_font_text_extents_get() on GTK not honoring the font set by dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1223
diff changeset
7442 fontname = pixmap->font;
db21c0081387 Fixes for dw_font_text_extents_get() on GTK not honoring the font set by dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1223
diff changeset
7443 else if(pixmap->handle)
db21c0081387 Fixes for dw_font_text_extents_get() on GTK not honoring the font set by dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1223
diff changeset
7444 fontname = (char *)g_object_get_data(G_OBJECT(pixmap->handle), "_dw_fontname");
db21c0081387 Fixes for dw_font_text_extents_get() on GTK not honoring the font set by dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1223
diff changeset
7445 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7446
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7447 font = pango_font_description_from_string(fontname ? fontname : "monospace 10");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7448 if(font)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7449 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7450 PangoContext *context = gdk_pango_context_get();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7451
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7452 if(context)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7453 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7454 PangoLayout *layout = pango_layout_new(context);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7455
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7456 if(layout)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7457 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7458 PangoRectangle rect;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7459
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7460 pango_layout_set_font_description(layout, font);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7461 pango_layout_set_text(layout, text, -1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7462 pango_layout_get_pixel_extents(layout, NULL, &rect);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7463
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7464 if(width)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7465 *width = rect.width;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7466 if(height)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7467 *height = rect.height;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7468
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7469 g_object_unref(layout);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7470 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7471 g_object_unref(context);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7472 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7473 pango_font_description_free(font);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7474 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7475 if ( free_fontname )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7476 free( fontname );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7477 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7478 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7479
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7480 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7481 * Creates a pixmap with given parameters.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7482 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7483 * handle: Window handle the pixmap is associated with.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7484 * or zero to enable this pixmap to be written
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7485 * off the screen to reduce flicker
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7486 * width: Width of the pixmap in pixels.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7487 * height: Height of the pixmap in pixels.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7488 * depth: Color depth of the pixmap.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7489 * Returns:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7490 * A handle to a pixmap or NULL on failure.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7491 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7492 HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7493 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7494 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7495 HPIXMAP pixmap;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7496
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7497 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7498 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7499
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7500 if (!depth)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7501 depth = -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7502
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7503 pixmap->width = width; pixmap->height = height;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7504
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7505
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7506 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7507 pixmap->handle = handle;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7508 /* Depth needs to be divided by 3... but for the RGB colorspace...
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7509 * only 8 bits per sample is allowed, so to avoid issues just pass 8 for now.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7510 */
815
c1e93dd575a5 Initial implementation of a slightly disjointed dual cairo_surface gdkpixbuf image model.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 814
diff changeset
7511 pixmap->pixbuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, FALSE, 8, width, height );
c1e93dd575a5 Initial implementation of a slightly disjointed dual cairo_surface gdkpixbuf image model.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 814
diff changeset
7512 pixmap->image = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7513 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7514 return pixmap;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7515 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7516
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7517 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7518 * Creates a pixmap from a file.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7519 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7520 * handle: Window handle the pixmap is associated with.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7521 * filename: Name of the file, omit extention to have
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7522 * DW pick the appropriate file extension.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7523 * (BMP on OS/2 or Windows, XPM on Unix)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7524 * Returns:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7525 * A handle to a pixmap or NULL on failure.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7526 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7527 HPIXMAP dw_pixmap_new_from_file(HWND handle, char *filename)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7528 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7529 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7530 HPIXMAP pixmap;
1258
3df86772b625 Updated the list of supported image formats for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1245
diff changeset
7531 char *file = alloca(strlen(filename) + 6);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7532 int found_ext = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7533 int i;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7534
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7535 if (!file || !(pixmap = calloc(1,sizeof(struct _hpixmap))))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7536 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7537
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7538 strcpy(file, filename);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7539
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7540 /* check if we can read from this file (it exists and read permission) */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7541 if(access(file, 04) != 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7542 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7543 /* Try with various extentions */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7544 for ( i = 0; i < NUM_EXTS; i++ )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7545 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7546 strcpy( file, filename );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7547 strcat( file, image_exts[i] );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7548 if ( access( file, 04 ) == 0 )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7549 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7550 found_ext = 1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7551 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7552 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7553 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7554 if ( found_ext == 0 )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7555 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7556 free(pixmap);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7557 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7558 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7559 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7560
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7561 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7562 pixmap->pixbuf = gdk_pixbuf_new_from_file(file, NULL);
815
c1e93dd575a5 Initial implementation of a slightly disjointed dual cairo_surface gdkpixbuf image model.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 814
diff changeset
7563 pixmap->image = cairo_image_surface_create_from_png(file);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7564 pixmap->width = gdk_pixbuf_get_width(pixmap->pixbuf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7565 pixmap->height = gdk_pixbuf_get_height(pixmap->pixbuf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7566 pixmap->handle = handle;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7567 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7568 return pixmap;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7569 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7570
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7571 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7572 * Creates a pixmap from data
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7573 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7574 * handle: Window handle the pixmap is associated with.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7575 * data: Source of image data
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7576 * DW pick the appropriate file extension.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7577 * (BMP on OS/2 or Windows, XPM on Unix)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7578 * Returns:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7579 * A handle to a pixmap or NULL on failure.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7580 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7581 HPIXMAP dw_pixmap_new_from_data(HWND handle, char *data, int len)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7582 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7583 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7584 char *file;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7585 FILE *fp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7586 HPIXMAP pixmap;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7587
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7588 if (!data || !(pixmap = calloc(1,sizeof(struct _hpixmap))))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7589 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7590
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7591 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7592 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7593 * A real hack; create a temporary file and write the contents
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7594 * of the data to the file
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7595 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7596 file = tmpnam( NULL );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7597 fp = fopen( file, "wb" );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7598 if ( fp )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7599 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7600 fwrite( data, len, 1, fp );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7601 fclose( fp );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7602 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7603 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7604 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7605 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7606 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7607 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7608 pixmap->pixbuf = gdk_pixbuf_new_from_file(file, NULL);
815
c1e93dd575a5 Initial implementation of a slightly disjointed dual cairo_surface gdkpixbuf image model.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 814
diff changeset
7609 pixmap->image = cairo_image_surface_create_from_png(file);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7610 pixmap->width = gdk_pixbuf_get_width(pixmap->pixbuf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7611 pixmap->height = gdk_pixbuf_get_height(pixmap->pixbuf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7612 /* remove our temporary file */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7613 unlink (file );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7614 pixmap->handle = handle;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7615 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7616 return pixmap;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7617 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7618
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7619 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7620 * Sets the transparent color for a pixmap
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7621 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7622 * pixmap: Handle to a pixmap returned by
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7623 * dw_pixmap_new..
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7624 * color: transparent color
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7625 * Note: This does nothing on GTK+ as transparency
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7626 * is handled automatically
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7627 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7628 void dw_pixmap_set_transparent_color(HPIXMAP pixmap, unsigned long color)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7629 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7630 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7631
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7632 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7633 * Creates a pixmap from internal resource graphic specified by id.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7634 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7635 * handle: Window handle the pixmap is associated with.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7636 * id: Resource ID associated with requested pixmap.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7637 * Returns:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7638 * A handle to a pixmap or NULL on failure.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7639 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7640 HPIXMAP dw_pixmap_grab(HWND handle, ULONG id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7641 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7642 HPIXMAP pixmap;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7643 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7644
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7645 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7646 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7647
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7648
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7649 DW_MUTEX_LOCK;
976
ab244c6f9386 Changed HICN to be a pointer type and simplified the icon code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 972
diff changeset
7650 pixmap->pixbuf = gdk_pixbuf_copy(_find_pixbuf((HICN)id, &pixmap->width, &pixmap->height));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7651 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7652 return pixmap;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7653 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7654
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7655 /* Call this after drawing to the screen to make sure
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7656 * anything you have drawn is visible.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7657 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7658 void dw_flush(void)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7659 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7660 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7661
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7662 /*
1148
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7663 * Sets the font used by a specified pixmap.
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7664 * Normally the pixmap font is obtained from the associated window handle.
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7665 * However this can be used to override that, or for pixmaps with no window.
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7666 * Parameters:
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7667 * pixmap: Handle to a pixmap returned by dw_pixmap_new() or
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7668 * passed to the application via a callback.
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7669 * fontname: Name and size of the font in the form "size.fontname"
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7670 * Returns:
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7671 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7672 */
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7673 int API dw_pixmap_set_font(HPIXMAP pixmap, char *fontname)
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7674 {
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7675 if(pixmap && fontname && *fontname)
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7676 {
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7677 char *oldfont = pixmap->font;
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7678 pixmap->font = strdup(fontname);
1240
3bc6244279c0 Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1232
diff changeset
7679 _convert_font(pixmap->font);
1148
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7680 if(oldfont)
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7681 free(oldfont);
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7682 return DW_ERROR_NONE;
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7683 }
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7684 return DW_ERROR_GENERAL;
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7685 }
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7686
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7687 /*
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7688 * Destroys an allocated pixmap.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7689 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7690 * pixmap: Handle to a pixmap returned by
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7691 * dw_pixmap_new..
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7692 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7693 void dw_pixmap_destroy(HPIXMAP pixmap)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7694 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7695 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7696
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7697 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7698 g_object_unref(G_OBJECT(pixmap->pixbuf));
818
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7699 cairo_surface_destroy(pixmap->image);
1148
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7700 if(pixmap->font)
439f276042cc Implemented dw_pixmap_set_font() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1145
diff changeset
7701 free(pixmap->font);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7702 free(pixmap);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7703 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7704 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7705
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7706 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7707 * Copies from one item to another.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7708 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7709 * dest: Destination window handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7710 * destp: Destination pixmap. (choose only one).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7711 * xdest: X coordinate of destination.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7712 * ydest: Y coordinate of destination.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7713 * width: Width of area to copy.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7714 * height: Height of area to copy.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7715 * src: Source window handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7716 * srcp: Source pixmap. (choose only one).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7717 * xsrc: X coordinate of source.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7718 * ysrc: Y coordinate of source.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7719 */
1245
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7720 void API dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc)
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7721 {
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7722 dw_pixmap_stretch_bitblt(dest, destp, xdest, ydest, width, height, src, srcp, xsrc, ysrc, -1, -1);
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7723 }
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7724
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7725 /*
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7726 * Copies from one surface to another allowing for stretching.
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7727 * Parameters:
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7728 * dest: Destination window handle.
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7729 * destp: Destination pixmap. (choose only one).
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7730 * xdest: X coordinate of destination.
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7731 * ydest: Y coordinate of destination.
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7732 * width: Width of the target area.
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7733 * height: Height of the target area.
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7734 * src: Source window handle.
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7735 * srcp: Source pixmap. (choose only one).
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7736 * xsrc: X coordinate of source.
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7737 * ysrc: Y coordinate of source.
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7738 * srcwidth: Width of area to copy.
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7739 * srcheight: Height of area to copy.
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7740 * Returns:
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7741 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7742 */
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7743 int API dw_pixmap_stretch_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc, int srcwidth, int srcheight)
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7744 {
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7745 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7746 cairo_t *cr = NULL;
1245
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7747 int retval = DW_ERROR_GENERAL;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7748
1177
c38ec904b6d3 Fixed dw_pixmap_bitblt() on printing context pixmaps in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1161
diff changeset
7749 if((!dest && (!destp || !destp->image)) || (!src && (!srcp || !srcp->image)))
1245
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7750 return retval;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7751
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7752 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7753 if(dest)
818
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7754 {
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7755 GdkWindow *window = gtk_widget_get_window(dest);
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7756 /* Safety check for non-existant windows */
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7757 if(!window || !GDK_IS_WINDOW(window))
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7758 {
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7759 DW_MUTEX_UNLOCK;
1245
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7760 return retval;
818
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7761 }
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7762 cr = gdk_cairo_create(window);
c17634e2b303 More safety checks in the drawing functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 817
diff changeset
7763 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7764 else if(destp)
816
916002e29d4c Implemented dw_pixmap_bitblt() with cairo surfaces instead of pixbufs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 815
diff changeset
7765 cr = cairo_create(destp->image);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
7766
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7767 if(cr)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7768 {
1245
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7769 double xscale = 1, yscale = 1;
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7770
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7771 if(srcwidth != -1 && srcheight != -1)
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7772 {
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7773 xscale = (double)width / (double)srcwidth;
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7774 yscale = (double)height / (double)srcheight;
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7775 cairo_scale(cr, xscale, yscale);
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7776 }
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7777
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7778 if(src)
1245
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7779 gdk_cairo_set_source_window (cr, gtk_widget_get_window(src), (xdest + xsrc) / xscale, (ydest + ysrc) / yscale);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7780 else if(srcp)
1245
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7781 cairo_set_source_surface (cr, srcp->image, (xdest + xsrc) / xscale, (ydest + ysrc) / yscale);
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7782
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7783 cairo_rectangle(cr, xdest / xscale, ydest / yscale, width, height);
959
37f2938ecd72 Fixes for bitblts with clipping and offset on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 900
diff changeset
7784 cairo_fill(cr);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7785 cairo_destroy(cr);
1245
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7786 retval = DW_ERROR_NONE;
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7787 }
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7788 DW_MUTEX_UNLOCK;
3a2ffe3a7eae Implemented dw_pixmap_stretch_bitblt() on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1240
diff changeset
7789 return retval;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7790 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7791
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7792 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7793 * Emits a beep.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7794 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7795 * freq: Frequency.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7796 * dur: Duration.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7797 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7798 void dw_beep(int freq, int dur)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7799 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7800 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7801
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7802 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7803 gdk_beep();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7804 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7805 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7806
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7807 void _my_strlwr(char *buf)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7808 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7809 int z, len = strlen(buf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7810
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7811 for(z=0;z<len;z++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7812 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7813 if(buf[z] >= 'A' && buf[z] <= 'Z')
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7814 buf[z] -= 'A' - 'a';
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7815 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7816 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7817
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7818 /* Open a shared library and return a handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7819 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7820 * name: Base name of the shared library.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7821 * handle: Pointer to a module handle,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7822 * will be filled in with the handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7823 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7824 int dw_module_load(char *name, HMOD *handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7825 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7826 int len;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7827 char *newname;
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
7828 char errorbuf[1025] = {0};
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7829
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7830
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7831 if(!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7832 return -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7833
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7834 if((len = strlen(name)) == 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7835 return -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7836
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7837 /* Lenth + "lib" + ".so" + NULL */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7838 newname = malloc(len + 7);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7839
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7840 if(!newname)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7841 return -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7842
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7843 sprintf(newname, "lib%s.so", name);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7844 _my_strlwr(newname);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7845
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7846 *handle = dlopen(newname, RTLD_NOW);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7847 if(*handle == NULL)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7848 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7849 strncpy(errorbuf, dlerror(), 1024);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7850 printf("%s\n", errorbuf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7851 sprintf(newname, "lib%s.so", name);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7852 *handle = dlopen(newname, RTLD_NOW);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7853 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7854
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7855 free(newname);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7856
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7857 return (NULL == *handle) ? -1 : 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7858 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7859
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7860 /* Queries the address of a symbol within open handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7861 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7862 * handle: Module handle returned by dw_module_load()
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7863 * name: Name of the symbol you want the address of.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7864 * func: A pointer to a function pointer, to obtain
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7865 * the address.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7866 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7867 int dw_module_symbol(HMOD handle, char *name, void**func)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7868 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7869 if(!func || !name)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7870 return -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7871
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7872 if(strlen(name) == 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7873 return -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7874
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7875 *func = (void*)dlsym(handle, name);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7876 return (NULL == *func);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7877 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7878
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7879 /* Frees the shared library previously opened.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7880 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7881 * handle: Module handle returned by dw_module_load()
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7882 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7883 int dw_module_close(HMOD handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7884 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7885 if(handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7886 return dlclose(handle);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7887 return 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7888 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7889
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7890 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7891 * Returns the handle to an unnamed mutex semaphore.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7892 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7893 HMTX dw_mutex_new(void)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7894 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7895 HMTX mutex = malloc(sizeof(pthread_mutex_t));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7896
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7897 pthread_mutex_init(mutex, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7898 return mutex;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7899 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7900
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7901 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7902 * Closes a semaphore created by dw_mutex_new().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7903 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7904 * mutex: The handle to the mutex returned by dw_mutex_new().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7905 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7906 void dw_mutex_close(HMTX mutex)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7907 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7908 if(mutex)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7909 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7910 pthread_mutex_destroy(mutex);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7911 free(mutex);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7912 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7913 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7914
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7915 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7916 * Tries to gain access to the semaphore, if it can't it blocks.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7917 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7918 * mutex: The handle to the mutex returned by dw_mutex_new().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7919 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7920 void dw_mutex_lock(HMTX mutex)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7921 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7922 /* If we are being called from an event handler we must release
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7923 * the GTK mutex so we don't deadlock.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7924 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7925 if(pthread_self() == _dw_thread)
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
7926 _dw_gdk_threads_leave();
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7927
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7928 pthread_mutex_lock(mutex);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7929
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7930 /* And of course relock it when we have acquired the mutext */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7931 if(pthread_self() == _dw_thread)
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
7932 _dw_gdk_threads_enter();
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7933 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7934
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7935 /*
1158
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1156
diff changeset
7936 * Tries to gain access to the semaphore.
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1156
diff changeset
7937 * Parameters:
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1156
diff changeset
7938 * mutex: The handle to the mutex returned by dw_mutex_new().
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1156
diff changeset
7939 * Returns:
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1156
diff changeset
7940 * DW_ERROR_NONE on success, DW_ERROR_TIMEOUT if it is already locked.
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1156
diff changeset
7941 */
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1156
diff changeset
7942 int API dw_mutex_trylock(HMTX mutex)
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1156
diff changeset
7943 {
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1156
diff changeset
7944 if(pthread_mutex_trylock(mutex) == 0)
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1156
diff changeset
7945 return DW_ERROR_NONE;
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1156
diff changeset
7946 return DW_ERROR_TIMEOUT;
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1156
diff changeset
7947 }
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1156
diff changeset
7948
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1156
diff changeset
7949 /*
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7950 * Reliquishes the access to the semaphore.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7951 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7952 * mutex: The handle to the mutex returned by dw_mutex_new().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7953 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7954 void dw_mutex_unlock(HMTX mutex)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7955 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7956 pthread_mutex_unlock(mutex);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7957 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7958
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7959 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7960 * Returns the handle to an unnamed event semaphore.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7961 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7962 HEV dw_event_new(void)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7963 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7964 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7965
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7966 if(!eve)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7967 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7968
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7969 /* We need to be careful here, mutexes on Linux are
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7970 * FAST by default but are error checking on other
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7971 * systems such as FreeBSD and OS/2, perhaps others.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7972 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7973 pthread_mutex_init (&(eve->mutex), NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7974 pthread_mutex_lock (&(eve->mutex));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7975 pthread_cond_init (&(eve->event), NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7976
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7977 pthread_mutex_unlock (&(eve->mutex));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7978 eve->alive = 1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7979 eve->posted = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7980
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7981 return eve;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7982 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7983
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7984 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7985 * Resets a semaphore created by dw_event_new().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7986 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7987 * eve: The handle to the event returned by dw_event_new().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7988 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7989 int dw_event_reset (HEV eve)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7990 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7991 if(!eve)
986
87dc0f5f96d0 Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 976
diff changeset
7992 return DW_ERROR_NON_INIT;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7993
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7994 pthread_mutex_lock (&(eve->mutex));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7995 pthread_cond_broadcast (&(eve->event));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7996 pthread_cond_init (&(eve->event), NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7997 eve->posted = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7998 pthread_mutex_unlock (&(eve->mutex));
986
87dc0f5f96d0 Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 976
diff changeset
7999 return DW_ERROR_NONE;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8000 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8001
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8002 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8003 * Posts a semaphore created by dw_event_new(). Causing all threads
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8004 * waiting on this event in dw_event_wait to continue.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8005 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8006 * eve: The handle to the event returned by dw_event_new().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8007 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8008 int dw_event_post (HEV eve)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8009 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8010 if(!eve)
986
87dc0f5f96d0 Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 976
diff changeset
8011 return DW_ERROR_NON_INIT;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8012
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8013 pthread_mutex_lock (&(eve->mutex));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8014 pthread_cond_broadcast (&(eve->event));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8015 eve->posted = 1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8016 pthread_mutex_unlock (&(eve->mutex));
986
87dc0f5f96d0 Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 976
diff changeset
8017 return DW_ERROR_NONE;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8018 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8019
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8020 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8021 * Waits on a semaphore created by dw_event_new(), until the
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8022 * event gets posted or until the timeout expires.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8023 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8024 * eve: The handle to the event returned by dw_event_new().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8025 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8026 int dw_event_wait(HEV eve, unsigned long timeout)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8027 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8028 int rc;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8029
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8030 if(!eve)
986
87dc0f5f96d0 Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 976
diff changeset
8031 return DW_ERROR_NON_INIT;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8032
1203
fc87309372ef Same fix for GTK2/3 as I just committed for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1191
diff changeset
8033 pthread_mutex_lock (&(eve->mutex));
fc87309372ef Same fix for GTK2/3 as I just committed for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1191
diff changeset
8034
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8035 if(eve->posted)
1203
fc87309372ef Same fix for GTK2/3 as I just committed for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1191
diff changeset
8036 {
fc87309372ef Same fix for GTK2/3 as I just committed for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1191
diff changeset
8037 pthread_mutex_unlock (&(eve->mutex));
fc87309372ef Same fix for GTK2/3 as I just committed for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1191
diff changeset
8038 return DW_ERROR_NONE;
fc87309372ef Same fix for GTK2/3 as I just committed for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1191
diff changeset
8039 }
fc87309372ef Same fix for GTK2/3 as I just committed for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1191
diff changeset
8040
1156
03b6d9fdfac0 Fixed a typo on Unix... timeout not time.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
8041 if(timeout != -1)
1155
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8042 {
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8043 struct timeval now;
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8044 struct timespec timeo;
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8045
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8046 gettimeofday(&now, 0);
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8047 timeo.tv_sec = now.tv_sec + (timeout / 1000);
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8048 timeo.tv_nsec = now.tv_usec * 1000;
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8049 rc = pthread_cond_timedwait(&(eve->event), &(eve->mutex), &timeo);
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8050 }
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8051 else
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8052 rc = pthread_cond_wait(&(eve->event), &(eve->mutex));
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8053
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8054 pthread_mutex_unlock (&(eve->mutex));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8055 if(!rc)
986
87dc0f5f96d0 Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 976
diff changeset
8056 return DW_ERROR_NONE;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8057 if(rc == ETIMEDOUT)
986
87dc0f5f96d0 Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 976
diff changeset
8058 return DW_ERROR_TIMEOUT;
87dc0f5f96d0 Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 976
diff changeset
8059 return DW_ERROR_GENERAL;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8060 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8061
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8062 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8063 * Closes a semaphore created by dw_event_new().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8064 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8065 * eve: The handle to the event returned by dw_event_new().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8066 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8067 int dw_event_close(HEV *eve)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8068 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8069 if(!eve || !(*eve))
986
87dc0f5f96d0 Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 976
diff changeset
8070 return DW_ERROR_NON_INIT;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8071
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8072 pthread_mutex_lock (&((*eve)->mutex));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8073 pthread_cond_destroy (&((*eve)->event));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8074 pthread_mutex_unlock (&((*eve)->mutex));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8075 pthread_mutex_destroy (&((*eve)->mutex));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8076 free(*eve);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8077 *eve = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8078
986
87dc0f5f96d0 Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 976
diff changeset
8079 return DW_ERROR_NONE;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8080 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8081
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8082 struct _seminfo {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8083 int fd;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8084 int waiting;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8085 };
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8086
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8087 static void _handle_sem(int *tmpsock)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8088 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8089 fd_set rd;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8090 struct _seminfo *array = (struct _seminfo *)malloc(sizeof(struct _seminfo));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8091 int listenfd = tmpsock[0];
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8092 int bytesread, connectcount = 1, maxfd, z, posted = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8093 char command;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8094 sigset_t mask;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8095
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8096 sigfillset(&mask); /* Mask all allowed signals */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8097 pthread_sigmask(SIG_BLOCK, &mask, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8098
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8099 /* problems */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8100 if(tmpsock[1] == -1)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8101 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8102 free(array);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8103 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8104 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8105
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8106 array[0].fd = tmpsock[1];
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8107 array[0].waiting = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8108
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8109 /* Free the memory allocated in dw_named_event_new. */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8110 free(tmpsock);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8111
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8112 while(1)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8113 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8114 FD_ZERO(&rd);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8115 FD_SET(listenfd, &rd);
1106
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8116 int result;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8117
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8118 maxfd = listenfd;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8119
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8120 /* Added any connections to the named event semaphore */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8121 for(z=0;z<connectcount;z++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8122 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8123 if(array[z].fd > maxfd)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8124 maxfd = array[z].fd;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8125
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8126 FD_SET(array[z].fd, &rd);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8127 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8128
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8129 if(select(maxfd+1, &rd, NULL, NULL, NULL) == -1)
1886
f7d408a47752 Fix a couple of errors reported by the static analyzer on Mac....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1884
diff changeset
8130 {
f7d408a47752 Fix a couple of errors reported by the static analyzer on Mac....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1884
diff changeset
8131 free(array);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8132 return;
1886
f7d408a47752 Fix a couple of errors reported by the static analyzer on Mac....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1884
diff changeset
8133 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8134
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8135 if(FD_ISSET(listenfd, &rd))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8136 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8137 struct _seminfo *newarray;
1886
f7d408a47752 Fix a couple of errors reported by the static analyzer on Mac....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1884
diff changeset
8138 int newfd = accept(listenfd, 0, 0);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8139
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8140 if(newfd > -1)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8141 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8142 /* Add new connections to the set */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8143 newarray = (struct _seminfo *)malloc(sizeof(struct _seminfo)*(connectcount+1));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8144 memcpy(newarray, array, sizeof(struct _seminfo)*(connectcount));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8145
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8146 newarray[connectcount].fd = newfd;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8147 newarray[connectcount].waiting = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8148
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8149 connectcount++;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8150
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8151 /* Replace old array with new one */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8152 free(array);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8153 array = newarray;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8154 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8155 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8156
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8157 /* Handle any events posted to the semaphore */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8158 for(z=0;z<connectcount;z++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8159 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8160 if(FD_ISSET(array[z].fd, &rd))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8161 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8162 if((bytesread = read(array[z].fd, &command, 1)) < 1)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8163 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8164 struct _seminfo *newarray;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8165
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8166 /* Remove this connection from the set */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8167 newarray = (struct _seminfo *)malloc(sizeof(struct _seminfo)*(connectcount-1));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8168 if(!z)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8169 memcpy(newarray, &array[1], sizeof(struct _seminfo)*(connectcount-1));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8170 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8171 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8172 memcpy(newarray, array, sizeof(struct _seminfo)*z);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8173 if(z!=(connectcount-1))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8174 memcpy(&newarray[z], &array[z+1], sizeof(struct _seminfo)*(z-connectcount-1));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8175 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8176 connectcount--;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8177
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8178 /* Replace old array with new one */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8179 free(array);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8180 array = newarray;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8181 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8182 else if(bytesread == 1)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8183 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8184 switch(command)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8185 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8186 case 0:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8187 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8188 /* Reset */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8189 posted = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8190 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8191 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8192 case 1:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8193 /* Post */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8194 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8195 int s;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8196 char tmp = (char)0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8197
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8198 posted = 1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8199
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8200 for(s=0;s<connectcount;s++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8201 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8202 /* The semaphore has been posted so
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8203 * we tell all the waiting threads to
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8204 * continue.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8205 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8206 if(array[s].waiting)
1106
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8207 result = write(array[s].fd, &tmp, 1);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8208 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8209 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8210 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8211 case 2:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8212 /* Wait */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8213 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8214 char tmp = (char)0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8215
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8216 array[z].waiting = 1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8217
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8218 /* If we are posted exit immeditately */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8219 if(posted)
1106
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8220 result = write(array[z].fd, &tmp, 1);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8221 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8222 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8223 case 3:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8224 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8225 /* Done Waiting */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8226 array[z].waiting = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8227 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8228 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8229 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8230 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8231 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8232 }
1124
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
8233 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8234 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8235
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8236 /* Using domain sockets on unix for IPC */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8237 /* Create a named event semaphore which can be
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8238 * opened from other processes.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8239 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8240 * eve: Pointer to an event handle to receive handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8241 * name: Name given to semaphore which can be opened
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8242 * by other processes.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8243 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8244 HEV dw_named_event_new(char *name)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8245 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8246 struct sockaddr_un un;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8247 int ev, *tmpsock = (int *)malloc(sizeof(int)*2);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8248 DWTID dwthread;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8249
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8250 if(!tmpsock)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8251 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8252
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8253 tmpsock[0] = socket(AF_UNIX, SOCK_STREAM, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8254 ev = socket(AF_UNIX, SOCK_STREAM, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8255 memset(&un, 0, sizeof(un));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8256 un.sun_family=AF_UNIX;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8257 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8258 strcpy(un.sun_path, "/tmp/.dw/");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8259 strcat(un.sun_path, name);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8260
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8261 /* just to be safe, this should be changed
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8262 * to support multiple instances.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8263 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8264 remove(un.sun_path);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8265
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8266 bind(tmpsock[0], (struct sockaddr *)&un, sizeof(un));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8267 listen(tmpsock[0], 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8268 connect(ev, (struct sockaddr *)&un, sizeof(un));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8269 tmpsock[1] = accept(tmpsock[0], 0, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8270
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8271 if(tmpsock[0] < 0 || tmpsock[1] < 0 || ev < 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8272 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8273 if(tmpsock[0] > -1)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8274 close(tmpsock[0]);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8275 if(tmpsock[1] > -1)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8276 close(tmpsock[1]);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8277 if(ev > -1)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8278 close(ev);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8279 free(tmpsock);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8280 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8281 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8282
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8283 /* Create a thread to handle this event semaphore */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8284 pthread_create(&dwthread, NULL, (void *)_handle_sem, (void *)tmpsock);
1106
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8285 return GINT_TO_POINTER(ev);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8286 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8287
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8288 /* Open an already existing named event semaphore.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8289 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8290 * eve: Pointer to an event handle to receive handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8291 * name: Name given to semaphore which can be opened
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8292 * by other processes.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8293 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8294 HEV dw_named_event_get(char *name)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8295 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8296 struct sockaddr_un un;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8297 int ev = socket(AF_UNIX, SOCK_STREAM, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8298 if(ev < 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8299 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8300
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8301 un.sun_family=AF_UNIX;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8302 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8303 strcpy(un.sun_path, "/tmp/.dw/");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8304 strcat(un.sun_path, name);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8305 connect(ev, (struct sockaddr *)&un, sizeof(un));
1106
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8306 return GINT_TO_POINTER(ev);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8307 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8308
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8309 /* Resets the event semaphore so threads who call wait
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8310 * on this semaphore will block.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8311 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8312 * eve: Handle to the semaphore obtained by
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8313 * an open or create call.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8314 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8315 int dw_named_event_reset(HEV eve)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8316 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8317 /* signal reset */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8318 char tmp = (char)0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8319
1106
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8320 if(GPOINTER_TO_INT(eve) < 0)
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8321 return DW_ERROR_NONE;
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8322
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8323 if(write(GPOINTER_TO_INT(eve), &tmp, 1) == 1)
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8324 return DW_ERROR_NONE;
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8325 return DW_ERROR_GENERAL;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8326 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8327
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8328 /* Sets the posted state of an event semaphore, any threads
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8329 * waiting on the semaphore will no longer block.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8330 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8331 * eve: Handle to the semaphore obtained by
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8332 * an open or create call.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8333 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8334 int dw_named_event_post(HEV eve)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8335 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8336
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8337 /* signal post */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8338 char tmp = (char)1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8339
1106
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8340 if(GPOINTER_TO_INT(eve) < 0)
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8341 return DW_ERROR_NONE;
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8342
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8343 if(write(GPOINTER_TO_INT(eve), &tmp, 1) == 1)
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8344 return DW_ERROR_NONE;
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8345 return DW_ERROR_GENERAL;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8346 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8347
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8348 /* Waits on the specified semaphore until it becomes
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8349 * posted, or returns immediately if it already is posted.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8350 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8351 * eve: Handle to the semaphore obtained by
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8352 * an open or create call.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8353 * timeout: Number of milliseconds before timing out
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8354 * or -1 if indefinite.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8355 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8356 int dw_named_event_wait(HEV eve, unsigned long timeout)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8357 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8358 fd_set rd;
1155
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8359 struct timeval tv, *useme = NULL;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8360 int retval = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8361 char tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8362
1106
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8363 if(GPOINTER_TO_INT(eve) < 0)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8364 return DW_ERROR_NON_INIT;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8365
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8366 /* Set the timout or infinite */
1155
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
8367 if(timeout != -1)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8368 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8369 tv.tv_sec = timeout / 1000;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8370 tv.tv_usec = timeout % 1000;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8371
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8372 useme = &tv;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8373 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8374
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8375 FD_ZERO(&rd);
1106
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8376 FD_SET(GPOINTER_TO_INT(eve), &rd);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8377
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8378 /* Signal wait */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8379 tmp = (char)2;
1106
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8380 retval = write(GPOINTER_TO_INT(eve), &tmp, 1);
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8381
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8382 if(retval == 1)
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8383 retval = select(GPOINTER_TO_INT(eve)+1, &rd, NULL, NULL, useme);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8384
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8385 /* Signal done waiting. */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8386 tmp = (char)3;
1106
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8387 if(retval == 1)
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8388 retval = write(GPOINTER_TO_INT(eve), &tmp, 1);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8389
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8390 if(retval == 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8391 return DW_ERROR_TIMEOUT;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8392 else if(retval == -1)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8393 return DW_ERROR_INTERRUPT;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8394
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8395 /* Clear the entry from the pipe so
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8396 * we don't loop endlessly. :)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8397 */
1106
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8398 if(read(GPOINTER_TO_INT(eve), &tmp, 1) == 1)
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8399 return DW_ERROR_NONE;
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8400 return DW_ERROR_GENERAL;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8401 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8402
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8403 /* Release this semaphore, if there are no more open
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8404 * handles on this semaphore the semaphore will be destroyed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8405 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8406 * eve: Handle to the semaphore obtained by
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8407 * an open or create call.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8408 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8409 int dw_named_event_close(HEV eve)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8410 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8411 /* Finally close the domain socket,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8412 * cleanup will continue in _handle_sem.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8413 */
1106
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8414 close(GPOINTER_TO_INT(eve));
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8415 return DW_ERROR_NONE;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8416 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8417
1887
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8418 /*
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8419 * Generally an internal function called from a newly created
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8420 * thread to setup the Dynamic Windows environment for the thread.
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8421 * However it is exported so language bindings can call it when
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8422 * they create threads that require access to Dynamic Windows.
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8423 */
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8424 void API _dw_init_thread(void)
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8425 {
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8426 GdkRGBA *foreground = malloc(sizeof(GdkRGBA));
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8427
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8428 foreground->alpha = foreground->red = foreground->green = foreground->blue = 0.0;
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8429 pthread_setspecific(_dw_fg_color_key, foreground);
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8430 pthread_setspecific(_dw_bg_color_key, NULL);
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8431 }
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8432
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8433 /*
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8434 * Generally an internal function called from a terminating
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8435 * thread to cleanup the Dynamic Windows environment for the thread.
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8436 * However it is exported so language bindings can call it when
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8437 * they exit threads that require access to Dynamic Windows.
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8438 */
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8439 void API _dw_deinit_thread(void)
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8440 {
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8441 GdkRGBA *foreground, *background;
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8442
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8443 if((foreground = pthread_getspecific(_dw_fg_color_key)))
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8444 free(foreground);
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8445 if((background = pthread_getspecific(_dw_bg_color_key)))
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8446 free(background);
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8447 }
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8448
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8449 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8450 * Setup thread independent color sets.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8451 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8452 void _dwthreadstart(void *data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8453 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8454 void (*threadfunc)(void *) = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8455 void **tmp = (void **)data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8456
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8457 threadfunc = (void (*)(void *))tmp[0];
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
8458
971
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
8459 /* Initialize colors */
1887
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8460 _dw_init_thread();
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
8461
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8462 threadfunc(tmp[1]);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8463 free(tmp);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
8464
971
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
8465 /* Free colors */
1887
09860ba329a4 Divided thread initialization and deinitialization into separate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1886
diff changeset
8466 _dw_deinit_thread();
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8467 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8468
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8469 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8470 * Allocates a shared memory region with a name.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8471 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8472 * handle: A pointer to receive a SHM identifier.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8473 * dest: A pointer to a pointer to receive the memory address.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8474 * size: Size in bytes of the shared memory region to allocate.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8475 * name: A string pointer to a unique memory name.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8476 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8477 HSHM dw_named_memory_new(void **dest, int size, char *name)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8478 {
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
8479 char namebuf[1025];
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8480 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8481
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8482 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
8483 snprintf(namebuf, 1024, "/tmp/.dw/%s", name);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8484
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8485 if((handle->fd = open(namebuf, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) < 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8486 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8487 free(handle);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8488 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8489 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8490
1106
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8491 if(ftruncate(handle->fd, size))
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8492 {
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8493 close(handle->fd);
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8494 free(handle);
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8495 return NULL;
eb6b27d17fe7 Fixed the 64bit warnings in GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1097
diff changeset
8496 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8497
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8498 /* attach the shared memory segment to our process's address space. */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8499 *dest = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8500
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8501 if(*dest == MAP_FAILED)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8502 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8503 close(handle->fd);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8504 *dest = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8505 free(handle);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8506 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8507 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8508
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8509 handle->size = size;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8510 handle->sid = getsid(0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8511 handle->path = strdup(namebuf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8512
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8513 return handle;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8514 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8515
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8516 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8517 * Aquires shared memory region with a name.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8518 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8519 * dest: A pointer to a pointer to receive the memory address.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8520 * size: Size in bytes of the shared memory region to requested.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8521 * name: A string pointer to a unique memory name.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8522 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8523 HSHM dw_named_memory_get(void **dest, int size, char *name)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8524 {
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
8525 char namebuf[1025];
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8526 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8527
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8528 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
8529 snprintf(namebuf, 1024, "/tmp/.dw/%s", name);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8530
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8531 if((handle->fd = open(namebuf, O_RDWR)) < 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8532 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8533 free(handle);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8534 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8535 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8536
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8537 /* attach the shared memory segment to our process's address space. */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8538 *dest = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8539
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8540 if(*dest == MAP_FAILED)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8541 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8542 close(handle->fd);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8543 *dest = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8544 free(handle);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8545 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8546 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8547
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8548 handle->size = size;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8549 handle->sid = -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8550 handle->path = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8551
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8552 return handle;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8553 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8554
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8555 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8556 * Frees a shared memory region previously allocated.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8557 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8558 * handle: Handle obtained from DB_named_memory_allocate.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8559 * ptr: The memory address aquired with DB_named_memory_allocate.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8560 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8561 int dw_named_memory_free(HSHM handle, void *ptr)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8562 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8563 struct _dw_unix_shm *h = handle;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8564 int rc = munmap(ptr, h->size);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8565
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8566 close(h->fd);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8567 if(h->path)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8568 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8569 /* Only remove the actual file if we are the
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8570 * creator of the file.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8571 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8572 if(h->sid != -1 && h->sid == getsid(0))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8573 remove(h->path);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8574 free(h->path);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8575 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8576 return rc;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8577 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8578 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8579 * Creates a new thread with a starting point of func.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8580 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8581 * func: Function which will be run in the new thread.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8582 * data: Parameter(s) passed to the function.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8583 * stack: Stack size of new thread (OS/2 and Windows only).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8584 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8585 DWTID dw_thread_new(void *func, void *data, int stack)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8586 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8587 DWTID gtkthread;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8588 void **tmp = malloc(sizeof(void *) * 2);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8589 int rc;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8590
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8591 tmp[0] = func;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8592 tmp[1] = data;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8593
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8594 rc = pthread_create(&gtkthread, NULL, (void *)_dwthreadstart, (void *)tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8595 if ( rc == 0 )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8596 return gtkthread;
1894
ed377fd16360 Fix some warnings reported by clang on FreeBSD in the GTK modules.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1892
diff changeset
8597 return (DWTID)DW_ERROR_UNKNOWN;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8598 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8599
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8600 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8601 * Ends execution of current thread immediately.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8602 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8603 void dw_thread_end(void)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8604 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8605 pthread_exit(NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8606 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8607
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8608 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8609 * Returns the current thread's ID.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8610 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8611 DWTID dw_thread_id(void)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8612 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8613 return (DWTID)pthread_self();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8614 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8615
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8616 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8617 * Cleanly terminates a DW session, should be signal handler safe.
1861
c836603d3f14 Add dw_shutdown() function which does the same thing as dw_exit() ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1853
diff changeset
8618 */
c836603d3f14 Add dw_shutdown() function which does the same thing as dw_exit() ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1853
diff changeset
8619 void dw_shutdown(void)
c836603d3f14 Add dw_shutdown() function which does the same thing as dw_exit() ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1853
diff changeset
8620 {
c836603d3f14 Add dw_shutdown() function which does the same thing as dw_exit() ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1853
diff changeset
8621 }
c836603d3f14 Add dw_shutdown() function which does the same thing as dw_exit() ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1853
diff changeset
8622
c836603d3f14 Add dw_shutdown() function which does the same thing as dw_exit() ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1853
diff changeset
8623 /*
c836603d3f14 Add dw_shutdown() function which does the same thing as dw_exit() ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1853
diff changeset
8624 * Cleanly terminates a DW session, should be signal handler safe.
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8625 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8626 * exitcode: Exit code reported to the operating system.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8627 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8628 void dw_exit(int exitcode)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8629 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8630 exit(exitcode);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8631 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8632
1561
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8633 /* Internal function to get the recommended size of scrolled items */
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8634 void _get_scrolled_size(GtkWidget *item, gint *thiswidth, gint *thisheight)
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8635 {
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8636 GtkWidget *widget = g_object_get_data(G_OBJECT(item), "_dw_user");
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8637
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8638 *thisheight = *thiswidth = 0;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8639
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8640 if(widget)
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8641 {
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8642 if(g_object_get_data(G_OBJECT(widget), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_TREE))
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8643 {
1566
035bc006afbe Experimental change... halfway between min and max for tree controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1563
diff changeset
8644 /* Set to half for tree */
035bc006afbe Experimental change... halfway between min and max for tree controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1563
diff changeset
8645 *thiswidth = (int)((_DW_SCROLLED_MAX_WIDTH + _DW_SCROLLED_MIN_WIDTH)/2);
035bc006afbe Experimental change... halfway between min and max for tree controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1563
diff changeset
8646 *thisheight = (int)((_DW_SCROLLED_MAX_HEIGHT + _DW_SCROLLED_MIN_HEIGHT)/2);
1561
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8647 }
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8648 else if(GTK_IS_TEXT_VIEW(widget))
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8649 {
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8650 unsigned long bytes;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8651 int height, width;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8652 char *buf, *ptr;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8653 int wrap = (gtk_text_view_get_wrap_mode(GTK_TEXT_VIEW(widget)) == GTK_WRAP_WORD);
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8654 static char testtext[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8655 int hscrolled = FALSE;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8656
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8657 *thiswidth = *thisheight = 0;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8658
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8659 dw_mle_get_size(item, &bytes, NULL);
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8660
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8661 ptr = buf = alloca(bytes + 2);
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8662 dw_mle_export(item, buf, 0, (int)bytes);
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8663 buf[bytes] = 0;
1562
9a8aa230a538 Ported a couple fixes from GTK3 to GTK2 that I had missed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1561
diff changeset
8664 strcat(buf, "\r");
1561
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8665
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8666 /* MLE */
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8667 while((ptr = strstr(buf, "\r")))
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8668 {
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8669 ptr[0] = 0;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8670 width = 0;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8671 if(strlen(buf))
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8672 dw_font_text_extents_get(item, NULL, buf, &width, &height);
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8673 else
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8674 dw_font_text_extents_get(item, NULL, testtext, NULL, &height);
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8675
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8676 if(wrap && width > _DW_SCROLLED_MAX_WIDTH)
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8677 {
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8678 *thiswidth = _DW_SCROLLED_MAX_WIDTH;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8679 *thisheight += height * (width / _DW_SCROLLED_MAX_WIDTH);
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8680 }
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8681 else
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8682 {
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8683 if(width > *thiswidth)
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8684 {
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8685 if(width > _DW_SCROLLED_MAX_WIDTH)
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8686 {
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8687 *thiswidth = _DW_SCROLLED_MAX_WIDTH;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8688 hscrolled = TRUE;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8689 }
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8690 else
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8691 *thiswidth = width;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8692 }
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8693 }
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8694 *thisheight += height;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8695 if(ptr[1] == '\n')
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8696 buf = &ptr[2];
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8697 else
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8698 buf = &ptr[1];
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8699 }
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8700 if(hscrolled)
1563
90fdfc8aa16d Slight adjustment to the scrollbar additional space on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1562
diff changeset
8701 *thisheight += 10;
1561
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8702 }
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8703 else
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8704 {
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8705 gtk_widget_get_preferred_height(GTK_WIDGET(widget), NULL, thisheight);
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8706 gtk_widget_get_preferred_width(GTK_WIDGET(widget), NULL, thiswidth);
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8707
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8708 *thisheight += 20;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8709 *thiswidth += 20;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8710 }
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8711 }
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8712 if(*thiswidth < _DW_SCROLLED_MIN_WIDTH)
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8713 *thiswidth = _DW_SCROLLED_MIN_WIDTH;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8714 if(*thiswidth > _DW_SCROLLED_MAX_WIDTH)
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8715 *thiswidth = _DW_SCROLLED_MAX_WIDTH;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8716 if(*thisheight < _DW_SCROLLED_MIN_HEIGHT)
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8717 *thisheight = _DW_SCROLLED_MIN_HEIGHT;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8718 if(*thisheight > _DW_SCROLLED_MAX_HEIGHT)
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8719 *thisheight = _DW_SCROLLED_MAX_HEIGHT;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8720 }
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8721
1087
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
8722 /* Internal box packing function called by the other 3 functions */
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
8723 void _dw_box_pack(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad, char *funcname)
1080
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8724 {
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8725 int warn = FALSE, _locked_by_me = FALSE;
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8726 GtkWidget *tmp, *tmpitem, *image = NULL;
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8727
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8728 if(!box)
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8729 return;
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8730
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8731 /*
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8732 * If you try and pack an item into itself VERY bad things can happen; like at least an
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8733 * infinite loop on GTK! Lets be safe!
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8734 */
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8735 if(box == item)
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8736 {
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8737 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!");
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8738 return;
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8739 }
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8740
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8741 DW_MUTEX_LOCK;
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8742
1451
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
8743 /* If this is a special box, like: Window, Groupbox, Scrollbox...
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
8744 * get the internal box handle.
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
8745 */
1080
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8746 if((tmp = g_object_get_data(G_OBJECT(box), "_dw_boxhandle")))
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8747 box = tmp;
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8748
1451
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
8749 /* Can't pack nothing with GTK, so create an empty label */
1080
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8750 if(!item)
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8751 {
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8752 item = gtk_label_new("");
1669
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8753 g_object_set_data(G_OBJECT(item), "_dw_padding", GINT_TO_POINTER(1));
1080
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8754 gtk_widget_show_all(item);
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8755 }
1451
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
8756 /* Due to GTK3 minimum size limitations, if we are packing a widget
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
8757 * with an image, we need to scale the image down to fit the packed size.
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
8758 */
1080
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8759 else if((image = g_object_get_data(G_OBJECT(item), "_dw_bitmap")))
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8760 {
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
8761 GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(image));
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
8762
1080
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8763 if(pixbuf)
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8764 {
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8765 int pwidth = gdk_pixbuf_get_width(pixbuf);
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8766 int pheight = gdk_pixbuf_get_height(pixbuf);
1426
dfd9f177c34c Fix incorrect pixbuf scaling on GTK3 when -1 is passed as a parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1414
diff changeset
8767
dfd9f177c34c Fix incorrect pixbuf scaling on GTK3 when -1 is passed as a parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1414
diff changeset
8768 if(width == -1)
dfd9f177c34c Fix incorrect pixbuf scaling on GTK3 when -1 is passed as a parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1414
diff changeset
8769 width = pwidth;
dfd9f177c34c Fix incorrect pixbuf scaling on GTK3 when -1 is passed as a parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1414
diff changeset
8770 if(height == -1)
dfd9f177c34c Fix incorrect pixbuf scaling on GTK3 when -1 is passed as a parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1414
diff changeset
8771 height = pheight;
1080
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8772
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8773 if(pwidth > width || pheight > height)
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8774 pixbuf = gdk_pixbuf_scale_simple(pixbuf, pwidth > width ? width : pwidth, pheight > height ? height : pheight, GDK_INTERP_BILINEAR);
1426
dfd9f177c34c Fix incorrect pixbuf scaling on GTK3 when -1 is passed as a parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1414
diff changeset
8775 gtk_image_set_from_pixbuf(GTK_IMAGE(image), pixbuf);
1080
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8776 }
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8777 }
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8778
1451
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
8779 /* Check if the item to be packed is a special box */
1080
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8780 tmpitem = (GtkWidget *)g_object_get_data(G_OBJECT(item), "_dw_boxhandle");
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8781
1451
95ca625b8ffc Removed GtkVbox and associated code from top-level windows on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
8782 /* Make sure our target box is valid */
1124
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
8783 if(GTK_IS_GRID(box))
1080
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8784 {
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
8785 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount"));
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
8786 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype"));
1080
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8787
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8788 /* If the item being packed is a box, then we use it's padding
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8789 * instead of the padding specified on the pack line, this is
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8790 * due to a bug in the OS/2 and Win32 renderer and a limitation
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8791 * of the GtkTable class.
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8792 */
1124
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
8793 if(GTK_IS_GRID(item) || (tmpitem && GTK_IS_GRID(tmpitem)))
1080
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8794 {
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8795 GtkWidget *eventbox = (GtkWidget *)g_object_get_data(G_OBJECT(item), "_dw_eventbox");
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8796
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8797 /* NOTE: I left in the ability to pack boxes with a size,
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8798 * this eliminates that by forcing the size to 0.
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8799 */
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8800 height = width = 0;
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8801
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8802 if(eventbox)
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8803 {
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
8804 int boxpad = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(item), "_dw_boxpad"));
1080
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8805 gtk_container_add(GTK_CONTAINER(eventbox), item);
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8806 gtk_container_set_border_width(GTK_CONTAINER(eventbox), boxpad);
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8807 item = eventbox;
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8808 }
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8809 }
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8810 else
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8811 {
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8812 /* Only show warning if item is not a box */
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8813 warn = TRUE;
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8814 }
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8815
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8816 /* Do some sanity bounds checking */
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8817 if(index < 0)
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8818 index = 0;
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8819 if(index > boxcount)
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8820 index = boxcount;
1656
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8821
1891
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8822 #if !GTK_CHECK_VERSION(3,10,0)
1656
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8823 /* Fix the index by taking into account empty cells */
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8824 if(boxtype == DW_VERT)
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8825 {
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8826 int z;
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8827
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8828 for(z=0;z<index;z++)
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8829 {
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8830 if(!gtk_grid_get_child_at(GTK_GRID(box), 0, z))
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8831 index++;
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8832 }
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8833 }
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8834 else
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8835 {
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8836 int z;
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8837
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8838 for(z=0;z<index;z++)
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8839 {
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8840 if(!gtk_grid_get_child_at(GTK_GRID(box), z, 0))
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8841 index++;
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8842 }
01f59ba51e7f Take into account empty box cells created by dw_window_destroy() in GTK3
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1637
diff changeset
8843 }
1890
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
8844 #endif
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
8845
1124
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
8846 g_object_set_data(G_OBJECT(item), "_dw_table", box);
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
8847 /* Set the expand attribute on the widgets now instead of the container */
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
8848 gtk_widget_set_vexpand(item, vsize);
1127
ed7cbdc37a75 Widget GTK3 v/halign properties get set according to the sizing flags
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1126
diff changeset
8849 gtk_widget_set_valign(item, vsize ? GTK_ALIGN_FILL : GTK_ALIGN_START);
1124
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
8850 gtk_widget_set_hexpand(item, hsize);
1127
ed7cbdc37a75 Widget GTK3 v/halign properties get set according to the sizing flags
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1126
diff changeset
8851 gtk_widget_set_halign(item, hsize ? GTK_ALIGN_FILL : GTK_ALIGN_START);
1124
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
8852 /* Use the margin property as padding */
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
8853 g_object_set(G_OBJECT(item), "margin", pad, NULL);
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
8854 /* Add to the grid using insert...
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
8855 * rows for vertical boxes and columns for horizontal.
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
8856 */
1080
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8857 if(boxtype == DW_VERT)
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8858 {
1124
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
8859 gtk_grid_insert_row(GTK_GRID(box), index);
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
8860 gtk_grid_attach(GTK_GRID(box), item, 0, index, 1, 1);
1080
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8861 }
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8862 else
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8863 {
1124
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
8864 gtk_grid_insert_column(GTK_GRID(box), index);
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
8865 gtk_grid_attach(GTK_GRID(box), item, index, 0, 1, 1);
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
8866 }
1080
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8867 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount + 1));
1545
6edf3fce77f2 Initial support for container and MLE auto-sizing on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1539
diff changeset
8868 /* Special case for scrolled windows */
1080
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8869 if(GTK_IS_SCROLLED_WINDOW(item))
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8870 {
1561
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8871 gint scrolledwidth = 0, scrolledheight = 0;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8872
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8873 /* Pre-run the calculation code for MLE/Container/Tree if needed */
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8874 if((width < 1 && !hsize) || (height < 1 && !vsize))
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8875 _get_scrolled_size(item, &scrolledwidth, &scrolledheight);
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8876
1413
28210f7941c7 Safety checks for -1 parameter to dw_box_pack*() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8877 if(width > 0)
28210f7941c7 Safety checks for -1 parameter to dw_box_pack*() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8878 gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(item), width);
1539
b7136c130a66 Default scrolled items to 500x200 on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
8879 else if(!hsize)
1561
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8880 gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(item), scrolledwidth);
1413
28210f7941c7 Safety checks for -1 parameter to dw_box_pack*() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8881 if(height > 0)
28210f7941c7 Safety checks for -1 parameter to dw_box_pack*() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8882 gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(item), height);
1539
b7136c130a66 Default scrolled items to 500x200 on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
8883 else if(!vsize)
1561
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
8884 gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(item), scrolledheight);
1080
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8885 }
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8886 else
1414
38c4484f5b90 Don't use natural size on GTK3 for entryfields, spinbuttons and comboboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1413
diff changeset
8887 {
1545
6edf3fce77f2 Initial support for container and MLE auto-sizing on GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1539
diff changeset
8888 /* Set the requested size of the widget */
1414
38c4484f5b90 Don't use natural size on GTK3 for entryfields, spinbuttons and comboboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1413
diff changeset
8889 if(width == -1 && (GTK_IS_COMBO_BOX(item) || GTK_IS_ENTRY(item)))
38c4484f5b90 Don't use natural size on GTK3 for entryfields, spinbuttons and comboboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1413
diff changeset
8890 gtk_widget_set_size_request(item, 150, height);
38c4484f5b90 Don't use natural size on GTK3 for entryfields, spinbuttons and comboboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1413
diff changeset
8891 else if(width == -1 && GTK_IS_SPIN_BUTTON(item))
38c4484f5b90 Don't use natural size on GTK3 for entryfields, spinbuttons and comboboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1413
diff changeset
8892 gtk_widget_set_size_request(item, 50, height);
38c4484f5b90 Don't use natural size on GTK3 for entryfields, spinbuttons and comboboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1413
diff changeset
8893 else
38c4484f5b90 Don't use natural size on GTK3 for entryfields, spinbuttons and comboboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1413
diff changeset
8894 gtk_widget_set_size_request(item, width, height);
38c4484f5b90 Don't use natural size on GTK3 for entryfields, spinbuttons and comboboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1413
diff changeset
8895 }
1080
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8896 if(GTK_IS_RADIO_BUTTON(item))
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8897 {
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8898 GSList *group;
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8899 GtkWidget *groupstart = (GtkWidget *)g_object_get_data(G_OBJECT(box), "_dw_group");
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8900
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8901 if(groupstart)
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8902 {
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8903 group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(groupstart));
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8904 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group);
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8905 }
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8906 else
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8907 g_object_set_data(G_OBJECT(box), "_dw_group", (gpointer)item);
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8908 }
1669
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8909 /* If we previously incremented the reference count... drop it now that it is packed */
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8910 if(g_object_get_data(G_OBJECT(item), "_dw_refed"))
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8911 {
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8912 g_object_unref(G_OBJECT(item));
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8913 g_object_set_data(G_OBJECT(item), "_dw_refed", NULL);
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8914 }
1080
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8915 }
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8916 DW_MUTEX_UNLOCK;
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8917
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8918 if(warn)
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8919 {
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8920 if ( width == 0 && hsize == FALSE )
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8921 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item);
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8922 if ( height == 0 && vsize == FALSE )
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8923 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item);
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8924 }
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8925 }
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8926
27e9a063fbb5 Committing initial version of dw_box_pack_at_index() for GTK2 and GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1076
diff changeset
8927 /*
1669
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8928 * Remove windows (widgets) from the box they are packed into.
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8929 * Parameters:
1679
e19b93a8229b More comment cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1678
diff changeset
8930 * handle: Window handle of the packed item to be removed.
1669
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8931 * Returns:
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8932 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8933 */
1769
d81bebc5c8cc Mark and I decided to change dw_box_remove*() to dw_box_unpack*() for consistency.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1747
diff changeset
8934 int API dw_box_unpack(HWND handle)
1669
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8935 {
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8936 int _locked_by_me = FALSE, retcode = DW_ERROR_GENERAL;
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8937
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8938 DW_MUTEX_LOCK;
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8939 if(GTK_IS_WIDGET(handle))
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8940 {
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8941 GtkWidget *box, *handle2 = handle;
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8942 GtkWidget *eventbox = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_eventbox");
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8943
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8944 /* Handle the invisible event box if it exists */
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8945 if(eventbox && GTK_IS_WIDGET(eventbox))
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8946 handle2 = eventbox;
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8947
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8948 /* Check if we are removing a widget from a box */
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8949 if((box = gtk_widget_get_parent(handle2)) && GTK_IS_GRID(box))
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8950 {
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8951 /* Get the number of items in the box... */
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8952 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount"));
1891
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8953 #if GTK_CHECK_VERSION(3,10,0)
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8954 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype"));
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8955 #endif
1669
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8956
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8957 if(boxcount > 0)
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8958 {
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8959 /* Decrease the count by 1 */
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8960 boxcount--;
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8961 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount));
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8962 }
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8963 /* If we haven't incremented the reference count... raise it before removal */
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8964 if(!g_object_get_data(G_OBJECT(handle2), "_dw_refed"))
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8965 {
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8966 g_object_ref(G_OBJECT(handle2));
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8967 g_object_set_data(G_OBJECT(handle2), "_dw_refed", GINT_TO_POINTER(1));
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8968 }
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8969 /* Remove the widget from the box */
1891
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8970 #if GTK_CHECK_VERSION(3,10,0)
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8971 /* Figure out where in the grid this widget is and remove that row/column */
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8972 if(boxtype == DW_VERT)
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8973 {
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8974 int z;
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8975
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8976 for(z=0;z<boxcount;z++)
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8977 {
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8978 if(gtk_grid_get_child_at(GTK_GRID(box), 0, z) == handle2)
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8979 {
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8980 gtk_grid_remove_row(GTK_GRID(box), z);
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8981 break;
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8982 }
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8983 }
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8984 }
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8985 else
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8986 {
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8987 int z;
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8988
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8989 for(z=0;z<boxcount;z++)
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8990 {
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8991 if(gtk_grid_get_child_at(GTK_GRID(box), z, 0) == handle2)
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8992 {
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8993 gtk_grid_remove_column(GTK_GRID(box), z);
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8994 break;
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8995 }
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8996 }
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8997 }
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
8998 #else
1669
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
8999 gtk_container_remove(GTK_CONTAINER(box), handle2);
1891
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
9000 #endif
1669
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
9001 retcode = DW_ERROR_NONE;
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
9002 }
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
9003 }
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
9004 DW_MUTEX_UNLOCK;
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
9005 return retcode;
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
9006 }
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
9007
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
9008 /*
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
9009 * Remove windows (widgets) from a box at an arbitrary location.
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
9010 * Parameters:
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
9011 * box: Window handle of the box to be removed from.
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
9012 * index: 0 based index of packed items.
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
9013 * Returns:
1679
e19b93a8229b More comment cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1678
diff changeset
9014 * Handle to the removed item on success, 0 on failure or padding.
1669
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
9015 */
1769
d81bebc5c8cc Mark and I decided to change dw_box_remove*() to dw_box_unpack*() for consistency.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1747
diff changeset
9016 HWND API dw_box_unpack_at_index(HWND box, int index)
1669
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
9017 {
1674
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9018 int _locked_by_me = FALSE;
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9019 HWND retval = 0;
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9020
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9021 DW_MUTEX_LOCK;
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9022 /* Check if we are removing a widget from a box */
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9023 if(GTK_IS_GRID(box))
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9024 {
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9025 /* Get the number of items in the box... */
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9026 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount"));
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9027 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype"));
1891
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
9028 #if GTK_CHECK_VERSION(3,10,0)
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
9029 GtkWidget *item = (boxtype == DW_VERT) ? gtk_grid_get_child_at(GTK_GRID(box), 0, index) : gtk_grid_get_child_at(GTK_GRID(box), index, 0);
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
9030 #else
1674
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9031 GtkWidget *item;
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9032
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9033 /* Fix the index by taking into account empty cells */
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9034 if(boxtype == DW_VERT)
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9035 {
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9036 int z;
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9037
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9038 for(z=0;z<index;z++)
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9039 {
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9040 if(!gtk_grid_get_child_at(GTK_GRID(box), 0, z))
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9041 index++;
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9042 }
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9043 item = gtk_grid_get_child_at(GTK_GRID(box), 0, index);
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9044 }
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9045 else
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9046 {
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9047 int z;
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9048
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9049 for(z=0;z<index;z++)
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9050 {
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9051 if(!gtk_grid_get_child_at(GTK_GRID(box), z, 0))
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9052 index++;
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9053 }
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9054 item = gtk_grid_get_child_at(GTK_GRID(box), index, 0);
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9055 }
1890
0f3df50bfc4f Untested GTK3 change to use the new gtk_grid_remove_*()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1887
diff changeset
9056 #endif
1674
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9057
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9058 if(boxcount > 0)
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9059 {
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9060 /* Decrease the count by 1 */
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9061 boxcount--;
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9062 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount));
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9063 }
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9064 /* If we haven't incremented the reference count... raise it before removal */
1891
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
9065 if(item && g_object_get_data(G_OBJECT(item), "_dw_padding"))
1674
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9066 gtk_widget_destroy(item);
1891
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
9067 else if(item)
1674
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9068 {
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9069 if(!g_object_get_data(G_OBJECT(item), "_dw_refed"))
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9070 {
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9071 g_object_ref(G_OBJECT(item));
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9072 g_object_set_data(G_OBJECT(item), "_dw_refed", GINT_TO_POINTER(1));
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9073 }
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9074 /* Remove the widget from the box */
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9075 gtk_container_remove(GTK_CONTAINER(box), item);
1891
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
9076 #if GTK_CHECK_VERSION(3,10,0)
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
9077 if(boxtype == DW_VERT)
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
9078 gtk_grid_remove_row(GTK_GRID(box), index);
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
9079 else
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
9080 gtk_grid_remove_column(GTK_GRID(box), index);
11a16c117748 Fixed build problems with the last GTK3 commit; tested with a live
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1890
diff changeset
9081 #endif
1674
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9082 retval = item;
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9083 }
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9084 }
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9085 DW_MUTEX_UNLOCK;
923af93e4084 Implemented dw_box_remove_at_index() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1669
diff changeset
9086 return retval;
1669
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
9087 }
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
9088
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1656
diff changeset
9089 /*
1087
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9090 * Pack windows (widgets) into a box at an arbitrary location.
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9091 * Parameters:
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9092 * box: Window handle of the box to be packed into.
1678
896f377a47c7 Added exports for building with MinGW on Windows and Watcom on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1674
diff changeset
9093 * item: Window handle of the item to pack.
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
9094 * index: 0 based index of packed items.
1087
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9095 * width: Width in pixels of the item or -1 to be self determined.
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9096 * height: Height in pixels of the item or -1 to be self determined.
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9097 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9098 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9099 * pad: Number of pixels of padding around the item.
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9100 */
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9101 void API dw_box_pack_at_index(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad)
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9102 {
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9103 _dw_box_pack(box, item, index, width, height, hsize, vsize, pad, "dw_box_pack_at_index()");
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9104 }
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9105
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9106 /*
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9107 * Pack windows (widgets) into a box from the start (or top).
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9108 * Parameters:
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9109 * box: Window handle of the box to be packed into.
1678
896f377a47c7 Added exports for building with MinGW on Windows and Watcom on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1674
diff changeset
9110 * item: Window handle of the item to pack.
1087
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9111 * width: Width in pixels of the item or -1 to be self determined.
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9112 * height: Height in pixels of the item or -1 to be self determined.
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9113 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9114 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9115 * pad: Number of pixels of padding around the item.
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9116 */
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9117 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9118 {
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
9119 /* 65536 is the table limit on GTK...
1087
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9120 * seems like a high enough value we will never hit it here either.
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9121 */
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9122 _dw_box_pack(box, item, 65536, width, height, hsize, vsize, pad, "dw_box_pack_start()");
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9123 }
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9124
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9125 /*
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9126 * Pack windows (widgets) into a box from the end (or bottom).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9127 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9128 * box: Window handle of the box to be packed into.
1678
896f377a47c7 Added exports for building with MinGW on Windows and Watcom on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1674
diff changeset
9129 * item: Window handle of the item to pack.
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9130 * width: Width in pixels of the item or -1 to be self determined.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9131 * height: Height in pixels of the item or -1 to be self determined.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9132 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9133 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9134 * pad: Number of pixels of padding around the item.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9135 */
1087
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9136 void API dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9137 {
173e49c2270f Merge all 3 box packing functions into one internal function on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1081
diff changeset
9138 _dw_box_pack(box, item, 0, width, height, hsize, vsize, pad, "dw_box_pack_end()");
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9139 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9140
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9141
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9142 union extents_union { guchar **gu_extents; unsigned long **extents; };
1510
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9143 static GdkAtom extents_atom = 0;
1479
1d414e81a099 FIXME: Workaround on GTK for Compiz not sending property notify
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1477
diff changeset
9144 static time_t extents_time = 0;
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9145
1510
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9146 static gboolean _dw_property_notify(GtkWidget *window, GdkEventProperty* event, GdkWindow *gdkwindow)
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9147 {
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9148 /* Check to see if we got a property change */
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9149 if(event->state == GDK_PROPERTY_NEW_VALUE && event->atom == extents_atom && event->window == gdkwindow)
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9150 extents_time = 0;
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9151 return FALSE;
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9152 }
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9153
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9154 /* Internal function to figure out the frame extents of an unmapped window */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9155 void _dw_get_frame_extents(GtkWidget *window, int *vert, int *horz)
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9156 {
1482
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9157 if(gtk_window_get_decorated(GTK_WINDOW(window)))
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9158 {
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9159 const char *request = "_NET_REQUEST_FRAME_EXTENTS";
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9160 unsigned long *extents = NULL;
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9161 union extents_union eu;
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9162 GdkAtom request_extents = gdk_atom_intern(request, FALSE);
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9163 GdkWindow *gdkwindow = gtk_widget_get_window(window);
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9164 GdkDisplay *display = gtk_widget_get_display(window);
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9165
1510
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9166 if(!extents_atom)
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9167 extents_atom = gdk_atom_intern("_NET_FRAME_EXTENTS", FALSE);
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9168
1482
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9169 /* Set some rational defaults.. just in case */
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9170 *vert = 28;
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9171 *horz = 12;
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9172
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9173 /* See if the current window manager supports _NET_REQUEST_FRAME_EXTENTS */
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9174 if(gdk_x11_screen_supports_net_wm_hint(gdk_screen_get_default(), request_extents))
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9175 {
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9176 Display *xdisplay = GDK_DISPLAY_XDISPLAY(display);
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9177 GdkWindow *root_window = gdk_get_default_root_window();
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9178 Window xroot_window = GDK_WINDOW_XID(root_window);
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9179 Atom extents_request_atom = gdk_x11_get_xatom_by_name_for_display(display, request);
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9180 unsigned long window_id = GDK_WINDOW_XID(gdkwindow);
1510
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9181 XEvent xevent = {0};
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9182 time_t currtime;
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9183 gulong connid;
1482
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9184
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9185 xevent.xclient.type = ClientMessage;
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9186 xevent.xclient.message_type = extents_request_atom;
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9187 xevent.xclient.display = xdisplay;
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9188 xevent.xclient.window = window_id;
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9189 xevent.xclient.format = 32;
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9190
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9191 /* Send the property request */
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9192 XSendEvent(xdisplay, xroot_window, False,
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9193 (SubstructureRedirectMask | SubstructureNotifyMask),
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9194 &xevent);
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9195
1510
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9196 /* Connect a signal to look for the property change */
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9197 connid = g_signal_connect(G_OBJECT(window), "property_notify_event", G_CALLBACK(_dw_property_notify), gdkwindow);
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9198
1482
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9199 /* Record the request time */
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9200 time(&extents_time);
1510
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9201
1482
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9202 /* Look for the property notify event */
1510
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9203 do
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9204 {
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9205 dw_main_iteration();
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9206 time(&currtime);
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9207 }
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9208 while(currtime - extents_time < 2);
1482
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9209
1510
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9210 /* Remove the signal handler now that we are done */
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9211 g_signal_handler_disconnect(G_OBJECT(window), connid);
1482
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9212 }
1479
1d414e81a099 FIXME: Workaround on GTK for Compiz not sending property notify
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1477
diff changeset
9213
1482
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9214 /* Attempt to retrieve window's frame extents. */
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9215 eu.extents = &extents;
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9216 if(gdk_property_get(gdkwindow,
1510
218c85939040 Ported fixes in previous commit from GTK2 to GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1506
diff changeset
9217 extents_atom,
1482
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9218 gdk_atom_intern("CARDINAL", FALSE),
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9219 0, sizeof(unsigned long)*4, FALSE,
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9220 NULL, NULL, NULL, eu.gu_extents))
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9221 {
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9222 *horz = extents[0] + extents[1];
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9223 *vert = extents[2] + extents[3];
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9224 }
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9225 }
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9226 else
dd584f431f9f Even better workaround to Compiz bug on GTK... it only seems to happen
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1481
diff changeset
9227 *horz = *vert = 0;
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9228 }
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9229
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9230 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9231 * Sets the size of a given window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9232 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9233 * handle: Window (widget) handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9234 * width: New width in pixels.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9235 * height: New height in pixels.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9236 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9237 void dw_window_set_size(HWND handle, unsigned long width, unsigned long height)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9238 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9239 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9240
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9241 if(!handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9242 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9243
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9244 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9245 if(GTK_IS_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9246 {
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9247 GdkWindow *window = gtk_widget_get_window(handle);
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9248 int cx = 0, cy = 0;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9249
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9250 /* Window is mapped query the frame size directly */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9251 if(window && gtk_widget_get_mapped(handle))
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9252 {
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9253 GdkRectangle frame;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9254 gint gwidth, gheight;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9255
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9256 /* Calculate the border size */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9257 gdk_window_get_frame_extents(window, &frame);
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9258 gdk_window_get_geometry(window, NULL, NULL, &gwidth, &gheight);
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9259
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9260 cx = frame.width - gwidth;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9261 if(cx < 0)
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9262 cx = 0;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9263 cy = frame.height - gheight;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9264 if(cy < 0)
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9265 cy = 0;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9266 }
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9267 else
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9268 {
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9269 /* Check if we have cached frame size values */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9270 if(!((cx = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_frame_width"))) |
1471
26dbd11399d6 Don't attempt to set windows to an invalid size on GTK when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1470
diff changeset
9271 (cy = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_frame_height")))))
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9272 {
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9273 /* If not try to ask the window manager for the estimated size...
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9274 * and finally if all else fails, guess.
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9275 */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9276 _dw_get_frame_extents(handle, &cy, &cx);
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9277 /* Cache values for later use */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9278 g_object_set_data(G_OBJECT(handle), "_dw_frame_width", GINT_TO_POINTER(cx));
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9279 g_object_set_data(G_OBJECT(handle), "_dw_frame_height", GINT_TO_POINTER(cy));
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9280 }
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9281 /* Save the size for when it is shown */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9282 g_object_set_data(G_OBJECT(handle), "_dw_width", GINT_TO_POINTER(width));
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9283 g_object_set_data(G_OBJECT(handle), "_dw_height", GINT_TO_POINTER(height));
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9284 }
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9285 /* Resize minus the border size */
1471
26dbd11399d6 Don't attempt to set windows to an invalid size on GTK when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1470
diff changeset
9286 if(width > cx && height > cy)
26dbd11399d6 Don't attempt to set windows to an invalid size on GTK when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1470
diff changeset
9287 {
26dbd11399d6 Don't attempt to set windows to an invalid size on GTK when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1470
diff changeset
9288 gtk_window_resize(GTK_WINDOW(handle), width - cx , height - cy );
26dbd11399d6 Don't attempt to set windows to an invalid size on GTK when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1470
diff changeset
9289 gtk_window_set_default_size(GTK_WINDOW(handle), width - cx, height - cy);
26dbd11399d6 Don't attempt to set windows to an invalid size on GTK when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1470
diff changeset
9290 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9291 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9292 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9293 gtk_widget_set_size_request(handle, width, height);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9294 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9295 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9296
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9297 /*
1429
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1426
diff changeset
9298 * Gets the size the system thinks the widget should be.
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1426
diff changeset
9299 * Parameters:
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1426
diff changeset
9300 * handle: Window handle of the item to be back.
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1426
diff changeset
9301 * width: Width in pixels of the item or NULL if not needed.
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1426
diff changeset
9302 * height: Height in pixels of the item or NULL if not needed.
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1426
diff changeset
9303 */
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1426
diff changeset
9304 void API dw_window_get_preferred_size(HWND handle, int *width, int *height)
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1426
diff changeset
9305 {
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1426
diff changeset
9306 int _locked_by_me = FALSE;
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1426
diff changeset
9307
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1426
diff changeset
9308 DW_MUTEX_LOCK;
1561
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
9309 if(GTK_IS_SCROLLED_WINDOW(handle))
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
9310 {
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
9311 gint scrolledwidth, scrolledheight;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
9312
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
9313 _get_scrolled_size(handle, &scrolledwidth, &scrolledheight);
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
9314
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
9315 if(width)
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
9316 *width = scrolledwidth;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
9317 if(height)
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
9318 *height = scrolledheight;
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
9319 }
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
9320 else
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
9321 {
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
9322 if(width)
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
9323 gtk_widget_get_preferred_width(handle, NULL, width);
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
9324 if(height)
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
9325 gtk_widget_get_preferred_height(handle, NULL, height);
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
9326 }
1429
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1426
diff changeset
9327 DW_MUTEX_UNLOCK;
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1426
diff changeset
9328 }
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1426
diff changeset
9329
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1426
diff changeset
9330 /*
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9331 * Returns the width of the screen.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9332 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9333 int dw_screen_width(void)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9334 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9335 int retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9336 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9337
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9338 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9339 retval = gdk_screen_width();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9340 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9341 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9342 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9343
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9344 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9345 * Returns the height of the screen.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9346 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9347 int dw_screen_height(void)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9348 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9349 int retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9350 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9351
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9352 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9353 retval = gdk_screen_height();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9354 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9355 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9356 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9357
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9358 /* This should return the current color depth */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9359 unsigned long dw_color_depth_get(void)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9360 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9361 int retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9362 GdkVisual *vis;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9363 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9364
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9365 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9366 vis = gdk_visual_get_system();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9367 retval = gdk_visual_get_depth(vis);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9368 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9369 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9370 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9371
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9372 /*
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9373 * Sets the gravity of a given window (widget).
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9374 * Gravity controls which corner of the screen and window the position is relative to.
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9375 * Parameters:
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9376 * handle: Window (widget) handle.
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9377 * horz: DW_GRAV_LEFT (default), DW_GRAV_RIGHT or DW_GRAV_CENTER.
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9378 * vert: DW_GRAV_TOP (default), DW_GRAV_BOTTOM or DW_GRAV_CENTER.
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9379 */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9380 void API dw_window_set_gravity(HWND handle, int horz, int vert)
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9381 {
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9382 dw_window_set_data(handle, "_dw_grav_horz", DW_INT_TO_POINTER(horz));
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9383 dw_window_set_data(handle, "_dw_grav_vert", DW_INT_TO_POINTER(vert));
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9384 }
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9385
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9386 /*
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9387 * Sets the position of a given window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9388 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9389 * handle: Window (widget) handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9390 * x: X location from the bottom left.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9391 * y: Y location from the bottom left.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9392 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9393 void dw_window_set_pos(HWND handle, long x, long y)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9394 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9395 int _locked_by_me = FALSE;
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
9396 #ifdef DW_INCLUDE_DEPRECATED
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9397 GtkWidget *mdi;
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
9398 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9399
1121
fb92778105b2 Fixes some major window positioning problems in GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1118
diff changeset
9400 if(!handle)
fb92778105b2 Fixes some major window positioning problems in GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1118
diff changeset
9401 return;
fb92778105b2 Fixes some major window positioning problems in GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1118
diff changeset
9402
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9403 DW_MUTEX_LOCK;
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
9404 #ifdef DW_INCLUDE_DEPRECATED
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9405 if((mdi = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_mdi")) && GTK_IS_MDI(mdi))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9406 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9407 gtk_mdi_move(GTK_MDI(mdi), handle, x, y);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9408 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9409 else
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
9410 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9411 {
1121
fb92778105b2 Fixes some major window positioning problems in GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1118
diff changeset
9412 GdkWindow *window = NULL;
fb92778105b2 Fixes some major window positioning problems in GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1118
diff changeset
9413
fb92778105b2 Fixes some major window positioning problems in GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1118
diff changeset
9414 if(GTK_IS_WINDOW(handle))
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9415 {
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9416 GdkWindow *window = gtk_widget_get_window(handle);
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9417 int horz = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_grav_horz"));
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9418 int vert = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_grav_vert"));
1476
d76a36c9cff1 FIXME: Hacky fix to gdk_window_get_frame_extents() on GTK3 returning bogus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
9419 int cx = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_frame_width"));
d76a36c9cff1 FIXME: Hacky fix to gdk_window_get_frame_extents() on GTK3 returning bogus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
9420 int cy = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_frame_height"));
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9421 int newx = x, newy = y, width = 0, height = 0;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9422
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9423 /* If the window is mapped */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9424 if(window && gtk_widget_get_mapped(handle))
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9425 {
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9426 /* If we need the width or height... */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9427 if(horz || vert)
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9428 {
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9429 GdkRectangle frame;
1476
d76a36c9cff1 FIXME: Hacky fix to gdk_window_get_frame_extents() on GTK3 returning bogus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
9430 int count = 0;
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9431
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9432 /* Get the frame size */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9433 gdk_window_get_frame_extents(window, &frame);
1476
d76a36c9cff1 FIXME: Hacky fix to gdk_window_get_frame_extents() on GTK3 returning bogus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
9434
d76a36c9cff1 FIXME: Hacky fix to gdk_window_get_frame_extents() on GTK3 returning bogus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
9435 /* FIXME: Sometimes we get returned an invalid 200x200
d76a36c9cff1 FIXME: Hacky fix to gdk_window_get_frame_extents() on GTK3 returning bogus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
9436 * result... so if we get this... try the call a second
d76a36c9cff1 FIXME: Hacky fix to gdk_window_get_frame_extents() on GTK3 returning bogus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
9437 * time and hope for a better result.
d76a36c9cff1 FIXME: Hacky fix to gdk_window_get_frame_extents() on GTK3 returning bogus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
9438 */
d76a36c9cff1 FIXME: Hacky fix to gdk_window_get_frame_extents() on GTK3 returning bogus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
9439 while((frame.width == 200 || frame.width == (200 + cx)) &&
d76a36c9cff1 FIXME: Hacky fix to gdk_window_get_frame_extents() on GTK3 returning bogus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
9440 (frame.height == 200 || frame.height == (200 + cy)) && count < 10)
d76a36c9cff1 FIXME: Hacky fix to gdk_window_get_frame_extents() on GTK3 returning bogus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
9441 {
1505
fcdd9e3c735a Use _dw_msleep() insetad of dw_main_sleep() when pausing to get the frame extents
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1501
diff changeset
9442 _dw_msleep(1);
1476
d76a36c9cff1 FIXME: Hacky fix to gdk_window_get_frame_extents() on GTK3 returning bogus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
9443 count++;
d76a36c9cff1 FIXME: Hacky fix to gdk_window_get_frame_extents() on GTK3 returning bogus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
9444 gdk_window_get_frame_extents(window, &frame);
d76a36c9cff1 FIXME: Hacky fix to gdk_window_get_frame_extents() on GTK3 returning bogus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
9445 }
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9446 width = frame.width;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9447 height = frame.height;
1470
a317c2ec1d4c On GTK2 gtk_window_move() needs to be called after mapping the window...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1469
diff changeset
9448 }
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9449 }
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9450 else
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9451 {
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9452 /* Check if we have cached frame size values */
1476
d76a36c9cff1 FIXME: Hacky fix to gdk_window_get_frame_extents() on GTK3 returning bogus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
9453 if(!(cx | cy))
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9454 {
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9455 /* If not try to ask the window manager for the estimated size...
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9456 * and finally if all else fails, guess.
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9457 */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9458 _dw_get_frame_extents(handle, &cy, &cx);
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9459 /* Cache values for later use */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9460 g_object_set_data(G_OBJECT(handle), "_dw_frame_width", GINT_TO_POINTER(cx));
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9461 g_object_set_data(G_OBJECT(handle), "_dw_frame_height", GINT_TO_POINTER(cy));
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9462 }
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9463 /* Save the positions for when it is shown */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9464 g_object_set_data(G_OBJECT(handle), "_dw_x", GINT_TO_POINTER(x));
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9465 g_object_set_data(G_OBJECT(handle), "_dw_y", GINT_TO_POINTER(y));
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9466 g_object_set_data(G_OBJECT(handle), "_dw_pos", GINT_TO_POINTER(1));
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9467 /* Check to see if there is a pending size request too */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9468 width = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_width"));
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9469 height = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_height"));
1470
a317c2ec1d4c On GTK2 gtk_window_move() needs to be called after mapping the window...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1469
diff changeset
9470 if(!width || !height)
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9471 {
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9472 /* Ask what GTK is planning on suggesting for the window size */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9473 gtk_window_get_size(GTK_WINDOW(handle), !width ? &width : NULL, !height ? &height : NULL);
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9474 }
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9475 /* Add the frame size to it */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9476 width += cx;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9477 height += cy;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9478 }
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9479 /* Do any gravity calculations */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9480 if(horz || vert)
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9481 {
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9482 /* Handle horizontal center gravity */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9483 if((horz & 0xf) == DW_GRAV_CENTER)
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9484 newx += ((gdk_screen_width() / 2) - (width / 2));
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9485 /* Handle right gravity */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9486 else if((horz & 0xf) == DW_GRAV_RIGHT)
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9487 newx = gdk_screen_width() - width - x;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9488 /* Handle vertical center gravity */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9489 if((vert & 0xf) == DW_GRAV_CENTER)
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9490 newy += ((gdk_screen_height() / 2) - (height / 2));
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9491 else if((vert & 0xf) == DW_GRAV_BOTTOM)
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1471
diff changeset
9492 newy = gdk_screen_height() - height - y;
1499
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9493
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
9494 #if GTK_CHECK_VERSION(3,3,8)
1499
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9495 /* Adjust the values to avoid Gnome bar if requested */
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9496 if((horz | vert) & DW_GRAV_OBSTACLES)
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9497 {
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9498 GdkRectangle rect;
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9499 GdkScreen *screen = gdk_screen_get_default();
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9500
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9501 gdk_screen_get_monitor_workarea(screen, 0, &rect);
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9502
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9503 if(horz & DW_GRAV_OBSTACLES)
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9504 {
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9505 if((horz & 0xf) == DW_GRAV_LEFT)
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9506 newx += rect.x;
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9507 else if((horz & 0xf) == DW_GRAV_RIGHT)
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9508 newx -= dw_screen_width() - (rect.x + rect.width);
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9509 }
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9510 if(vert & DW_GRAV_OBSTACLES)
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9511 {
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9512 if((vert & 0xf) == DW_GRAV_TOP)
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9513 newy += rect.y;
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9514 else if((vert & 0xf) == DW_GRAV_BOTTOM)
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9515 newy -= dw_screen_height() - (rect.y + rect.height);
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9516 }
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9517 }
97e5e8688fe1 Added gravity obstacle support for GTK 3.4 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1491
diff changeset
9518 #endif
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9519 }
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9520 /* Finally move the window into place */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9521 gtk_window_move(GTK_WINDOW(handle), newx, newy);
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9522 }
1121
fb92778105b2 Fixes some major window positioning problems in GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1118
diff changeset
9523 else if((window = gtk_widget_get_window(handle)))
fb92778105b2 Fixes some major window positioning problems in GTK3...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1118
diff changeset
9524 gdk_window_move(window, x, y);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9525 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9526 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9527 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9528
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9529 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9530 * Sets the position and size of a given window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9531 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9532 * handle: Window (widget) handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9533 * x: X location from the bottom left.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9534 * y: Y location from the bottom left.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9535 * width: Width of the widget.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9536 * height: Height of the widget.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9537 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9538 void dw_window_set_pos_size(HWND handle, long x, long y, unsigned long width, unsigned long height)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9539 {
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9540 dw_window_set_size(handle, width, height);
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9541 dw_window_set_pos(handle, x, y);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9542 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9543
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9544 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9545 * Gets the position and size of a given window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9546 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9547 * handle: Window (widget) handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9548 * x: X location from the bottom left.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9549 * y: Y location from the bottom left.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9550 * width: Width of the widget.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9551 * height: Height of the widget.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9552 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9553 void dw_window_get_pos_size(HWND handle, long *x, long *y, ULONG *width, ULONG *height)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9554 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9555 int _locked_by_me = FALSE;
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9556 gint gx = 0, gy = 0, gwidth = 0, gheight = 0;
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
9557 #ifdef DW_INCLUDE_DEPRECATED
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9558 GtkWidget *mdi;
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
9559 #endif
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
9560
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
9561 DW_MUTEX_LOCK;
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
9562 #ifdef DW_INCLUDE_DEPRECATED
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9563 /* If it is an MDI window query what we can */
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9564 if((mdi = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_mdi")) && GTK_IS_MDI(mdi))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9565 {
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9566 gtk_mdi_get_pos(GTK_MDI(mdi), handle, &gx, &gy);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9567 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9568 else
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
9569 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9570 {
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9571 GdkWindow *window;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9572
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9573 /* Can only query if the window is realized */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9574 if(handle && (window = gtk_widget_get_window(handle)))
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9575 {
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9576 /* If it is a toplevel window */
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9577 if(GTK_IS_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9578 {
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9579 if(gtk_widget_get_mapped(handle))
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9580 {
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9581 GdkRectangle frame;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9582
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9583 /* Calculate the border rectangle */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9584 gdk_window_get_frame_extents(window, &frame);
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9585 gx = frame.x;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9586 gy = frame.y;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9587 gwidth = frame.width;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9588 gheight = frame.height;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9589 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9590 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9591 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9592 {
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9593 /* Get an individual widget coordinates */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9594 gdk_window_get_geometry(window, &gx, &gy, &gwidth, &gheight);
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9595 gdk_window_get_root_origin(window, &gx, &gy);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9596 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9597 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9598 }
1469
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9599 /* Fill in the requested fields */
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9600 if(x)
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9601 *x = gx;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9602 if(y)
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9603 *y = gy;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9604 if(width)
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9605 *width = gwidth;
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9606 if(height)
b9efb744cfbd Second try and window positioning for GTK2 and port to GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1463
diff changeset
9607 *height = gheight;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9608 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9609 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9610
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9611 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9612 * Sets the style of a given window (widget).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9613 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9614 * handle: Window (widget) handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9615 * width: New width in pixels.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9616 * height: New height in pixels.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9617 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9618 void dw_window_set_style(HWND handle, unsigned long style, unsigned long mask)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9619 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9620 GtkWidget *handle2 = handle;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9621 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9622
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9623 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9624 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9625 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9626 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9627 if(tmp)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9628 handle2 = tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9629 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9630 else if(GTK_IS_FRAME(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9631 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9632 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_label");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9633 if(tmp && GTK_IS_LABEL(tmp))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9634 handle2 = tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9635 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9636 else if(GTK_IS_BUTTON(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9637 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9638 if(mask & DW_BS_NOBORDER)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9639 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9640 if(style & DW_BS_NOBORDER)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9641 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9642 gtk_button_set_relief((GtkButton *)handle, GTK_RELIEF_NONE);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9643 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9644 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9645 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9646 gtk_button_set_relief((GtkButton *)handle, GTK_RELIEF_NORMAL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9647 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9648 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9649 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9650 if ( GTK_IS_LABEL(handle2) )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9651 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9652 gfloat x=DW_LEFT, y=DW_CENTER;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9653 /* horizontal... */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9654 if ( style & DW_DT_CENTER )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9655 x = DW_CENTER;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9656 if ( style & DW_DT_RIGHT )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9657 x = DW_RIGHT;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9658 if ( style & DW_DT_LEFT )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9659 x = DW_LEFT;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9660 /* vertical... */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9661 if ( style & DW_DT_VCENTER )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9662 y = DW_CENTER;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9663 if ( style & DW_DT_TOP )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9664 y = DW_TOP;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9665 if ( style & DW_DT_BOTTOM )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9666 y = DW_BOTTOM;
1917
933b5f7005a9 Fix building on GTK3 versions older than 3.16.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1916
diff changeset
9667 #if GTK_CHECK_VERSION(3,16,0)
1913
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
9668 gtk_label_set_xalign(GTK_LABEL(handle2), x);
5d32be499016 The GTK MDI code is filling up with deprecated calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1912
diff changeset
9669 gtk_label_set_yalign(GTK_LABEL(handle2), y);
1917
933b5f7005a9 Fix building on GTK3 versions older than 3.16.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1916
diff changeset
9670 #else
933b5f7005a9 Fix building on GTK3 versions older than 3.16.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1916
diff changeset
9671 gtk_misc_set_alignment(GTK_MISC(handle2), x, y);
933b5f7005a9 Fix building on GTK3 versions older than 3.16.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1916
diff changeset
9672 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9673 if ( style & DW_DT_WORDBREAK )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9674 gtk_label_set_line_wrap( GTK_LABEL(handle), TRUE );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9675 }
1314
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9676 if ( GTK_IS_CHECK_MENU_ITEM(handle2) && (mask & (DW_MIS_CHECKED | DW_MIS_UNCHECKED)) )
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9677 {
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9678 int check = 0;
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9679
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9680 if ( style & DW_MIS_CHECKED )
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9681 check = 1;
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9682
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9683 _dw_ignore_click = 1;
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9684 if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(handle2)) != check)
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9685 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(handle2), check);
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9686 _dw_ignore_click = 0;
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9687 }
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9688 if ( (GTK_IS_CHECK_MENU_ITEM(handle2) || GTK_IS_MENU_ITEM(handle2)) && (mask & (DW_MIS_ENABLED | DW_MIS_DISABLED) ))
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9689 {
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9690 _dw_ignore_click = 1;
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9691 if ( style & DW_MIS_ENABLED )
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9692 gtk_widget_set_sensitive( handle2, TRUE );
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9693 else
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9694 gtk_widget_set_sensitive( handle2, FALSE );
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9695 _dw_ignore_click = 0;
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1308
diff changeset
9696 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9697 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9698 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9699
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9700 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9701 * Adds a new page to specified notebook.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9702 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9703 * handle: Window (widget) handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9704 * flags: Any additional page creation flags.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9705 * front: If TRUE page is added at the beginning.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9706 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9707 unsigned long dw_notebook_page_new(HWND handle, unsigned long flags, int front)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9708 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9709 int z;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9710 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9711 GtkWidget **pagearray;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9712
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9713 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9714 pagearray = (GtkWidget **)g_object_get_data(G_OBJECT(handle), "_dw_pagearray");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9715
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9716 if(pagearray)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9717 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9718 for(z=0;z<256;z++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9719 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9720 if(!pagearray[z])
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9721 {
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
9722 char text[101] = {0};
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9723 int num = z;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9724
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9725 if(front)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9726 num |= 1 << 16;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9727
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
9728 snprintf(text, 100, "_dw_page%d", z);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9729 /* Save the real id and the creation flags */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9730 g_object_set_data(G_OBJECT(handle), text, GINT_TO_POINTER(num));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9731 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9732 return z;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9733 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9734 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9735 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9736 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9737
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9738 /* Hopefully this won't happen. */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9739 return 256;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9740 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9741
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9742 /* Return the physical page id from the logical page id */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9743 int _get_physical_page(HWND handle, unsigned long pageid)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9744 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9745 int z;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9746 GtkWidget *thispage, **pagearray = g_object_get_data(G_OBJECT(handle), "_dw_pagearray");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9747
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9748 if(pagearray)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9749 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9750 for(z=0;z<256;z++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9751 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9752 if((thispage = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), z)))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9753 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9754 if(thispage == pagearray[pageid])
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9755 return z;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9756 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9757 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9758 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9759 return 256;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9760 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9761
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9762 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9763 * Remove a page from a notebook.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9764 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9765 * handle: Handle to the notebook widget.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9766 * pageid: ID of the page to be destroyed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9767 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9768 void dw_notebook_page_destroy(HWND handle, unsigned int pageid)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9769 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9770 int realpage, _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9771 GtkWidget **pagearray;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9772
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9773 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9774 realpage = _get_physical_page(handle, pageid);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9775 if(realpage > -1 && realpage < 256)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9776 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9777 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), realpage);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9778 if((pagearray = g_object_get_data(G_OBJECT(handle), "_dw_pagearray")))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9779 pagearray[pageid] = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9780 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9781 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9782 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9783
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9784 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9785 * Queries the currently visible page ID.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9786 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9787 * handle: Handle to the notebook widget.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9788 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9789 unsigned long dw_notebook_page_get(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9790 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9791 int retval, phys;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9792 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9793
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9794 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9795 phys = gtk_notebook_get_current_page(GTK_NOTEBOOK(handle));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9796 retval = _get_logical_page(handle, phys);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9797 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9798 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9799 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9800
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9801 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9802 * Sets the currently visibale page ID.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9803 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9804 * handle: Handle to the notebook widget.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9805 * pageid: ID of the page to be made visible.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9806 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9807 void dw_notebook_page_set(HWND handle, unsigned int pageid)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9808 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9809 int realpage, _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9810
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9811 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9812 realpage = _get_physical_page(handle, pageid);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9813 if(realpage > -1 && realpage < 256)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9814 gtk_notebook_set_current_page(GTK_NOTEBOOK(handle), pageid);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9815 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9816 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9817
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9818
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9819 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9820 * Sets the text on the specified notebook tab.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9821 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9822 * handle: Notebook handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9823 * pageid: Page ID of the tab to set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9824 * text: Pointer to the text to set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9825 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9826 void dw_notebook_page_set_text(HWND handle, unsigned long pageid, char *text)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9827 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9828 GtkWidget *child;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9829 int realpage, _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9830
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9831 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9832 realpage = _get_physical_page(handle, pageid);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9833 if(realpage < 0 || realpage > 255)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9834 {
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
9835 char ptext[101] = {0};
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9836 int num;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9837
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
9838 snprintf(ptext, 100, "_dw_page%d", (int)pageid);
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
9839 num = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), ptext));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9840 realpage = 0xFF & num;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9841 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9842
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9843 if(realpage > -1 && realpage < 256)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9844 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9845 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), realpage);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9846 if(child)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9847 gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(handle), child, text);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9848 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9849 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9850 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9851
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9852 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9853 * Sets the text on the specified notebook tab status area.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9854 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9855 * handle: Notebook handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9856 * pageid: Page ID of the tab to set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9857 * text: Pointer to the text to set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9858 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9859 void dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, char *text)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9860 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9861 /* TODO (if possible) */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9862 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9863
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9864 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9865 * Packs the specified box into the notebook page.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9866 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9867 * handle: Handle to the notebook to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9868 * pageid: Page ID in the notebook which is being packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9869 * page: Box handle to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9870 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9871 void dw_notebook_pack(HWND handle, unsigned long pageid, HWND page)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9872 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9873 GtkWidget *label, *child, *oldlabel, **pagearray;
790
1822c8a71936 Removed a now unused helper function and fixed a discared qualifier error.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 789
diff changeset
9874 const gchar *text = NULL;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9875 int num, z, realpage = -1, pad, _locked_by_me = FALSE;
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
9876 char ptext[101] = {0};
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
9877
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
9878 DW_MUTEX_LOCK;
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
9879 snprintf(ptext, 100, "_dw_page%d", (int)pageid);
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
9880 num = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), ptext));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9881 g_object_set_data(G_OBJECT(handle), ptext, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9882 pagearray = (GtkWidget **)g_object_get_data(G_OBJECT(handle), "_dw_pagearray");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9883
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9884 if(!pagearray)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9885 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9886 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9887 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9888 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9889
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9890 /* The page already exists... so get it's current page */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9891 if(pagearray[pageid])
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9892 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9893 for(z=0;z<256;z++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9894 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9895 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), z);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9896 if(child == pagearray[pageid])
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9897 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9898 oldlabel = gtk_notebook_get_tab_label(GTK_NOTEBOOK(handle), child);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9899 if(oldlabel)
789
8fe51d916b36 Reenabled the set-focus code that was disabled due to combobox issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 788
diff changeset
9900 text = gtk_label_get_text(GTK_LABEL(oldlabel));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9901 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), z);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9902 realpage = z;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9903 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9904 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9905 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9906 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9907
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9908 pagearray[pageid] = page;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9909
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9910 label = gtk_label_new(text ? text : "");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9911
1124
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
9912 if(GTK_IS_GRID(page))
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9913 {
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
9914 pad = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(page), "_dw_boxpad"));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9915 gtk_container_set_border_width(GTK_CONTAINER(page), pad);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9916 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9917
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9918 if(realpage != -1)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9919 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, realpage);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9920 else if(num & ~(0xFF))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9921 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 0);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9922 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9923 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 256);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9924 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9925 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9926
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9927 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9928 * Appends the specified text to the listbox's (or combobox) entry list.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9929 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9930 * handle: Handle to the listbox to be appended to.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9931 * text: Text to append into listbox.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9932 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9933 void dw_listbox_append(HWND handle, char *text)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9934 {
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9935 dw_listbox_insert(handle, text, -1);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9936 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9937
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9938 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9939 * Inserts the specified text int the listbox's (or combobox) entry list at the
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9940 * position indicated.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9941 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9942 * handle: Handle to the listbox to be appended to.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9943 * text: Text to insert into listbox.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9944 * pos: 0-based index into listbox. -1 will append
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9945 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9946 void dw_listbox_insert(HWND handle, char *text, int pos)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9947 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9948 GtkWidget *handle2 = handle;
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9949 GtkListStore *store = NULL;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9950 int _locked_by_me = FALSE;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9951
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9952 DW_MUTEX_LOCK;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9953 /* Get the inner handle for scrolled controls */
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9954 if(GTK_IS_SCROLLED_WINDOW(handle))
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9955 {
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9956 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9957 if(tmp)
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9958 handle2 = tmp;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9959 }
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9960 if(handle2)
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9961 {
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9962 GtkTreeIter iter;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
9963
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9964 /* Make sure it is the correct tree type */
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
9965 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
9966 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9967 else if(GTK_IS_COMBO_BOX(handle2))
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
9968 store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
9969
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9970 if(!store)
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9971 {
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9972 DW_MUTEX_UNLOCK;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9973 return;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9974 }
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
9975
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9976 if(pos < 0)
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9977 {
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9978 /* Insert an entry at the end */
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9979 gtk_list_store_append(store, &iter);
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9980 }
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9981 else
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9982 {
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9983 /* Insert at position */
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9984 gtk_list_store_insert(store, &iter, pos);
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9985 }
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9986 gtk_list_store_set (store, &iter, 0, text, -1);
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9987 }
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9988 DW_MUTEX_UNLOCK;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9989 }
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9990
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9991 /*
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9992 * Appends the specified text items to the listbox's (or combobox) entry list.
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9993 * Parameters:
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9994 * handle: Handle to the listbox to be appended to.
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9995 * text: Text strings to append into listbox.
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9996 * count: Number of text strings to append
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9997 */
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9998 void dw_listbox_list_append(HWND handle, char **text, int count)
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
9999 {
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10000 GtkWidget *handle2 = handle;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10001 GtkListStore *store = NULL;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10002 int _locked_by_me = FALSE;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10003
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10004 DW_MUTEX_LOCK;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10005 /* Get the inner handle for scrolled controls */
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10006 if(GTK_IS_SCROLLED_WINDOW(handle))
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10007 {
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10008 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10009 if(tmp)
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10010 handle2 = tmp;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10011 }
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10012 if(handle2)
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10013 {
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10014 int z;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10015 GtkTreeIter iter;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10016
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10017 /* Make sure it is the correct tree type */
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10018 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10019 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10020 else if(GTK_IS_COMBO_BOX(handle2))
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10021 store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10022
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10023 if(!store)
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10024 {
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10025 DW_MUTEX_UNLOCK;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10026 return;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10027 }
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10028
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10029 /* Insert entries at the end */
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10030 for(z=0;z<count;z++)
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10031 {
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10032 gtk_list_store_append(store, &iter);
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10033 gtk_list_store_set (store, &iter, 0, text[z], -1);
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10034 }
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10035 }
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10036 DW_MUTEX_UNLOCK;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10037 }
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10038
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10039 /*
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10040 * Clears the listbox's (or combobox) list of all entries.
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10041 * Parameters:
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10042 * handle: Handle to the listbox to be cleared.
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10043 */
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10044 void dw_listbox_clear(HWND handle)
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10045 {
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10046 GtkWidget *handle2 = handle;
777
c0e7200dad31 More work on comboboxes, listboxes and containers. Comboboxes now display the list properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 775
diff changeset
10047 GtkListStore *store = NULL;
c0e7200dad31 More work on comboboxes, listboxes and containers. Comboboxes now display the list properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 775
diff changeset
10048 int _locked_by_me = FALSE;
c0e7200dad31 More work on comboboxes, listboxes and containers. Comboboxes now display the list properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 775
diff changeset
10049
c0e7200dad31 More work on comboboxes, listboxes and containers. Comboboxes now display the list properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 775
diff changeset
10050 DW_MUTEX_LOCK;
c0e7200dad31 More work on comboboxes, listboxes and containers. Comboboxes now display the list properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 775
diff changeset
10051 /* Get the inner handle for scrolled controls */
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10052 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10053 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10054 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10055 if(tmp)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10056 handle2 = tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10057 }
777
c0e7200dad31 More work on comboboxes, listboxes and containers. Comboboxes now display the list properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 775
diff changeset
10058 if(handle2)
c0e7200dad31 More work on comboboxes, listboxes and containers. Comboboxes now display the list properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 775
diff changeset
10059 {
c0e7200dad31 More work on comboboxes, listboxes and containers. Comboboxes now display the list properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 775
diff changeset
10060 /* Make sure it is the correct tree type */
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10061 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10062 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
777
c0e7200dad31 More work on comboboxes, listboxes and containers. Comboboxes now display the list properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 775
diff changeset
10063 else if(GTK_IS_COMBO_BOX(handle2))
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10064 store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10065
777
c0e7200dad31 More work on comboboxes, listboxes and containers. Comboboxes now display the list properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 775
diff changeset
10066 if(!store)
c0e7200dad31 More work on comboboxes, listboxes and containers. Comboboxes now display the list properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 775
diff changeset
10067 {
c0e7200dad31 More work on comboboxes, listboxes and containers. Comboboxes now display the list properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 775
diff changeset
10068 DW_MUTEX_UNLOCK;
c0e7200dad31 More work on comboboxes, listboxes and containers. Comboboxes now display the list properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 775
diff changeset
10069 return;
c0e7200dad31 More work on comboboxes, listboxes and containers. Comboboxes now display the list properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 775
diff changeset
10070 }
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10071 /* Clear the list */
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10072 gtk_list_store_clear(store);
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10073 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10074 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10075 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10076
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10077 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10078 * Returns the listbox's item count.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10079 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10080 * handle: Handle to the listbox to be counted
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10081 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10082 int dw_listbox_count(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10083 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10084 GtkWidget *handle2 = handle;
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10085 GtkListStore *store = NULL;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10086 int _locked_by_me = FALSE;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10087 int retval = 0;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10088
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10089 DW_MUTEX_LOCK;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10090 /* Get the inner handle for scrolled controls */
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10091 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10092 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10093 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10094 if(tmp)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10095 handle2 = tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10096 }
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10097 if(handle2)
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10098 {
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10099 /* Make sure it is the correct tree type */
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10100 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10101 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10102 else if(GTK_IS_COMBO_BOX(handle2))
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10103 store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10104
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10105 if(store)
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10106 {
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10107 /* Get the number of children at the top level */
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10108 retval = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL);
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10109 }
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10110 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10111 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10112 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10113 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10114
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10115 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10116 * Sets the topmost item in the viewport.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10117 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10118 * handle: Handle to the listbox to be cleared.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10119 * top: Index to the top item.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10120 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10121 void dw_listbox_set_top(HWND handle, int top)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10122 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10123 GtkWidget *handle2 = handle;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10124 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10125
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10126 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10127 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10128 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10129 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10130 if(tmp)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10131 handle2 = tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10132 }
877
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10133 /* Make sure it is the correct tree type */
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10134 if(handle2 && GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10135 {
1330
c63069148357 Mostly fixed dw_listbox_set_top() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1327
diff changeset
10136 GtkAdjustment *adjust = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle));
877
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10137 GtkListStore *store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10138
877
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10139 if(store && adjust)
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10140 {
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10141 /* Get the number of children at the top level */
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10142 gint rowcount = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL);
1330
c63069148357 Mostly fixed dw_listbox_set_top() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1327
diff changeset
10143 gdouble pagesize = gtk_adjustment_get_page_size(adjust);
c63069148357 Mostly fixed dw_listbox_set_top() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1327
diff changeset
10144 gdouble upper = gtk_adjustment_get_upper(adjust) - pagesize;
877
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10145 gdouble lower = gtk_adjustment_get_lower(adjust);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10146 gdouble change;
1330
c63069148357 Mostly fixed dw_listbox_set_top() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1327
diff changeset
10147
877
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10148 /* Safety check */
1330
c63069148357 Mostly fixed dw_listbox_set_top() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1327
diff changeset
10149 if(rowcount < 2)
877
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10150 {
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10151 DW_MUTEX_UNLOCK;
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10152 return;
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10153 }
1330
c63069148357 Mostly fixed dw_listbox_set_top() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1327
diff changeset
10154
c63069148357 Mostly fixed dw_listbox_set_top() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1327
diff changeset
10155 /* Verify the range */
c63069148357 Mostly fixed dw_listbox_set_top() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1327
diff changeset
10156 rowcount--;
c63069148357 Mostly fixed dw_listbox_set_top() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1327
diff changeset
10157 if(top > rowcount)
c63069148357 Mostly fixed dw_listbox_set_top() on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1327
diff changeset
10158 top = rowcount;
877
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10159
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10160 change = ((gdouble)top/(gdouble)rowcount) * (upper - lower);
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10161
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10162 gtk_adjustment_set_value(adjust, change + lower);
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10163 }
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10164 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10165 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10166 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10167
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10168 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10169 * Copies the given index item's text into buffer.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10170 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10171 * handle: Handle to the listbox to be queried.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10172 * index: Index into the list to be queried.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10173 * buffer: Buffer where text will be copied.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10174 * length: Length of the buffer (including NULL).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10175 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10176 void dw_listbox_get_text(HWND handle, unsigned int index, char *buffer, unsigned int length)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10177 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10178 GtkWidget *handle2 = handle;
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10179 GtkListStore *store = NULL;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10180 int _locked_by_me = FALSE;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10181
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10182 DW_MUTEX_LOCK;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10183 /* Get the inner handle for scrolled controls */
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10184 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10185 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10186 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10187 if(tmp)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10188 handle2 = tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10189 }
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10190 if(handle2)
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10191 {
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10192 /* Make sure it is the correct tree type */
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10193 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10194 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10195 else if(GTK_IS_COMBO_BOX(handle2))
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10196 store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10197
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10198 if(store && index < gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL))
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10199 {
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10200 GtkTreeIter iter;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10201
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10202 /* Get the nth child at the top level */
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10203 if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, index))
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10204 {
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10205 /* Get the text */
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10206 gchar *text;
1884
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
10207 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, _DW_DATA_TYPE_STRING, &text, -1);
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
10208 if(text)
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
10209 {
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
10210 strncpy(buffer, text, length);
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
10211 g_free(text);
71780cf68aa2 More container and tree changes on all platforms regarding memory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1881
diff changeset
10212 }
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10213 DW_MUTEX_UNLOCK;
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10214 return;
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10215 }
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10216 }
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10217 }
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10218 buffer[0] = '\0';
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10219 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10220 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10221
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10222 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10223 * Sets the text of a given listbox entry.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10224 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10225 * handle: Handle to the listbox to be queried.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10226 * index: Index into the list to be queried.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10227 * buffer: Buffer where text will be copied.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10228 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10229 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10230 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10231 GtkWidget *handle2 = handle;
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10232 GtkListStore *store = NULL;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10233 int _locked_by_me = FALSE;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10234
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10235 DW_MUTEX_LOCK;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10236 /* Get the inner handle for scrolled controls */
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10237 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10238 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10239 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10240 if(tmp)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10241 handle2 = tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10242 }
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10243 if(handle2)
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10244 {
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10245 /* Make sure it is the correct tree type */
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10246 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10247 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10248 else if(GTK_IS_COMBO_BOX(handle2))
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10249 store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10250
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10251 if(store && index < gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL))
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10252 {
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10253 GtkTreeIter iter;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10254
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10255 /* Get the nth child at the top level */
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10256 if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, index))
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10257 {
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10258 /* Update the text */
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10259 gtk_list_store_set(store, &iter, buffer);
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10260 }
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10261 }
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10262 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10263 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10264 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10265
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10266 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10267 * Returns the index to the current selected item or -1 when done.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10268 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10269 * handle: Handle to the listbox to be queried.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10270 * where: Either the previous return or -1 to restart.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10271 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10272 int dw_listbox_selected_multi(HWND handle, int where)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10273 {
788
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10274 GtkWidget *handle2;
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10275 GtkListStore *store = NULL;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10276 int retval = DW_LIT_NONE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10277 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10278
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10279 DW_MUTEX_LOCK;
788
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10280 handle2 = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10281
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10282 /* Make sure it is the correct tree type */
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10283 if(handle2 && GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10284 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10285
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10286 if(store)
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10287 {
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10288 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(handle2));
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10289 GList *list = gtk_tree_selection_get_selected_rows(sel, NULL);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10290
788
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10291 if(list)
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10292 {
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10293 int counter = 0;
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10294 GtkTreePath *path = g_list_nth_data(list, 0);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10295
788
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10296 while(path)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10297 {
788
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10298 gint *indices = gtk_tree_path_get_indices(path);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10299
788
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10300 if(indices && indices[0] > where)
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10301 {
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10302 retval = indices[0];
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10303 break;
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10304 }
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10305
788
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10306 counter++;
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10307 path = g_list_nth_data(list, counter);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10308 }
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10309
788
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10310 g_list_foreach(list, (GFunc) gtk_tree_path_free, NULL);
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10311 g_list_free(list);
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10312 }
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
10313 }
1124
aff4aeca858f Experimental change to use GtkGrid instead of GtkTable for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1122
diff changeset
10314 DW_MUTEX_UNLOCK;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10315 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10316 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10317
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10318 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10319 * Returns the index to the item in the list currently selected.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10320 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10321 * handle: Handle to the listbox to be queried.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10322 */
986
87dc0f5f96d0 Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 976
diff changeset
10323 int dw_listbox_selected(HWND handle)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10324 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10325 GtkWidget *handle2 = handle;
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10326 GtkListStore *store = NULL;
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10327 int _locked_by_me = FALSE;
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10328 unsigned int retval = 0;
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10329
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10330 DW_MUTEX_LOCK;
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10331 /* Get the inner handle for scrolled controls */
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10332 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10333 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10334 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10335 if(tmp)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10336 handle2 = tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10337 }
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10338 if(handle2)
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10339 {
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10340 /* Make sure it is the correct tree type */
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10341 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10342 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10343 else if(GTK_IS_COMBO_BOX(handle2))
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10344 store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10345
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10346 if(store)
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10347 {
780
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10348 if(GTK_IS_TREE_VIEW(handle2))
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10349 {
780
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10350 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(handle2));
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10351 GList *list = gtk_tree_selection_get_selected_rows(sel, NULL);
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10352 if(list)
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10353 {
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10354 GtkTreePath *path = g_list_nth_data(list, 0);
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10355 gint *indices = gtk_tree_path_get_indices(path);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10356
780
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10357 if(indices)
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10358 {
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10359 retval = indices[0];
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10360 }
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10361
780
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10362 g_list_foreach(list, (GFunc) gtk_tree_path_free, NULL);
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10363 g_list_free(list);
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10364 }
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10365 }
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10366 else
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10367 {
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10368 GtkTreeIter iter;
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10369 GtkTreePath *path;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10370
883
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
10371 if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(handle2), &iter))
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10372 {
883
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
10373 path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
10374 if(path)
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
10375 {
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
10376 gint *indices = gtk_tree_path_get_indices(path);
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10377
883
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
10378 if(indices)
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
10379 {
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
10380 retval = indices[0];
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
10381 }
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
10382 gtk_tree_path_free(path);
63a8e77191c7 Experimental changes to the containers so filsystem icon and name are same column for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 877
diff changeset
10383 }
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10384 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10385 }
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10386 }
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10387 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10388 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10389 return retval;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10390 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10391
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10392 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10393 * Sets the selection state of a given index.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10394 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10395 * handle: Handle to the listbox to be set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10396 * index: Item index.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10397 * state: TRUE if selected FALSE if unselected.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10398 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10399 void dw_listbox_select(HWND handle, int index, int state)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10400 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10401 GtkWidget *handle2 = handle;
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10402 GtkListStore *store = NULL;
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10403 int _locked_by_me = FALSE;
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10404
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10405 DW_MUTEX_LOCK;
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10406 /* Get the inner handle for scrolled controls */
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10407 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10408 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10409 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10410 if(tmp)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10411 handle2 = tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10412 }
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10413 if(handle2)
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10414 {
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10415 /* Make sure it is the correct tree type */
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10416 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10417 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10418 else if(GTK_IS_COMBO_BOX(handle2))
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10419 store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10420
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10421 if(store && index < gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL))
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10422 {
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10423 GtkTreeIter iter;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10424
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10425 /* Get the nth child at the top level */
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10426 if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, index))
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10427 {
787
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
10428 if(GTK_IS_COMBO_BOX(handle2))
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10429 {
787
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
10430 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(handle2), &iter);
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10431 }
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10432 else
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10433 {
787
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
10434 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(handle2));
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
10435 if(state)
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
10436 {
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
10437 /* Select the item */
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
10438 gtk_tree_selection_select_iter(sel, &iter);
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
10439 }
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
10440 else
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
10441 {
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
10442 /* Deselect the item */
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
10443 gtk_tree_selection_unselect_iter(sel, &iter);
098458f3bdfb Fixes some missing checks for combobox causing GTK warnings running HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 786
diff changeset
10444 }
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10445 }
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10446 }
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10447 }
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10448 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10449 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10450 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10451
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10452 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10453 * Deletes the item with given index from the list.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10454 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10455 * handle: Handle to the listbox to be set.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10456 * index: Item index.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10457 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10458 void dw_listbox_delete(HWND handle, int index)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10459 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10460 GtkWidget *handle2 = handle;
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10461 GtkListStore *store = NULL;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10462 int _locked_by_me = FALSE;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10463
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10464 DW_MUTEX_LOCK;
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10465 /* Get the inner handle for scrolled controls */
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10466 if(GTK_IS_SCROLLED_WINDOW(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10467 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10468 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10469 if(tmp)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10470 handle2 = tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10471 }
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10472 if(handle2)
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10473 {
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10474 /* Make sure it is the correct tree type */
780
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10475 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10476 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10477 else if(GTK_IS_COMBO_BOX(handle2))
780
fda93b441c4d Lots of listbox/combobox/container fixes. Things are starting to come together.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 779
diff changeset
10478 store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10479
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10480 if(store)
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10481 {
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10482 GtkTreeIter iter;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
10483
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10484 /* Get the nth child at the top level */
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10485 if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, index))
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10486 {
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10487 gtk_list_store_remove(store, &iter);
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
10488 }
778
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10489 }
99ce0ea1f271 Implemented many of the dw_listbox_* functions using the new tree view for comboboxes and listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 777
diff changeset
10490 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10491 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10492 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10493
1353
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10494 /* Function to do delayed positioning */
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10495 gboolean _splitbar_set_percent(gpointer data)
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10496 {
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10497 GtkWidget *widget = data;
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10498 float *percent = (float *)g_object_get_data(G_OBJECT(widget), "_dw_percent");
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10499
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10500 if(percent)
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10501 {
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10502 GtkAllocation alloc;
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10503
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10504 gtk_widget_get_allocation(widget, &alloc);
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10505
1583
525c4c9d04c6 After switching to non-deprecated functions in GTK3 like...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1579
diff changeset
10506 if(gtk_orientable_get_orientation(GTK_ORIENTABLE(widget)) == GTK_ORIENTATION_HORIZONTAL)
1353
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10507 gtk_paned_set_position(GTK_PANED(widget), (int)(alloc.width * (*percent / 100.0)));
1583
525c4c9d04c6 After switching to non-deprecated functions in GTK3 like...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1579
diff changeset
10508 else
1353
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10509 gtk_paned_set_position(GTK_PANED(widget), (int)(alloc.height * (*percent / 100.0)));
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10510 g_object_set_data(G_OBJECT(widget), "_dw_percent", NULL);
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10511 free(percent);
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10512 }
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10513 return FALSE;
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10514 }
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10515
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10516 /* Reposition the bar according to the percentage */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10517 static gint _splitbar_size_allocate(GtkWidget *widget, GtkAllocation *event, gpointer data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10518 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10519 float *percent = (float *)g_object_get_data(G_OBJECT(widget), "_dw_percent");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10520
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10521 /* Prevent infinite recursion ;) */
1005
751522e9f3ac Switchted to using dw_paned_pack*() to pack the splitbar on GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1001
diff changeset
10522 if(!percent || event->width < 20 || event->height < 20)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10523 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10524
1353
f4ad4ba39b61 Apparently it is unsafe to set properties in the GTK3 size allocate callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1352
diff changeset
10525 g_idle_add(_splitbar_set_percent, widget);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10526 return FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10527 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10528
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10529 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10530 * Creates a splitbar window (widget) with given parameters.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10531 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10532 * type: Value can be DW_VERT or DW_HORZ.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10533 * topleft: Handle to the window to be top or left.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10534 * bottomright: Handle to the window to be bottom or right.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10535 * Returns:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10536 * A handle to a splitbar window or NULL on failure.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10537 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10538 HWND dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10539 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10540 GtkWidget *tmp = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10541 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10542 float *percent = malloc(sizeof(float));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10543
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10544 DW_MUTEX_LOCK;
1575
58ed65820baf Eliminate even more deprecated APIs for GTK3... still more to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
10545 tmp = gtk_paned_new(type == DW_HORZ ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
1125
95d7eb4e85c6 The shrink flag on GtkPanded (splitbar) in GTK 3 causes tons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1124
diff changeset
10546 gtk_paned_pack1(GTK_PANED(tmp), topleft, TRUE, FALSE);
95d7eb4e85c6 The shrink flag on GtkPanded (splitbar) in GTK 3 causes tons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1124
diff changeset
10547 gtk_paned_pack2(GTK_PANED(tmp), bottomright, TRUE, FALSE);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10548 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10549 *percent = 50.0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10550 g_object_set_data(G_OBJECT(tmp), "_dw_percent", (gpointer)percent);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10551 g_signal_connect(G_OBJECT(tmp), "size-allocate", G_CALLBACK(_splitbar_size_allocate), NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10552 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10553 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10554 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10555 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10556
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10557 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10558 * Sets the position of a splitbar (pecentage).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10559 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10560 * handle: The handle to the splitbar returned by dw_splitbar_new().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10561 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10562 void dw_splitbar_set(HWND handle, float percent)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10563 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10564 float *mypercent = (float *)dw_window_get_data(handle, "_dw_percent");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10565 int size = 0, position;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10566
1583
525c4c9d04c6 After switching to non-deprecated functions in GTK3 like...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1579
diff changeset
10567 if(gtk_orientable_get_orientation(GTK_ORIENTABLE(handle)) == GTK_ORIENTATION_HORIZONTAL)
525c4c9d04c6 After switching to non-deprecated functions in GTK3 like...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1579
diff changeset
10568 size = gtk_widget_get_allocated_width(handle);
525c4c9d04c6 After switching to non-deprecated functions in GTK3 like...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1579
diff changeset
10569 else
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10570 size = gtk_widget_get_allocated_height(handle);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10571
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10572 if(mypercent)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10573 *mypercent = percent;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10574
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10575 if(size > 10)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10576 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10577 position = (int)((float)size * (percent / 100.0));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10578
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10579 gtk_paned_set_position(GTK_PANED(handle), position);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10580 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10581 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10582
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10583 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10584 * Gets the position of a splitbar (pecentage).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10585 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10586 * handle: The handle to the splitbar returned by dw_splitbar_new().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10587 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10588 float dw_splitbar_get(HWND handle)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10589 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10590 float *percent = (float *)dw_window_get_data(handle, "_dw_percent");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10591
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10592 if(percent)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10593 return *percent;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10594 return 0.0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10595 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10596
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10597 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10598 * Creates a calendar window (widget) with given parameters.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10599 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10600 * id: Unique identifier for calendar widget
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10601 * Returns:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10602 * A handle to a calendar window or NULL on failure.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10603 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10604 HWND dw_calendar_new(unsigned long id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10605 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10606 GtkWidget *tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10607 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10608 GtkCalendarDisplayOptions flags;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10609 time_t now;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10610 struct tm *tmdata;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10611
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10612 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10613 tmp = gtk_calendar_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10614 gtk_widget_show(tmp);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10615 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10616 /* select today */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10617 flags = GTK_CALENDAR_SHOW_HEADING|GTK_CALENDAR_SHOW_DAY_NAMES;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10618 gtk_calendar_set_display_options( GTK_CALENDAR(tmp), flags );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10619 now = time( NULL );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10620 tmdata = localtime( & now );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10621 gtk_calendar_select_month( GTK_CALENDAR(tmp), tmdata->tm_mon, 1900+tmdata->tm_year );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10622 gtk_calendar_select_day( GTK_CALENDAR(tmp), tmdata->tm_mday );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10623
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10624 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10625 return tmp;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10626 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10627
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10628 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10629 * Sets the current date of a calendar
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10630 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10631 * handle: The handle to the calendar returned by dw_calendar_new().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10632 * year...
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10633 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10634 void dw_calendar_set_date(HWND handle, unsigned int year, unsigned int month, unsigned int day)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10635 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10636 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10637
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10638 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10639 if(GTK_IS_CALENDAR(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10640 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10641 gtk_calendar_select_month(GTK_CALENDAR(handle),month-1,year);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10642 gtk_calendar_select_day(GTK_CALENDAR(handle), day);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10643 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10644 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10645 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10646 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10647
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10648 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10649 * Gets the position of a splitbar (pecentage).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10650 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10651 * handle: The handle to the splitbar returned by dw_splitbar_new().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10652 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10653 void dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10654 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10655 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10656
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10657 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10658 if(GTK_IS_CALENDAR(handle))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10659 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10660 gtk_calendar_get_date(GTK_CALENDAR(handle),year,month,day);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10661 *month = *month + 1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10662 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10663 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10664 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10665 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10666
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10667 /*
1795
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1793
diff changeset
10668 * Sets the current focus item for a window/dialog.
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1793
diff changeset
10669 * Parameters:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1793
diff changeset
10670 * handle: Handle to the dialog item to be focused.
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1793
diff changeset
10671 * Remarks:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1793
diff changeset
10672 * This is for use after showing the window/dialog.
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1793
diff changeset
10673 */
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1793
diff changeset
10674 void API dw_window_set_focus(HWND handle)
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1793
diff changeset
10675 {
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1793
diff changeset
10676 int _locked_by_me = FALSE;
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1793
diff changeset
10677
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1793
diff changeset
10678 if(!handle)
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1793
diff changeset
10679 return;
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1793
diff changeset
10680
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1793
diff changeset
10681 DW_MUTEX_LOCK;
1796
7f549994b633 Fixed tabs put in by TextMate 2... had to figure out how turn
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10682 gtk_widget_grab_focus(handle);
1795
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1793
diff changeset
10683 DW_MUTEX_UNLOCK;
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1793
diff changeset
10684 }
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1793
diff changeset
10685
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1793
diff changeset
10686 /*
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10687 * Sets the default focus item for a window/dialog.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10688 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10689 * window: Toplevel window or dialog.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10690 * defaultitem: Handle to the dialog item to be default.
1795
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1793
diff changeset
10691 * Remarks:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1793
diff changeset
10692 * This is for use before showing the window/dialog.
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10693 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10694 void dw_window_default(HWND window, HWND defaultitem)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10695 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10696 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10697
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10698 if(!window)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10699 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10700
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10701 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10702 g_object_set_data(G_OBJECT(window), "_dw_defaultitem", (gpointer)defaultitem);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10703 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10704 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10705
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10706 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10707 * Sets window to click the default dialog item when an ENTER is pressed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10708 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10709 * window: Window (widget) to look for the ENTER press.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10710 * next: Window (widget) to move to next (or click)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10711 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10712 void dw_window_click_default(HWND window, HWND next)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10713 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10714 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10715
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10716 if(!window)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10717 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10718
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10719 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10720 g_signal_connect(G_OBJECT(window), "key_press_event", G_CALLBACK(_default_key_press_event), next);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10721 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10722 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10723
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10724 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10725 * Returns some information about the current operating environment.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10726 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10727 * env: Pointer to a DWEnv struct.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10728 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10729 void dw_environment_query(DWEnv *env)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10730 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10731 struct utsname name;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10732 char tempbuf[100];
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10733 int len, z;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10734
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10735 uname(&name);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10736 strcpy(env->osName, name.sysname);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10737 strcpy(tempbuf, name.release);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10738
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10739 env->MajorBuild = env->MinorBuild = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10740
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10741 len = strlen(tempbuf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10742
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10743 strcpy(env->buildDate, __DATE__);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10744 strcpy(env->buildTime, __TIME__);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10745 env->DWMajorVersion = DW_MAJOR_VERSION;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10746 env->DWMinorVersion = DW_MINOR_VERSION;
1160
924c8087a755 Attempt to use the subversion revision number as the sub version number.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1158
diff changeset
10747 #ifdef VER_REV
1161
e4b13cd7a002 Update configure script and fix a miscommit of the GTK3 code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1160
diff changeset
10748 env->DWSubVersion = VER_REV;
1160
924c8087a755 Attempt to use the subversion revision number as the sub version number.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1158
diff changeset
10749 #else
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10750 env->DWSubVersion = DW_SUB_VERSION;
1160
924c8087a755 Attempt to use the subversion revision number as the sub version number.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1158
diff changeset
10751 #endif
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10752
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10753 for(z=1;z<len;z++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10754 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10755 if(tempbuf[z] == '.')
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10756 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10757 tempbuf[z] = '\0';
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10758 env->MajorVersion = atoi(&tempbuf[z-1]);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10759 env->MinorVersion = atoi(&tempbuf[z+1]);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10760 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10761 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10762 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10763 env->MajorVersion = atoi(tempbuf);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10764 env->MinorVersion = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10765 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10766
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10767 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10768 * Opens a file dialog and queries user selection.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10769 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10770 * title: Title bar text for dialog.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10771 * defpath: The default path of the open dialog.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10772 * ext: Default file extention.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10773 * flags: DW_FILE_OPEN or DW_FILE_SAVE or DW_DIRECTORY_OPEN
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10774 * Returns:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10775 * NULL on error. A malloced buffer containing
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10776 * the file path on success.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10777 *
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10778 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10779 char *dw_file_browse(char *title, char *defpath, char *ext, int flags)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10780 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10781 GtkWidget *filew;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10782
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10783 GtkFileChooserAction action;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10784 GtkFileFilter *filter1 = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10785 GtkFileFilter *filter2 = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10786 gchar *button;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10787 char *filename = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10788 char buf[1000];
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10789 char mypath[PATH_MAX+1];
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10790
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10791 switch (flags )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10792 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10793 case DW_DIRECTORY_OPEN:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10794 action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
10795 button = _("_Open");
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10796 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10797 case DW_FILE_OPEN:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10798 action = GTK_FILE_CHOOSER_ACTION_OPEN;
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
10799 button = _("_Open");
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10800 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10801 case DW_FILE_SAVE:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10802 action = GTK_FILE_CHOOSER_ACTION_SAVE;
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
10803 button = _("_Save");
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10804 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10805 default:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10806 dw_messagebox( "Coding error", DW_MB_OK|DW_MB_ERROR, "dw_file_browse() flags argument invalid.");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10807 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10808 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10809 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10810
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10811 filew = gtk_file_chooser_dialog_new ( title,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10812 NULL,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10813 action,
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
10814 _("_Cancel"), GTK_RESPONSE_CANCEL,
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10815 button, GTK_RESPONSE_ACCEPT,
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10816 NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10817
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10818 if ( flags == DW_FILE_SAVE )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10819 gtk_file_chooser_set_do_overwrite_confirmation( GTK_FILE_CHOOSER( filew ), TRUE );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10820
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10821 if ( ext )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10822 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10823 filter1 = gtk_file_filter_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10824 sprintf( buf, "*.%s", ext );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10825 gtk_file_filter_add_pattern( filter1, (gchar *)buf );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10826 sprintf( buf, "\"%s\" files", ext );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10827 gtk_file_filter_set_name( filter1, (gchar *)buf );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10828 filter2 = gtk_file_filter_new();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10829 gtk_file_filter_add_pattern( filter2, (gchar *)"*" );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10830 gtk_file_filter_set_name( filter2, (gchar *)"All Files" );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10831 gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( filew ), filter1 );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10832 gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( filew ), filter2 );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10833 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10834
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10835 if ( defpath )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10836 {
1295
d0c9d4d0ff3b Implement default filename support for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
10837 struct stat buf;
d0c9d4d0ff3b Implement default filename support for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
10838
877
d3693ceec9b1 Implemented dw_listbox_set_top() for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 876
diff changeset
10839 if ( g_path_is_absolute( defpath ) || !realpath(defpath, mypath))
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10840 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10841 strcpy( mypath, defpath );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10842 }
1295
d0c9d4d0ff3b Implement default filename support for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
10843
d0c9d4d0ff3b Implement default filename support for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
10844 /* See if the path exists */
d0c9d4d0ff3b Implement default filename support for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
10845 if(stat(mypath, &buf) == 0)
d0c9d4d0ff3b Implement default filename support for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
10846 {
d0c9d4d0ff3b Implement default filename support for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
10847 /* If the path is a directory... set the current folder */
d0c9d4d0ff3b Implement default filename support for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
10848 if(buf.st_mode & S_IFDIR)
d0c9d4d0ff3b Implement default filename support for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
10849 gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( filew ), mypath );
d0c9d4d0ff3b Implement default filename support for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
10850 else if(flags == DW_FILE_SAVE) /* Otherwise set the filename */
d0c9d4d0ff3b Implement default filename support for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
10851 gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( filew ), mypath );
d0c9d4d0ff3b Implement default filename support for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
10852 else if(flags == DW_FILE_OPEN)
d0c9d4d0ff3b Implement default filename support for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
10853 gtk_file_chooser_select_filename( GTK_FILE_CHOOSER( filew), mypath );
d0c9d4d0ff3b Implement default filename support for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
10854 }
d0c9d4d0ff3b Implement default filename support for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
10855 else if(flags == DW_FILE_SAVE)
d0c9d4d0ff3b Implement default filename support for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
10856 {
1300
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10857 if(strchr(mypath, '/'))
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10858 {
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10859 unsigned long x = strlen(mypath) - 1;
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10860
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10861 /* Trim off the filename */
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10862 while(x > 0 && mypath[x] != '/')
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10863 {
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10864 x--;
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10865 }
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10866 if(mypath[x] == '/')
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10867 {
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10868 char *file = NULL;
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10869 char temp[PATH_MAX+1];
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10870
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10871 /* Save the original path in temp */
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10872 strcpy(temp, mypath);
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10873 mypath[x] = 0;
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10874
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10875 /* Check to make sure the trimmed piece is a directory */
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10876 if(realpath(mypath, temp) && stat(temp, &buf) == 0)
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10877 {
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10878 if(buf.st_mode & S_IFDIR)
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10879 {
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10880 /* We now have it split */
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10881 file = &mypath[x+1];
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10882 }
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10883 }
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10884
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10885 /* Select folder... */
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10886 gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(filew), temp );
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10887 /* ... and file separately */
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10888 if(file)
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10889 gtk_file_chooser_set_current_name( GTK_FILE_CHOOSER(filew), file );
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10890 }
9c8de9cccc07 Fix for file and folder not being selected on GTK if file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1295
diff changeset
10891 }
1295
d0c9d4d0ff3b Implement default filename support for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
10892 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10893 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10894
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10895 if ( gtk_dialog_run( GTK_DIALOG( filew ) ) == GTK_RESPONSE_ACCEPT )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10896 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10897 filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( filew ) );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10898 /*g_free (filename);*/
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10899 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10900
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10901 gtk_widget_destroy( filew );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10902 return filename;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10903 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10904
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10905
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10906 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10907 * Execute and external program in a seperate session.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10908 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10909 * program: Program name with optional path.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10910 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10911 * params: An array of pointers to string arguements.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10912 * Returns:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10913 * -1 on error.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10914 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10915 int dw_exec(char *program, int type, char **params)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10916 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10917 int ret = -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10918
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10919 if((ret = fork()) == 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10920 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10921 int i;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10922
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10923 for (i = 3; i < 256; i++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10924 close(i);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10925 setsid();
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10926 if(type == DW_EXEC_GUI)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10927 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10928 execvp(program, params);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10929 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10930 else if(type == DW_EXEC_CON)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10931 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10932 char **tmpargs;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10933
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10934 if(!params)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10935 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10936 tmpargs = malloc(sizeof(char *));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10937 tmpargs[0] = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10938 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10939 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10940 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10941 int z = 0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10942
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10943 while(params[z])
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10944 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10945 z++;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10946 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10947 tmpargs = malloc(sizeof(char *)*(z+3));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10948 z=0;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10949 tmpargs[0] = "xterm";
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10950 tmpargs[1] = "-e";
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10951 while(params[z])
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10952 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10953 tmpargs[z+2] = params[z];
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10954 z++;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10955 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10956 tmpargs[z+2] = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10957 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10958 execvp("xterm", tmpargs);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10959 free(tmpargs);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10960 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10961 /* If we got here exec failed */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10962 _exit(-1);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10963 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10964 return ret;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10965 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10966
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10967 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10968 * Loads a web browser pointed at the given URL.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10969 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10970 * url: Uniform resource locator.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10971 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10972 int dw_browse(char *url)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10973 {
1118
63dd52ba9a8f Added support for attempting to launch a browser using a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1116
diff changeset
10974 /* If possible load the URL/URI using gvfs... */
63dd52ba9a8f Added support for attempting to launch a browser using a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1116
diff changeset
10975 if(gtk_show_uri(gdk_screen_get_default(), url, GDK_CURRENT_TIME, NULL))
63dd52ba9a8f Added support for attempting to launch a browser using a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1116
diff changeset
10976 {
63dd52ba9a8f Added support for attempting to launch a browser using a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1116
diff changeset
10977 return DW_ERROR_NONE;
63dd52ba9a8f Added support for attempting to launch a browser using a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1116
diff changeset
10978 }
63dd52ba9a8f Added support for attempting to launch a browser using a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1116
diff changeset
10979 else
63dd52ba9a8f Added support for attempting to launch a browser using a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1116
diff changeset
10980 {
63dd52ba9a8f Added support for attempting to launch a browser using a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1116
diff changeset
10981 /* Otherwise just fall back to executing firefox...
63dd52ba9a8f Added support for attempting to launch a browser using a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1116
diff changeset
10982 * or the browser defined by the DW_BROWSER variable.
63dd52ba9a8f Added support for attempting to launch a browser using a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1116
diff changeset
10983 */
63dd52ba9a8f Added support for attempting to launch a browser using a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1116
diff changeset
10984 char *execargs[3], *browser = "firefox", *tmp;
63dd52ba9a8f Added support for attempting to launch a browser using a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1116
diff changeset
10985
63dd52ba9a8f Added support for attempting to launch a browser using a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1116
diff changeset
10986 tmp = getenv( "DW_BROWSER" );
63dd52ba9a8f Added support for attempting to launch a browser using a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1116
diff changeset
10987 if(tmp) browser = tmp;
63dd52ba9a8f Added support for attempting to launch a browser using a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1116
diff changeset
10988 execargs[0] = browser;
63dd52ba9a8f Added support for attempting to launch a browser using a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1116
diff changeset
10989 execargs[1] = url;
63dd52ba9a8f Added support for attempting to launch a browser using a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1116
diff changeset
10990 execargs[2] = NULL;
63dd52ba9a8f Added support for attempting to launch a browser using a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1116
diff changeset
10991
63dd52ba9a8f Added support for attempting to launch a browser using a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1116
diff changeset
10992 return dw_exec(browser, DW_EXEC_GUI, execargs);
63dd52ba9a8f Added support for attempting to launch a browser using a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1116
diff changeset
10993 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10994 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10995
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10996 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10997 * Causes the embedded HTML widget to take action.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10998 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10999 * handle: Handle to the window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11000 * action: One of the DW_HTML_* constants.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11001 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11002 void dw_html_action(HWND handle, int action)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11003 {
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
11004 #ifdef USE_WEBKIT
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11005 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11006 WebKitWebView *web_view;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11007 WebKitWebFrame *frame;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11008
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11009 if (!_webkit_web_view_open)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11010 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11011
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11012 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11013 web_view = (WebKitWebView *)g_object_get_data(G_OBJECT(handle), "_dw_web_view");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11014 if ( web_view )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11015 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11016 switch( action )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11017 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11018 case DW_HTML_GOBACK:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11019 _webkit_web_view_go_back( web_view );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11020 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11021 case DW_HTML_GOFORWARD:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11022 _webkit_web_view_go_forward( web_view );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11023 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11024 case DW_HTML_GOHOME:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11025 _webkit_web_view_open( web_view, "http://dwindows.netlabs.org" );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11026 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11027 case DW_HTML_RELOAD:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11028 _webkit_web_view_reload( web_view );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11029 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11030 case DW_HTML_STOP:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11031 _webkit_web_view_stop_loading( web_view );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11032 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11033 case DW_HTML_PRINT:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11034 frame = _webkit_web_view_get_focused_frame( web_view );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11035 _webkit_web_frame_print( frame );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11036 break;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11037 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11038 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11039 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11040 #endif
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11041 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11042
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11043 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11044 * Render raw HTML code in the embedded HTML widget..
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11045 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11046 * handle: Handle to the window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11047 * string: String buffer containt HTML code to
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11048 * be rendered.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11049 * Returns:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11050 * 0 on success.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11051 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11052 int dw_html_raw(HWND handle, char *string)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11053 {
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
11054 #ifdef USE_WEBKIT
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11055 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11056 WebKitWebView *web_view;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11057
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11058 if (!_webkit_web_view_open)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11059 return -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11060
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11061 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11062 web_view = (WebKitWebView *)g_object_get_data(G_OBJECT(handle), "_dw_web_view");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11063 if ( web_view )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11064 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11065 _webkit_web_view_load_html_string( web_view, string, "file:///");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11066 gtk_widget_show( GTK_WIDGET(handle) );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11067 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11068 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11069 return 0;
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
11070 #else
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
11071 return -1;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11072 #endif
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11073 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11074
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11075 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11076 * Render file or web page in the embedded HTML widget..
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11077 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11078 * handle: Handle to the window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11079 * url: Universal Resource Locator of the web or
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11080 * file object to be rendered.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11081 * Returns:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11082 * 0 on success.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11083 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11084 int dw_html_url(HWND handle, char *url)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11085 {
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
11086 #ifdef USE_WEBKIT
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11087 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11088 WebKitWebView *web_view;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11089
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11090 if (!_webkit_web_view_open)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11091 return -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11092
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11093 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11094 web_view = (WebKitWebView *)g_object_get_data(G_OBJECT(handle), "_dw_web_view");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11095 if ( web_view )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11096 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11097 _webkit_web_view_open( web_view, url );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11098 gtk_widget_show(GTK_WIDGET(handle));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11099 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11100 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11101 return 0;
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
11102 #else
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11103 return -1;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11104 #endif
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
11105 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11106
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11107 #ifdef USE_WEBKIT
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11108 static void _dw_html_print_cb( GtkWidget *widget, gpointer *data )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11109 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11110 WebKitWebView *web_view = DW_WEBKIT_WEB_VIEW(data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11111 WebKitWebFrame *frame;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11112
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11113 frame = _webkit_web_view_get_focused_frame( web_view );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11114 _webkit_web_frame_print( frame );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11115 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11116 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11117 * Fired when the user right-clicks to get the popup-menu on the HTML widget
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11118 * We add a "Print" menu item to enable printing
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11119 * user_data is not used
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11120 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11121 static void _dw_html_populate_popup_cb( WebKitWebView *web_view, GtkMenu *menu, gpointer user_data )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11122 {
1892
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
11123 GtkWidget *item = gtk_menu_item_new_with_mnemonic( _("_Print") );
c4a6ef8291be Fix deprecation warnings by switching to newly available methods for 3.10.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1891
diff changeset
11124
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11125 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11126 g_signal_connect( item, "activate", G_CALLBACK(_dw_html_print_cb), web_view );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11127 gtk_widget_show(item);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11128 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11129 #endif
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11130
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11131 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11132 * Create a new Entryfield window (widget) to be packed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11133 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11134 * text: The default text to be in the entryfield widget.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11135 * id: An ID to be used with dw_window_from_id() or 0L.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11136 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11137 HWND dw_html_new(unsigned long id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11138 {
1355
dd252596227b Removed a now unused variable on GTK in dw_html_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1354
diff changeset
11139 GtkWidget *widget = NULL;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11140 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11141
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11142 DW_MUTEX_LOCK;
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
11143 #ifdef USE_WEBKIT
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11144 if (!_webkit_web_view_open)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11145 {
1358
2f5e54b0c5c4 dw_debug() lines in dw_html_new() should end with a newline.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1355
diff changeset
11146 dw_debug( "HTML widget not available; you do not have access to webkit.\n" );
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11147 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11148 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11149 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11150 WebKitWebView *web_view;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11151 widget = gtk_scrolled_window_new (NULL, NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11152 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW (widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11153 web_view = (WebKitWebView *)_webkit_web_view_new();
1320
6bebcfa03b2b Added support for dw_font_set_default() on GTK for appropriate widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
11154 /* web_view = WEBKIT_WEB_VIEW(_webkit_web_view_new() ); */
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11155 gtk_container_add( GTK_CONTAINER (widget), GTK_WIDGET(web_view) );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11156 gtk_widget_show( GTK_WIDGET(web_view) );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11157 g_object_set_data(G_OBJECT(widget), "_dw_web_view", (gpointer)web_view);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11158 g_signal_connect( web_view, "populate-popup", G_CALLBACK(_dw_html_populate_popup_cb), NULL );
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11159 }
1354
1f22addc2722 Changed the behavior of dw_html_new() to return NULL on failure like the documentation indicates...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1353
diff changeset
11160 gtk_widget_show(widget);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11161 #else
1358
2f5e54b0c5c4 dw_debug() lines in dw_html_new() should end with a newline.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1355
diff changeset
11162 dw_debug( "HTML widget not available; you do not have access to webkit.\n" );
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11163 #endif
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11164 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11165 return widget;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11166 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11167
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11168 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11169 * Gets the contents of the default clipboard as text.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11170 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11171 * None.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11172 * Returns:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11173 * Pointer to an allocated string of text or NULL if clipboard empty or contents could not
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11174 * be converted to text.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11175 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11176 char *dw_clipboard_get_text()
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11177 {
971
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11178 int _locked_by_me = FALSE;
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11179 GtkClipboard *clipboard_object;
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11180 char *ret = NULL;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
11181
971
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11182 DW_MUTEX_LOCK;
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11183 if((clipboard_object = gtk_clipboard_get( GDK_SELECTION_CLIPBOARD )))
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11184 {
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11185 gchar *clipboard_contents;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
11186
971
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11187 if((clipboard_contents = gtk_clipboard_wait_for_text( clipboard_object )))
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11188 {
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11189 ret = strdup((char *)clipboard_contents);
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11190 g_free(clipboard_contents);
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11191 }
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11192 }
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11193 DW_MUTEX_UNLOCK;
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11194 return ret;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11195 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11196
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11197 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11198 * Sets the contents of the default clipboard to the supplied text.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11199 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11200 * Text.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11201 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11202 void dw_clipboard_set_text( char *str, int len )
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11203 {
971
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11204 int _locked_by_me = FALSE;
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11205 GtkClipboard *clipboard_object;
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11206
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11207 DW_MUTEX_LOCK;
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11208 if((clipboard_object = gtk_clipboard_get( GDK_SELECTION_CLIPBOARD )))
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11209 {
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11210 gtk_clipboard_set_text( clipboard_object, str, len );
2a21915684d1 Step 1 in modernizing the GTK3 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 959
diff changeset
11211 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11212 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11213 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11214
1136
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11215 /* Internal function to create the drawable pixmap and call the function */
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11216 static void _dw_draw_page(GtkPrintOperation *operation, GtkPrintContext *context, int page_nr)
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11217 {
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11218 cairo_t *cr = gtk_print_context_get_cairo_context(context);
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11219 void *drawdata = g_object_get_data(G_OBJECT(operation), "_dw_drawdata");
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11220 int (*drawfunc)(HPRINT, HPIXMAP, int, void *) = g_object_get_data(G_OBJECT(operation), "_dw_drawfunc");
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11221 int result = 0;
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11222 HPIXMAP pixmap;
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11223
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11224 if(cr && drawfunc && (pixmap = calloc(1,sizeof(struct _hpixmap))))
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11225 {
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11226 pixmap->image = cairo_get_group_target(cr);
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11227 pixmap->handle = (HWND)operation;
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11228 pixmap->width = gtk_print_context_get_width(context);
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11229 pixmap->height = gtk_print_context_get_height(context);
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11230 result = drawfunc((HPRINT)operation, pixmap, page_nr, drawdata);
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11231 if(result)
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11232 gtk_print_operation_draw_page_finish(operation);
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11233 free(pixmap);
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11234 }
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11235 }
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11236
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11237 /*
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11238 * Creates a new print object.
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11239 * Parameters:
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1149
diff changeset
11240 * jobname: Name of the print job to show in the queue.
1136
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11241 * flags: Flags to initially configure the print object.
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11242 * pages: Number of pages to print.
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11243 * drawfunc: The pointer to the function to be used as the callback.
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11244 * drawdata: User data to be passed to the handler function.
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11245 * Returns:
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1136
diff changeset
11246 * A handle to the print object or NULL on failure.
1136
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11247 */
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1149
diff changeset
11248 HPRINT API dw_print_new(char *jobname, unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata)
1136
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11249 {
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11250 GtkPrintOperation *op;
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11251 int _locked_by_me = FALSE;
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11252
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11253 if(!drawfunc)
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11254 return NULL;
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11255
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11256 DW_MUTEX_LOCK;
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11257 if((op = gtk_print_operation_new()))
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11258 {
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11259 gtk_print_operation_set_n_pages(op, pages);
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1149
diff changeset
11260 gtk_print_operation_set_job_name(op, jobname ? jobname : "Dynamic Windows Print Job");
1136
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11261 g_object_set_data(G_OBJECT(op), "_dw_drawfunc", drawfunc);
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11262 g_object_set_data(G_OBJECT(op), "_dw_drawdata", drawdata);
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11263 g_signal_connect(op, "draw_page", G_CALLBACK(_dw_draw_page), NULL);
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11264 }
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11265 DW_MUTEX_UNLOCK;
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11266 return (HPRINT)op;
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11267 }
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11268
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11269 /*
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11270 * Runs the print job, causing the draw page callbacks to fire.
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11271 * Parameters:
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11272 * print: Handle to the print object returned by dw_print_new().
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11273 * flags: Flags to run the print job.
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11274 * Returns:
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11275 * DW_ERROR_UNKNOWN on error or DW_ERROR_NONE on success.
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11276 */
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11277 int API dw_print_run(HPRINT print, unsigned long flags)
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11278 {
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11279 GtkPrintOperationResult res;
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11280 GtkPrintOperation *op = (GtkPrintOperation *)print;
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11281 int _locked_by_me = FALSE;
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11282
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11283 DW_MUTEX_LOCK;
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11284 res = gtk_print_operation_run(op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL, NULL);
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11285 DW_MUTEX_UNLOCK;
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11286 return (res == GTK_PRINT_OPERATION_RESULT_ERROR ? DW_ERROR_UNKNOWN : DW_ERROR_NONE);
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11287 }
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11288
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11289 /*
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11290 * Cancels the print job, typically called from a draw page callback.
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11291 * Parameters:
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11292 * print: Handle to the print object returned by dw_print_new().
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11293 */
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11294 void API dw_print_cancel(HPRINT print)
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11295 {
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11296 int _locked_by_me = FALSE;
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11297 GtkPrintOperation *op = (GtkPrintOperation *)print;
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11298
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11299 DW_MUTEX_LOCK;
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11300 gtk_print_operation_cancel(op);
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11301 DW_MUTEX_UNLOCK;
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11302 }
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11303
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11304 /*
1a5b0908659b Initial implementation of the DynamicWindows Print object for GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1127
diff changeset
11305 * Returns a pointer to a static buffer which contains the
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11306 * current user directory. Or the root directory (C:\ on
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11307 * OS/2 and Windows).
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11308 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11309 char *dw_user_dir(void)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11310 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11311 static char _user_dir[1024] = "";
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11312
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11313 if(!_user_dir[0])
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11314 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11315 char *home = getenv("HOME");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11316
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11317 if(home)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11318 strcpy(_user_dir, home);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11319 else
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11320 strcpy(_user_dir, "/");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11321 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11322 return _user_dir;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11323 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11324
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11325 /*
1384
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
11326 * Returns a pointer to a static buffer which containes the
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
11327 * private application data directory.
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
11328 */
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
11329 char * API dw_app_dir(void)
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
11330 {
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
11331 return _dw_share_path;
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
11332 }
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
11333
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1373
diff changeset
11334 /*
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11335 * Call a function from the window (widget)'s context.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11336 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11337 * handle: Window handle of the widget.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11338 * function: Function pointer to be called.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11339 * data: Pointer to the data to be passed to the function.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11340 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11341 void dw_window_function(HWND handle, void *function, void *data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11342 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11343 void (* windowfunc)(void *);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11344
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11345 windowfunc = function;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11346
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11347 if(windowfunc)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11348 windowfunc(data);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11349 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11350
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11351 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11352 * Add a named user data item to a window handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11353 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11354 * window: Window handle of signal to be called back.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11355 * dataname: A string pointer identifying which signal to be hooked.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11356 * data: User data to be passed to the handler function.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11357 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11358 void dw_window_set_data(HWND window, char *dataname, void *data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11359 {
784
fb21fdd6b839 Slight code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 783
diff changeset
11360 HWND thiswindow = window;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11361 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11362
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11363 if(!window)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11364 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11365
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11366 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11367 if(GTK_IS_SCROLLED_WINDOW(window))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11368 {
784
fb21fdd6b839 Slight code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 783
diff changeset
11369 thiswindow = (HWND)g_object_get_data(G_OBJECT(window), "_dw_user");
fb21fdd6b839 Slight code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 783
diff changeset
11370 }
fb21fdd6b839 Slight code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 783
diff changeset
11371 if(thiswindow && G_IS_OBJECT(thiswindow))
fb21fdd6b839 Slight code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 783
diff changeset
11372 g_object_set_data(G_OBJECT(thiswindow), dataname, (gpointer)data);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11373 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11374 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11375
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11376 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11377 * Gets a named user data item to a window handle.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11378 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11379 * window: Window handle of signal to be called back.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11380 * dataname: A string pointer identifying which signal to be hooked.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11381 * data: User data to be passed to the handler function.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11382 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11383 void *dw_window_get_data(HWND window, char *dataname)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11384 {
784
fb21fdd6b839 Slight code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 783
diff changeset
11385 HWND thiswindow = window;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11386 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11387 void *ret = NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11388
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11389 if(!window)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11390 return NULL;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11391
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11392 DW_MUTEX_LOCK;
784
fb21fdd6b839 Slight code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 783
diff changeset
11393 if(GTK_IS_SCROLLED_WINDOW(window))
fb21fdd6b839 Slight code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 783
diff changeset
11394 {
fb21fdd6b839 Slight code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 783
diff changeset
11395 thiswindow = (HWND)g_object_get_data(G_OBJECT(window), "_dw_user");
fb21fdd6b839 Slight code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 783
diff changeset
11396 }
fb21fdd6b839 Slight code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 783
diff changeset
11397 if(G_IS_OBJECT(thiswindow))
fb21fdd6b839 Slight code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 783
diff changeset
11398 ret = (void *)g_object_get_data(G_OBJECT(thiswindow), dataname);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11399 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11400 return ret;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11401 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11402
874
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11403 /* Internal function to get the state of the timer before firing */
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11404 gboolean _dw_timer_func(gpointer data)
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11405 {
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11406 void (*sigfunc)(void *data) = NULL;
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11407 void *sdata;
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
11408 char tmpbuf[31] = {0};
874
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11409 int *tag = data;
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
11410
874
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11411 if(tag)
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11412 {
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11413 snprintf(tmpbuf, 30, "_dw_timer%d", *tag);
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11414 sigfunc = g_object_get_data(G_OBJECT(_DWObject), tmpbuf);
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11415 snprintf(tmpbuf, 30, "_dw_timerdata%d", *tag);
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11416 sdata = g_object_get_data(G_OBJECT(_DWObject), tmpbuf);
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11417 }
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11418 if(!sigfunc)
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11419 {
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11420 if(tag)
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11421 free(tag);
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11422 return FALSE;
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11423 }
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11424 sigfunc(sdata);
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11425 return TRUE;
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11426 }
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11427
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11428 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11429 * Add a callback to a timer event.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11430 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11431 * interval: Milliseconds to delay between calls.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11432 * sigfunc: The pointer to the function to be used as the callback.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11433 * data: User data to be passed to the handler function.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11434 * Returns:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11435 * Timer ID for use with dw_timer_disconnect(), 0 on error.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11436 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11437 int API dw_timer_connect(int interval, void *sigfunc, void *data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11438 {
874
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11439 int *tag, _locked_by_me = FALSE;
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
11440 char tmpbuf[31] = {0};
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
11441
874
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11442 tag = calloc(1, sizeof(int));
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
11443
874
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11444 DW_MUTEX_LOCK;
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11445 *tag = g_timeout_add(interval, (GSourceFunc)_dw_timer_func, (gpointer)tag);
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11446 snprintf(tmpbuf, 30, "_dw_timer%d", *tag);
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11447 g_object_set_data(G_OBJECT(_DWObject), tmpbuf, sigfunc);
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11448 snprintf(tmpbuf, 30, "_dw_timerdata%d", *tag);
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11449 g_object_set_data(G_OBJECT(_DWObject), tmpbuf, data);
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11450 DW_MUTEX_UNLOCK;
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11451 return *tag;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11452 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11453
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11454 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11455 * Removes timer callback.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11456 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11457 * id: Timer ID returned by dw_timer_connect().
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11458 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11459 void API dw_timer_disconnect(int id)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11460 {
874
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11461 int _locked_by_me = FALSE;
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1300
diff changeset
11462 char tmpbuf[31] = {0};
876
13442724eb5d One last change... use 30 bytes instead of 20... don't want to overflow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 875
diff changeset
11463
13442724eb5d One last change... use 30 bytes instead of 20... don't want to overflow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 875
diff changeset
11464 snprintf(tmpbuf, 30, "_dw_timer%d", id);
874
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11465 DW_MUTEX_LOCK;
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11466 g_object_set_data(G_OBJECT(_DWObject), tmpbuf, NULL);
876
13442724eb5d One last change... use 30 bytes instead of 20... don't want to overflow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 875
diff changeset
11467 snprintf(tmpbuf, 30, "_dw_timerdata%d", id);
875
e1afa43261d9 After thinking about it... probably need to get rid of the saved data to so we don't leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 874
diff changeset
11468 g_object_set_data(G_OBJECT(_DWObject), tmpbuf, NULL);
874
18eab415ff0c Rewrote the timers for GTK3. Due to the removal of the timer remove by ID function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 861
diff changeset
11469 DW_MUTEX_UNLOCK;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11470 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11471
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11472 /* Get the actual signal window handle not the user window handle
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11473 * Should mimic the code in dw_signal_connect() below.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11474 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11475 static HWND _find_signal_window(HWND window, char *signame)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11476 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11477 HWND thiswindow = window;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11478
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11479 if(GTK_IS_SCROLLED_WINDOW(thiswindow))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11480 thiswindow = (HWND)g_object_get_data(G_OBJECT(window), "_dw_user");
1583
525c4c9d04c6 After switching to non-deprecated functions in GTK3 like...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1579
diff changeset
11481 else if(GTK_IS_SCALE(thiswindow) || GTK_IS_SCROLLBAR(thiswindow) || GTK_IS_SPIN_BUTTON(thiswindow))
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11482 thiswindow = (GtkWidget *)g_object_get_data(G_OBJECT(thiswindow), "_dw_adjustment");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11483 else if(GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_SELECT) == 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11484 thiswindow = (GtkWidget *)gtk_tree_view_get_selection(GTK_TREE_VIEW(thiswindow));
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11485 return thiswindow;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11486 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11487
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11488 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11489 * Add a callback to a window event.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11490 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11491 * window: Window handle of signal to be called back.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11492 * signame: A string pointer identifying which signal to be hooked.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11493 * sigfunc: The pointer to the function to be used as the callback.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11494 * data: User data to be passed to the handler function.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11495 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11496 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11497 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11498 dw_signal_connect_data(window, signame, sigfunc, NULL, data);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11499 }
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11500
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11501 /* Internal function to free any allocated signal data..
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11502 * and call any required function to free additional memory.
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11503 */
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11504 static void _dw_signal_disconnect(gpointer data, GClosure *closure)
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11505 {
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11506 if(data)
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11507 {
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11508 void **params = (void **)data;
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11509 void (*discfunc)(HWND, void *) = params[1];
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11510
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11511 if(discfunc)
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11512 {
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11513 SignalHandler work = _get_signal_handler(data);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11514
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11515 if(work.window)
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11516 {
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11517 discfunc(work.window, work.data);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11518 }
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11519 }
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11520 free(data);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11521 }
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11522 }
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11523
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11524 /*
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11525 * Add a callback to a window event with a closure callback.
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11526 * Parameters:
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11527 * window: Window handle of signal to be called back.
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11528 * signame: A string pointer identifying which signal to be hooked.
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11529 * sigfunc: The pointer to the function to be used as the callback.
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11530 * discfunc: The pointer to the function called when this handler is removed.
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11531 * data: User data to be passed to the handler function.
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11532 */
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11533 void dw_signal_connect_data(HWND window, char *signame, void *sigfunc, void *discfunc, void *data)
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11534 {
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11535 void *thisfunc = _findsigfunc(signame);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11536 char *thisname = signame;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11537 HWND thiswindow = window;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11538 int sigid, _locked_by_me = FALSE;
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11539 void **params = calloc(3, sizeof(void *));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11540 gint cid;
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11541
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11542 /* Save the disconnect function pointer */
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11543 params[1] = discfunc;
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11544
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11545 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11546 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11547 * If the window we are setting the signal on is a scrolled window we need to get
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11548 * the "real" widget type. thiswindow is the "real" widget type
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11549 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11550 if (GTK_IS_SCROLLED_WINDOW(thiswindow))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11551 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11552 thiswindow = (HWND)g_object_get_data(G_OBJECT(window), "_dw_user");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11553 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11554
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
11555 if (strcmp(signame, DW_SIGNAL_EXPOSE) == 0)
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
11556 {
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
11557 thisname = "draw";
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
11558 }
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
11559 else if (GTK_IS_MENU_ITEM(thiswindow) && strcmp(signame, DW_SIGNAL_CLICKED) == 0)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11560 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11561 thisname = "activate";
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11562 thisfunc = _findsigfunc(thisname);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11563 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11564 else if (GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_CONTEXT) == 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11565 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11566 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, thisfunc, discfunc);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11567 params[0] = GINT_TO_POINTER(sigid);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11568 params[2] = (void *)thiswindow;
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11569 cid = g_signal_connect_data(G_OBJECT(thiswindow), "button_press_event", G_CALLBACK(thisfunc), params, _dw_signal_disconnect, 0);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11570 _set_signal_handler_id(thiswindow, sigid, cid);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11571
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11572 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11573 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11574 }
785
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
11575 else if ((GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_SELECT) == 0) ||
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
11576 (GTK_IS_COMBO_BOX(thiswindow) && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0))
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
11577 {
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
11578 GtkWidget *widget = thiswindow;
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
11579
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11580 thisname = "changed";
1096
5261439c7227 Fix bug with setting up container on 64bit platform.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1092
diff changeset
11581
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11582 sigid = _set_signal_handler(widget, window, sigfunc, data, thisfunc, discfunc);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11583 params[0] = GINT_TO_POINTER(sigid);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11584 params[2] = (void *)thiswindow;
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
11585 if(GTK_IS_TREE_VIEW(thiswindow))
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
11586 {
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
11587 thiswindow = (GtkWidget *)gtk_tree_view_get_selection(GTK_TREE_VIEW(thiswindow));
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11588 cid = g_signal_connect_data(G_OBJECT(thiswindow), thisname, G_CALLBACK(thisfunc), params, _dw_signal_disconnect, 0);
785
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
11589 }
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
11590 else
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
11591 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11592 cid = g_signal_connect_data(G_OBJECT(thiswindow), thisname, G_CALLBACK(_combobox_select_event), params, _dw_signal_disconnect, 0);
785
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
11593 }
a86c54519de0 Implemented list select event for both combobox and listbox (implemented via the tree view).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 784
diff changeset
11594 _set_signal_handler_id(widget, sigid, cid);
779
d67d2f626c33 More code and cleanups for listboxes/combobox and event handling...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 778
diff changeset
11595
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11596 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11597 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11598 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11599 else if (GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_TREE_EXPAND) == 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11600 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11601 thisname = "row-expanded";
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11602 }
783
9ef49898a5e6 Container events now working except for column-click.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 782
diff changeset
11603 else if (GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_ENTER) == 0)
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11604 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11605 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, _container_enter_event, discfunc);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11606 params[0] = GINT_TO_POINTER(sigid);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11607 params[2] = (void *)thiswindow;
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11608 cid = g_signal_connect_data(G_OBJECT(thiswindow), "key_press_event", G_CALLBACK(_container_enter_event), params, _dw_signal_disconnect, 0);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11609 _set_signal_handler_id(thiswindow, sigid, cid);
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11610
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11611 params = calloc(sizeof(void *), 3);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11612
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11613 thisname = "button_press_event";
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11614 thisfunc = _findsigfunc(DW_SIGNAL_ITEM_ENTER);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11615 }
786
0e251c2f5d08 Implemented the column click event handler...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 785
diff changeset
11616 else if (GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_COLUMN_CLICK) == 0)
0e251c2f5d08 Implemented the column click event handler...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 785
diff changeset
11617 {
0e251c2f5d08 Implemented the column click event handler...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 785
diff changeset
11618 /* We don't actually need a signal handler here... just need to assign the handler ID
0e251c2f5d08 Implemented the column click event handler...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 785
diff changeset
11619 * Since the handlers for the columns were already created in _dw_container_setup()
0e251c2f5d08 Implemented the column click event handler...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 785
diff changeset
11620 */
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11621 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, _column_click_event, discfunc);
788
f8f4f72d6462 Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 787
diff changeset
11622 g_object_set_data(G_OBJECT(thiswindow), "_dw_column_click_id", GINT_TO_POINTER(sigid+1));
786
0e251c2f5d08 Implemented the column click event handler...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 785
diff changeset
11623 DW_MUTEX_UNLOCK;
0e251c2f5d08 Implemented the column click event handler...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 785
diff changeset
11624 return;
0e251c2f5d08 Implemented the column click event handler...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 785
diff changeset
11625 }
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11626 else if (strcmp(signame, DW_SIGNAL_SET_FOCUS) == 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11627 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11628 thisname = "focus-in-event";
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11629 if (GTK_IS_COMBO_BOX(thiswindow))
789
8fe51d916b36 Reenabled the set-focus code that was disabled due to combobox issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 788
diff changeset
11630 thiswindow = gtk_bin_get_child(GTK_BIN(thiswindow));
8fe51d916b36 Reenabled the set-focus code that was disabled due to combobox issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 788
diff changeset
11631 }
8fe51d916b36 Reenabled the set-focus code that was disabled due to combobox issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 788
diff changeset
11632 #if 0
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11633 else if (strcmp(signame, DW_SIGNAL_LOSE_FOCUS) == 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11634 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11635 thisname = "focus-out-event";
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11636 if(GTK_IS_COMBO_BOX(thiswindow))
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11637 thiswindow = GTK_COMBO_BOX(thiswindow)->entry;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11638 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11639 #endif
1583
525c4c9d04c6 After switching to non-deprecated functions in GTK3 like...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1579
diff changeset
11640 else if (GTK_IS_SCALE(thiswindow) || GTK_IS_SCROLLBAR(thiswindow) || GTK_IS_SPIN_BUTTON(thiswindow) )
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11641 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11642 thiswindow = (GtkWidget *)g_object_get_data(G_OBJECT(thiswindow), "_dw_adjustment");
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11643 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11644 else if (GTK_IS_NOTEBOOK(thiswindow) && strcmp(signame, DW_SIGNAL_SWITCH_PAGE) == 0)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11645 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11646 thisname = "switch-page";
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11647 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11648
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11649 if (!thisfunc || !thiswindow)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11650 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11651 free(params);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11652 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11653 return;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11654 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11655
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11656 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, thisfunc, discfunc);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11657 params[0] = GINT_TO_POINTER(sigid);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11658 params[2] = (void *)thiswindow;
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11659 cid = g_signal_connect_data(G_OBJECT(thiswindow), thisname, G_CALLBACK(thisfunc), params, _dw_signal_disconnect, 0);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11660 _set_signal_handler_id(thiswindow, sigid, cid);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11661 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11662 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11663
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11664 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11665 * Removes callbacks for a given window with given name.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11666 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11667 * window: Window handle of callback to be removed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11668 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11669 void dw_signal_disconnect_by_name(HWND window, char *signame)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11670 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11671 int z, count;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11672 void *thisfunc;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11673 int _locked_by_me = FALSE;
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11674 void **params = alloca(sizeof(void *) * 3);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11675
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11676 DW_MUTEX_LOCK;
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11677 params[2] = _find_signal_window(window, signame);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11678 count = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(params[2]), "_dw_sigcounter"));
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11679 thisfunc = _findsigfunc(signame);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11680
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11681 for(z=0;z<count;z++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11682 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11683 SignalHandler sh;
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11684
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11685 params[0] = GINT_TO_POINTER(z);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11686 sh = _get_signal_handler(params);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11687
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11688 if(sh.intfunc == thisfunc)
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11689 _remove_signal_handler((HWND)params[2], z);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11690 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11691 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11692 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11693
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11694 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11695 * Removes all callbacks for a given window.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11696 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11697 * window: Window handle of callback to be removed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11698 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11699 void dw_signal_disconnect_by_window(HWND window)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11700 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11701 HWND thiswindow;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11702 int z, count;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11703 int _locked_by_me = FALSE;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11704
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11705 DW_MUTEX_LOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11706 thiswindow = _find_signal_window(window, NULL);
1092
0fc7387abfd1 Similar GTK3 changes to what I just committed for GTK2, to avoid casting warnings on 64bit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1087
diff changeset
11707 count = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(thiswindow), "_dw_sigcounter"));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11708
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11709 for(z=0;z<count;z++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11710 _remove_signal_handler(thiswindow, z);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11711 g_object_set_data(G_OBJECT(thiswindow), "_dw_sigcounter", NULL);
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11712 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11713 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11714
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11715 /*
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11716 * Removes all callbacks for a given window with specified data.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11717 * Parameters:
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11718 * window: Window handle of callback to be removed.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11719 * data: Pointer to the data to be compared against.
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11720 */
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11721 void dw_signal_disconnect_by_data(HWND window, void *data)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11722 {
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11723 int z, count;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11724 int _locked_by_me = FALSE;
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11725 void **params = alloca(sizeof(void *) * 3);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11726
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11727 DW_MUTEX_LOCK;
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11728 params[2] = _find_signal_window(window, NULL);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11729 count = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(params[2]), "_dw_sigcounter"));
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11730
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11731 for(z=0;z<count;z++)
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11732 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11733 SignalHandler sh;
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11734
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11735 params[0] = GINT_TO_POINTER(z);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11736 sh = _get_signal_handler(params);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11737
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11738 if(sh.data == data)
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1847
diff changeset
11739 _remove_signal_handler((HWND)params[2], z);
775
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11740 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11741 DW_MUTEX_UNLOCK;
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11742 }
5ec50e403a8a Added initial support for GTK 3.0. Split it off into its own directory.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11743
1785
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11744 /*
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11745 * Converts a UTF-8 encoded string into a wide string.
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11746 * Parameters:
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11747 * utf8string: UTF-8 encoded source string.
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11748 * Returns:
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11749 * Wide string that needs to be freed with dw_free()
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11750 * or NULL on failure.
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11751 */
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11752 wchar_t * API dw_utf8_to_wchar(char *utf8string)
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11753 {
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11754 wchar_t *retval = NULL, *freeme;
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11755
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11756 if(sizeof(wchar_t) == sizeof(gunichar))
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11757 freeme = retval = (wchar_t *)g_utf8_to_ucs4(utf8string, -1, NULL, NULL, NULL);
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11758 else if(sizeof(wchar_t) == sizeof(gunichar2))
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11759 freeme = retval = (wchar_t *)g_utf8_to_utf16(utf8string, -1, NULL, NULL, NULL);
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11760 if(retval)
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11761 {
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11762 retval = wcsdup(retval);
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11763 g_free(freeme);
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11764 }
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11765 return retval;
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11766 }
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11767
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11768 /*
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11769 * Converts a wide string into a UTF-8 encoded string.
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11770 * Parameters:
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11771 * wstring: Wide source string.
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11772 * Returns:
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11773 * UTF-8 encoded string that needs to be freed with dw_free()
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11774 * or NULL on failure.
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11775 */
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11776 char * API dw_wchar_to_utf8(wchar_t *wstring)
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11777 {
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11778 char *retval = NULL, *freeme;
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11779
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11780 if(sizeof(wchar_t) == sizeof(gunichar))
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11781 freeme = retval = g_ucs4_to_utf8((gunichar *)wstring, -1, NULL, NULL, NULL);
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11782 else if(sizeof(wchar_t) == sizeof(gunichar2))
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11783 freeme = retval = g_utf16_to_utf8((gunichar2 *)wstring, -1, NULL, NULL, NULL);
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11784 if(retval)
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11785 {
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11786 retval = strdup(retval);
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11787 g_free(freeme);
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11788 }
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11789 return retval;
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11790 }
c5ea64e8b436 Added UTF8/Wide conversion for GTK2/3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
11791