Mercurial > emacs
annotate oldXMenu/InsPane.c @ 69007:b9e2a1b4b54a
* cus-edit.el (customize-set-variable): Push setting to `user' theme.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sun, 19 Feb 2006 17:27:37 +0000 |
parents | e8a3fb527b77 |
children | ce127a46b1ca d04d8ccb3c41 c5406394f567 |
rev | line source |
---|---|
25858 | 1 #include "copyright.h" |
2 | |
3 /* Copyright Massachusetts Institute of Technology 1985 */ | |
68640
e8a3fb527b77
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65000
diff
changeset
|
4 /* Copyright (C) 2002, 2003, 2004, 2005, |
e8a3fb527b77
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65000
diff
changeset
|
5 2006 Free Software Foundation, Inc. */ |
25858 | 6 |
7 /* | |
8 * XMenu: MIT Project Athena, X Window system menu package | |
9 * | |
10 * XMenuInsertPane - Inserts a pane into an XMenu object in | |
11 * a particular position. | |
12 * | |
13 * Author: Tony Della Fera, DEC | |
14 * 20-Nov-85 | |
15 * | |
16 */ | |
17 | |
18 #include <config.h> | |
19 #include "XMenuInt.h" | |
20 | |
21 int | |
22 XMenuInsertPane(menu, p_num, label, active) | |
23 register XMenu *menu; /* Menu object to be modified. */ | |
24 register int p_num; /* Pane number of new pane. */ | |
25 char *label; /* Selection label. */ | |
26 int active; /* Make selection active? */ | |
27 { | |
28 register XMPane *p_ptr; /* XMPane pointer. */ | |
29 register XMPane *pane; /* Newly created pane. */ | |
30 register XMSelect *select; /* Initial selection for the new pane. */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
25858
diff
changeset
|
31 |
25858 | 32 int label_length; /* Label length in characters. */ |
33 int label_width; /* Label width in pixels. */ | |
34 | |
35 /* | |
36 * Check for NULL pointers! | |
37 */ | |
38 if (label == NULL) { | |
39 _XMErrorCode = XME_ARG_BOUNDS; | |
40 return(XM_FAILURE); | |
41 } | |
42 | |
43 /* | |
44 * Find the pane number one less than the one specified since that | |
45 * is the pane after which the insertion will occur. | |
46 */ | |
47 p_ptr = _XMGetPanePtr(menu, (p_num - 1)); | |
48 if (p_ptr == NULL) return(XM_FAILURE); | |
49 | |
50 /* | |
51 * Calloc the XMPane structure and the initial XMSelect. | |
52 */ | |
53 pane = (XMPane *)calloc(1, sizeof(XMPane)); | |
54 if (pane == NULL) { | |
55 _XMErrorCode = XME_CALLOC; | |
56 return(XM_FAILURE); | |
57 } | |
58 select = (XMSelect *)calloc(1, sizeof(XMSelect)); | |
59 if (select == NULL) { | |
60 _XMErrorCode = XME_CALLOC; | |
61 return(XM_FAILURE); | |
62 } | |
63 | |
64 /* | |
65 * Determine label size. | |
66 */ | |
67 label_length = strlen(label); | |
68 label_width = XTextWidth(menu->p_fnt_info, label, label_length); | |
69 | |
70 /* | |
71 * Set up the initial selection. | |
72 * Values not explicitly set are zeroed by calloc. | |
73 */ | |
74 select->next = select; | |
75 select->prev = select; | |
76 select->type = SL_HEADER; | |
77 select->serial = -1; | |
78 select->parent_p = pane; | |
79 | |
80 /* | |
81 * Fill the XMPane structure. | |
82 */ | |
83 pane->type = PANE; | |
84 pane->active = active; | |
85 pane->serial = -1; | |
86 pane->label = label; | |
87 pane->label_width = label_width; | |
88 pane->label_length = label_length; | |
89 pane->s_list = select; | |
90 | |
91 /* | |
92 * Insert the pane after the pane with the pane | |
93 * number one less than the desired number for the | |
94 * new pane. | |
95 */ | |
96 emacs_insque(pane, p_ptr); | |
97 | |
98 /* | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
25858
diff
changeset
|
99 * Update the pane count. |
25858 | 100 */ |
101 menu->p_count++; | |
102 | |
103 /* | |
104 * Schedule a recompute. | |
105 */ | |
106 menu->recompute = 1; | |
107 | |
108 /* | |
109 * Return the number of the pane just added. | |
110 */ | |
111 _XMErrorCode = XME_NO_ERROR; | |
112 return(p_num); | |
113 } | |
52401 | 114 |
115 /* arch-tag: ab94d53d-f05b-4273-82d3-f1b01eb9dc9e | |
116 (do not change this comment) */ |