re-fresh
[nedit-bw.git] / newTabTab-redux.patch
blobaede74f0740cef145f20251cf03311b3d9e3af7a
1 ---
3 Microline/XmL/Folder.c | 80 ++++++++++++++++++++++++++++++++++++++++--------
4 Microline/XmL/FolderP.h | 3 +
5 Microline/XmL/XmL.h | 3 +
6 source/window.c | 34 ++++++++++++--------
7 4 files changed, 93 insertions(+), 27 deletions(-)
9 diff --quilt old/Microline/XmL/Folder.c new/Microline/XmL/Folder.c
10 --- old/Microline/XmL/Folder.c
11 +++ new/Microline/XmL/Folder.c
12 @@ -325,6 +325,12 @@ static XtResource resources[] =
13 XtOffset(XmLFolderWidget, manager.shadow_thickness),
14 XmRImmediate, (XtPointer)2,
16 + {
17 + XmNnewTabCallback, XmCCallback,
18 + XmRCallback, sizeof(XtCallbackList),
19 + XtOffset(XmLFolderWidget, folder.newTabCallback),
20 + XmRImmediate, (XtPointer)0,
21 + },
24 static XtResource constraint_resources[] =
25 @@ -876,6 +882,7 @@ LayoutTopBottom(XmLFolderWidget f,
27 int width, height, numTabs, y;
28 } rows[MAX_TAB_ROWS];
29 + unsigned int core_width = f->core.width;
31 dpy = XtDisplay(f);
32 children = f->composite.children;
33 @@ -904,6 +911,20 @@ LayoutTopBottom(XmLFolderWidget f,
34 int maxTabWidth = f->folder.maxTabWidth;
35 int tabEffCount = 0;
37 +#if 0
38 + if (f->folder.newTabWidget)
39 + {
40 + int thisTabWidth;
41 + XtVaGetValues(f->folder.newTabWidget, XmNwidth, &thisTabWidth, NULL);
42 + thisTabWidth += (st + co + f->folder.marginWidth + ht +
43 + f->folder.newTabWidget->core.border_width) * 2;
44 + if (core_width > thisTabWidth)
45 + core_width -= thisTabWidth;
46 + fprintf(stderr, "%s: remove newTab space: %u %d\n",
47 + __func__, core_width, thisTabWidth);
48 + }
49 +#endif
51 for (i = 0; i < f->folder.tabCount; i++)
53 tab = f->folder.tabs[i];
54 @@ -914,10 +935,11 @@ LayoutTopBottom(XmLFolderWidget f,
56 tabPaddingWidth = (st + co + f->folder.marginWidth + ht +
57 f->folder.tabs[0]->core.border_width) * 2;
58 - if (maxTabWidth * tabEffCount > f->core.width)
60 + if (maxTabWidth * tabEffCount > core_width)
62 - tgtTabWidth = f->core.width/tabEffCount - tabPaddingWidth;
63 - tailSpace = f->core.width % tabEffCount;
64 + tgtTabWidth = core_width/tabEffCount - tabPaddingWidth;
65 + tailSpace = core_width % tabEffCount;
66 tabFit = 1;
68 /* if tabs get too small */
69 @@ -941,16 +963,19 @@ LayoutTopBottom(XmLFolderWidget f,
71 if (f->folder.resizePolicy == XmRESIZE_PACK)
73 - if (tabFit)
74 - {
75 - XtVaSetValues(tab, XmNwidth,
76 - tailSpace? tgtTabWidth+1: tgtTabWidth, NULL);
77 - if (tailSpace)
78 - tailSpace--;
79 - }
80 - else
81 + if (tab != f->folder.newTabWidget)
83 - XtVaSetValues(tab, XmNwidth, tgtTabWidth, NULL);
84 + if (tabFit)
85 + {
86 + XtVaSetValues(tab, XmNwidth,
87 + tailSpace? tgtTabWidth+1: tgtTabWidth, NULL);
88 + if (tailSpace)
89 + tailSpace--;
90 + }
91 + else
92 + {
93 + XtVaSetValues(tab, XmNwidth, tgtTabWidth, NULL);
94 + }
97 else
98 @@ -1178,7 +1203,7 @@ LayoutTopBottom(XmLFolderWidget f,
99 /* calculate tab padding */
100 pad1 = 0;
101 pad2 = 0;
102 - w = f->core.width - rows[rowNum].width;
103 + w = core_width - rows[rowNum].width;
104 if (rowNum != f->folder.activeRow)
105 w -= 4;
106 if (f->folder.tabsPerRow && w > 0)
107 @@ -1655,6 +1680,8 @@ ConstraintInitialize(Widget req,
108 fc->folder.managedName = (char *)strdup(fc->folder.managedName);
109 if (XtIsSubclass(w, xmPrimitiveWidgetClass))
111 + Cardinal i, new_narg = 0;
112 + Boolean isNewTabLabel = False;
113 XtOverrideTranslations(w, f->folder.primTrans);
114 XtAddCallback(w, XmNactivateCallback, PrimActivate, 0);
115 XtVaSetValues(w,
116 @@ -1664,6 +1691,29 @@ ConstraintInitialize(Widget req,
117 if (XtIsSubclass(w, xmLabelWidgetClass))
118 XtVaSetValues(w, XmNfillOnArm, False, NULL);
120 + for (i = 0; i < *narg; ++i)
122 + if (0 == strcmp(args[i].name, XmNisNewTabWidget))
124 + isNewTabLabel = !!args[i].value;
126 + else
128 + args[new_narg].name = args[i].name;
129 + args[new_narg].value = args[i].value;
130 + new_narg++;
133 + *narg = new_narg;
135 + if (isNewTabLabel)
137 +#if 0
138 + fprintf(stderr, "%s: found new-tab label\n", __func__);
139 +#endif
140 + f->folder.newTabWidget = w;
143 /* add child to tabs list */
144 if (f->folder.tabAllocCount < f->folder.tabCount + 1)
146 @@ -1714,6 +1764,8 @@ ConstraintDestroy(Widget w)
148 XtRemoveCallback(w, XmNactivateCallback, PrimActivate, 0);
150 + /* TODO: f->folder.newTabWidget == w */
152 /* remove child from tabs list and calculate active pos */
153 activePos = -1;
154 j = 0;
155 @@ -3602,6 +3654,8 @@ PrimActivate(Widget w,
156 XmLFolderWidget f;
157 XmAnyCallbackStruct *cbs;
159 + /* TODO: f->folder.newTabWidget == w */
161 f = (XmLFolderWidget)XtParent(w);
162 cbs = (XmAnyCallbackStruct *)callData;
163 SetActiveTab(f, w, cbs->event, True);
164 diff --quilt old/Microline/XmL/FolderP.h new/Microline/XmL/FolderP.h
165 --- old/Microline/XmL/FolderP.h
166 +++ new/Microline/XmL/FolderP.h
167 @@ -85,6 +85,9 @@ typedef struct _XmLFolderPart
169 WidgetClass tabWidgetClass;
171 + Widget newTabWidget;
172 + XtCallbackList newTabCallback;
174 } XmLFolderPart;
176 typedef struct _XmLFolderRec
177 diff --quilt old/Microline/XmL/XmL.h new/Microline/XmL/XmL.h
178 --- old/Microline/XmL/XmL.h
179 +++ new/Microline/XmL/XmL.h
180 @@ -117,6 +117,9 @@ extern "C" {
181 #define XmNtabWidgetList "tabWidgetList"
182 #define XmNtabWidgetClass "tabWidgetClass"
183 #define XmCTabWidgetClass "TabWidgetClass"
184 +#define XmNisNewTabWidget "isNewTabWidget"
185 +#define XmCIsNewTabWidget "IsNewTabWidget"
186 +#define XmNnewTabCallback "newTabCallback"
188 /* Folder Constraint resources */
190 diff --quilt old/source/window.c new/source/window.c
191 --- old/source/window.c
192 +++ new/source/window.c
193 @@ -602,7 +602,7 @@ WindowInfo *CreateWindow(const char *nam
194 /* create the tab bar */
195 window->tabBar = XtVaCreateManagedWidget("tabBar",
196 xmlFolderWidgetClass, tabForm,
197 - XmNresizePolicy, XmRESIZE_DYNAMIC,
198 + XmNresizePolicy, XmRESIZE_PACK,
199 XmNleftAttachment, XmATTACH_FORM,
200 XmNleftOffset, 0,
201 XmNrightAttachment, XmATTACH_WIDGET,
202 @@ -845,25 +845,31 @@ static Widget addTab(Widget folder, cons
204 Widget tooltipLabel, tab;
205 XmString s1, s2;
206 + Arg args[16];
207 + Cardinal nargs = 0;
209 s1 = XmStringCreateSimple((char *)string);
210 if (isNewTabTab)
211 s2 = XmStringCreateSimple("New Document");
212 else
213 s2 = s1;
214 - tab = XtVaCreateManagedWidget("tab",
215 - xrwsBubbleButtonWidgetClass, folder,
216 - /* XmNmarginWidth, <default@nedit.c>, */
217 - /* XmNmarginHeight, <default@nedit.c>, */
218 - /* XmNalignment, <default@nedit.c>, */
219 - XmNlabelString, s1,
220 - XltNbubbleString, s2,
221 - XltNshowBubble, GetPrefToolTips(),
222 - XltNautoParkBubble, True,
223 - XltNslidingBubble, False,
224 - /* XltNdelay, 800,*/
225 - /* XltNbubbleDuration, 8000,*/
226 - NULL);
228 +/* XtSetArg(args[nargs], XmNmarginWidth, <default@nedit.c>); nargs++; */
229 +/* XtSetArg(args[nargs], XmNmarginHeight, <default@nedit.c>); nargs++; */
230 +/* XtSetArg(args[nargs], XmNalignment, <default@nedit.c>); nargs++; */
231 + XtSetArg(args[nargs], XmNlabelString, s1); nargs++;
232 + XtSetArg(args[nargs], XltNbubbleString, s2); nargs++;
233 + XtSetArg(args[nargs], XltNshowBubble, GetPrefToolTips()); nargs++;
234 + XtSetArg(args[nargs], XltNautoParkBubble, True); nargs++;
235 + XtSetArg(args[nargs], XltNslidingBubble, False); nargs++;
236 +/* XtSetArg(args[nargs], XltNdelay, 800); nargs++; */
237 +/* XtSetArg(args[nargs], XltNbubbleDuration, 8000); nargs++; */
238 + if (isNewTabTab) {
239 + XtSetArg(args[nargs], XmNisNewTabWidget, True); nargs++;
242 + tab = XtCreateManagedWidget("tab", xrwsBubbleButtonWidgetClass, folder,
243 + args, nargs);
244 XmStringFree(s1);
245 if (isNewTabTab)
246 XmStringFree(s2);