]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/utilsres.cpp
gtk_signal_connect -> g_signal_connect in unix/mediactrl.cpp
[wxWidgets.git] / src / gtk / utilsres.cpp
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
bd046d42 2// Name: utilres.cpp
c801d85f
KB
3// Purpose:
4// Author: Robert Roebling
a81258be 5// Id: $Id$
bd046d42 6// Copyright: (c) 1998 Robert Roebling
65571936 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
14f355c2
VS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
c801d85f
KB
13#include "wx/utils.h"
14#include "wx/string.h"
15#include "wx/list.h"
c693edf3 16#include "wx/log.h"
bd046d42
RR
17#include "wx/config.h"
18#include "wx/app.h"
c801d85f
KB
19
20//-----------------------------------------------------------------------------
21// resource functions
22//-----------------------------------------------------------------------------
23
24bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file )
25{
bd046d42 26 wxString filename( file );
e7d9c398 27 if (filename.IsEmpty()) filename = wxT(".wxWindows");
3d257b8d 28
bd046d42 29 wxFileConfig conf( wxTheApp->GetAppName(), wxTheApp->GetVendorName(), filename );
3d257b8d 30
bd046d42 31 conf.SetPath( section );
3d257b8d 32
bd046d42
RR
33 return conf.Write( entry, value );
34}
c801d85f
KB
35
36bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file )
37{
bd046d42
RR
38 wxString buf;
39 buf.Printf(wxT("%.4f"), value);
40
c801d85f 41 return wxWriteResource(section, entry, buf, file);
bd046d42 42}
c801d85f
KB
43
44bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file )
45{
bd046d42
RR
46 wxString buf;
47 buf.Printf(wxT("%ld"), value);
48
c801d85f 49 return wxWriteResource(section, entry, buf, file);
bd046d42 50}
c801d85f
KB
51
52bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file )
53{
bd046d42
RR
54 wxString buf;
55 buf.Printf(wxT("%d"), value);
56
c801d85f 57 return wxWriteResource(section, entry, buf, file);
bd046d42 58}
c801d85f 59
cbf97a6c 60bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file )
c801d85f 61{
bd046d42 62 wxString filename( file );
e7d9c398 63 if (filename.IsEmpty()) filename = wxT(".wxWindows");
9c2882d9 64
bd046d42 65 wxFileConfig conf( wxTheApp->GetAppName(), wxTheApp->GetVendorName(), filename );
9c2882d9 66
bd046d42 67 conf.SetPath( section );
9c2882d9 68
bd046d42 69 wxString result;
9c2882d9 70 if (conf.Read( entry, &result ))
3e61c765 71 {
bd046d42 72 if (!result.IsEmpty())
9c2882d9 73 {
cbf97a6c 74 wxChar *s = new wxChar[result.Len()+1];
9c2882d9
VZ
75 wxStrcpy( s, result.c_str() );
76 *value = s;
77 return TRUE;
78 }
c801d85f 79 }
9c2882d9 80
c801d85f 81 return FALSE;
bd046d42 82}
c801d85f
KB
83
84bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file )
85{
bd046d42
RR
86 wxChar *s = NULL;
87 bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
88 if (succ)
3e61c765 89 {
bd046d42
RR
90 *value = (float)wxStrtod(s, NULL);
91 delete[] s;
a3622daa 92 return TRUE;
bd046d42
RR
93 }
94 else return FALSE;
95}
c801d85f
KB
96
97bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file )
98{
bd046d42
RR
99 wxChar *s = NULL;
100 bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
101 if (succ)
3e61c765 102 {
bd046d42
RR
103 *value = wxStrtol(s, NULL, 10);
104 delete[] s;
a3622daa 105 return TRUE;
bd046d42
RR
106 }
107 else return FALSE;
108}
c801d85f
KB
109
110bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file )
111{
bd046d42
RR
112 wxChar *s = NULL;
113 bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
114 if (succ)
3e61c765 115 {
bd046d42
RR
116 *value = (int)wxStrtol(s, NULL, 10);
117 delete[] s;
a3622daa 118 return TRUE;
bd046d42
RR
119 }
120 else return FALSE;
121}
c801d85f 122