~ubuntu-branches/ubuntu/quantal/openmotif/quantal

« back to all changes in this revision

Viewing changes to demos/programs/hellomotifi18n/helloint.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Bauer
  • Date: 2010-06-23 12:12:31 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100623121231-u89gxdp51sg9wjj2
Tags: 2.3.0-1
* New Maintainer (Closes: #379258) 
* Acknowledge NMU changes
* New upstream release (Closes: #494375)
* Get rid of security patches as they are already part of new upstream
  release (00-xpmvuln.openmotif.patch, 342092-CVE-2005-3964.patch)
* Bump Standards to 3.8.4
* Added {misc:Depends} to make the package lintian cleaner
* Fix weak-library-dev-dependency by adding ${binary:Version}) for the
  -dev Package of openmotif
* Let package depend on autotools-dev to use newer autotools-helper-files
* Work around an autoconf-bug (Gentoo-Bug #1475)
* Added Client-side anti-aliased fonts support via XFT
* Added UTF-8 and UTF8_STRING atom support
* Ability to show text and pixmaps in Label, LabelGadget and all
  derived widgets
* Support of PNG/JPEG image formats in the same way as XPM is supported
* Increase FILE_OFFSET_BITS to 64 to show files >2GB in file-selector
  Idea taken from Magne Oestlyngen (Closes: #288537)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $XConsortium: helloint.c /main/5 1995/07/15 20:45:32 drk $ */
 
2
/*
 
3
 *  @OPENGROUP_COPYRIGHT@
 
4
 *  COPYRIGHT NOTICE
 
5
 *  Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
 
6
 *  Copyright (c) 1996, 1997, 1998, 1999, 2000 The Open Group
 
7
 *  ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
 
8
 *  the full copyright text.
 
9
 *  
 
10
 *  This software is subject to an open license. It may only be
 
11
 *  used on, with or for operating systems which are themselves open
 
12
 *  source systems. You must contact The Open Group for a license
 
13
 *  allowing distribution and sublicensing of this software on, with,
 
14
 *  or for operating systems which are not Open Source programs.
 
15
 *  
 
16
 *  See http://www.opengroup.org/openmotif/license for full
 
17
 *  details of the license agreement. Any use, reproduction, or
 
18
 *  distribution of the program constitutes recipient's acceptance of
 
19
 *  this agreement.
 
20
 *  
 
21
 *  EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
 
22
 *  PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 
23
 *  KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
 
24
 *  WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
 
25
 *  OR FITNESS FOR A PARTICULAR PURPOSE
 
26
 *  
 
27
 *  EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
 
28
 *  NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT,
 
29
 *  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
30
 *  DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED
 
31
 *  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
32
 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 
33
 *  ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
 
34
 *  EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
 
35
 *  POSSIBILITY OF SUCH DAMAGES.
 
36
 */
 
37
/*
 
38
 * HISTORY
 
39
 */
 
40
#include <stdlib.h>             /* for getenv() */
 
41
#include <Xm/Xm.h>              /* Motif Toolkit */
 
42
#include <Mrm/MrmPublic.h>      /* Mrm Toolkit */
 
43
 
 
44
#define APP_CLASS "XmdHelloInt"
 
45
 
 
46
static void Activate(Widget, XtPointer, XtPointer);
 
47
 
 
48
/* 
 
49
 * MRM database file list 
 
50
 */
 
51
static String uid_vec[]={"helloint.uid","l_strings.uid"}; 
 
52
/* 
 
53
 * Callback bindings
 
54
 */
 
55
static MrmRegisterArg reg_vec[] = {       
 
56
  {"helloworld_button_activate",(XtPointer)Activate}
 
57
};
 
58
 
 
59
/*
 
60
 * MRM Hierachy
 
61
 */
 
62
static MrmHierarchy s_mrm_hierarchy;            
 
63
 
 
64
 
 
65
/****************************************************************
 
66
 *
 
67
 *  Main program. Fetch UIL interface description and enter 
 
68
 *  event loop.
 
69
 *
 
70
 ****************************************************************/
 
71
int main(int argc, 
 
72
         char *argv[])
 
73
{
 
74
  XtAppContext app_context;
 
75
  Widget       top_level, helloworld_main;
 
76
  MrmCode      mrm_class;
 
77
  char       * applresdir;
 
78
 
 
79
  /*
 
80
   *  This demo requires XAPPLRESDIR to be set to '.'. Mrm
 
81
   *  will only report that l_strings.uid could not be found,
 
82
   *  so, to be a little more friendly, we help the user. This
 
83
   *  it not a check that normally would be done, since the uid
 
84
   *  files would be installed in the appropriate directory.
 
85
   */
 
86
 
 
87
  if ((applresdir = (char *)getenv("XAPPLRESDIR")) == NULL ||
 
88
      strcmp(applresdir, ".") != 0) {
 
89
    XtError("Environment variable XAPPLRESDIR must be set to \".\"\n");
 
90
  }
 
91
 
 
92
  /*
 
93
   *  Set up language environment.
 
94
   */
 
95
  XtSetLanguageProc(NULL, NULL, NULL);
 
96
  
 
97
  /*
 
98
   *  Initialize MRM
 
99
   */
 
100
  
 
101
  MrmInitialize ();
 
102
  
 
103
  /* 
 
104
   * Initialize Xt and create a resizable shell 
 
105
   */
 
106
  
 
107
  top_level = XtVaAppInitialize(&app_context, "XmdHelloInt", 
 
108
                                NULL, 0, &argc, argv, NULL, 
 
109
                                XmNallowShellResize, True, NULL); 
 
110
 
 
111
  /*
 
112
   * Create the Mrm hierarchy
 
113
   */
 
114
  
 
115
  if (MrmOpenHierarchy (XtNumber(uid_vec),          /* number of files      */
 
116
                        uid_vec,                    /* files                */
 
117
                        NULL,                       /* os_ext_list (null)   */
 
118
                        &s_mrm_hierarchy)           /* ptr to returned id   */
 
119
      != MrmSUCCESS) {
 
120
    XtError ("can't open hierarchy\n");
 
121
  }
 
122
  
 
123
  /*
 
124
   * Register our callback routines so that the resource manager can 
 
125
   * resolve them at widget-creation time.
 
126
   */
 
127
 
 
128
  if (MrmRegisterNames (reg_vec, XtNumber(reg_vec)) != MrmSUCCESS) {
 
129
    XtError("can't register names\n");
 
130
  }
 
131
 
 
132
  /*
 
133
   *  Call MRM to fetch and create the widgets 
 
134
   */
 
135
  
 
136
  if (MrmFetchWidget (s_mrm_hierarchy, 
 
137
                      "helloworld_main", 
 
138
                      top_level,
 
139
                      &helloworld_main, 
 
140
                      &mrm_class) != MrmSUCCESS) {
 
141
    XtError ("can't fetch interface\n");
 
142
  }
 
143
  
 
144
  /*
 
145
   * Manage the widget returned by Mrm.
 
146
   */
 
147
 
 
148
  XtManageChild(helloworld_main);
 
149
 
 
150
  /*
 
151
   * Realize the widget tree.
 
152
   */
 
153
  XtRealizeWidget(top_level);
 
154
   
 
155
  /*
 
156
   *  Loop and process events
 
157
   */
 
158
  
 
159
  XtAppMainLoop(app_context);
 
160
 
 
161
  /* UNREACHABLE */
 
162
  return (0);
 
163
}
 
164
 
 
165
 
 
166
static void Activate(Widget    widget,
 
167
                     XtPointer client_data,
 
168
                     XtPointer callback_data)
 
169
{
 
170
  static Boolean first_time = True;
 
171
  Arg arglist[1];
 
172
  
 
173
  if (first_time) {
 
174
    /*
 
175
     * Get "Goodbye World!" in the language of choice and
 
176
     * set the label string of widget to this string.
 
177
     */
 
178
    XtSetArg(arglist[0], XmNlabelString, "bye_label");
 
179
    MrmFetchSetValues(s_mrm_hierarchy, widget, arglist, 1);
 
180
    first_time = False;
 
181
  } else {
 
182
    /*
 
183
     * We're done...
 
184
     */
 
185
    exit(0);
 
186
  }
 
187
}