Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
DISCONTINUED:openSUSE:11.1:Update
xpdf
xpdf-settitle.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xpdf-settitle.patch of Package xpdf
diff -ur xpdf-orig/xpdf/XPDFViewer.cc xpdf-3.02/xpdf/XPDFViewer.cc --- xpdf-orig/xpdf/XPDFViewer.cc 2007-02-27 23:05:52.000000000 +0100 +++ xpdf-3.02/xpdf/XPDFViewer.cc 2007-08-06 13:53:55.000000000 +0200 @@ -20,6 +20,10 @@ #ifdef HAVE_X11_XPM_H #include <X11/xpm.h> #endif +#include <locale.h> +#include <langinfo.h> +#include <iconv.h> +#include <X11/Xatom.h> #if defined(__sgi) && (XmVERSION <= 1) #define Object XtObject #include <Sgm/HPanedW.h> @@ -255,7 +259,8 @@ outlineLabelsLength = outlineLabelsSize = 0; outlinePaneWidth = 175; #endif - + viewerTitle = NULL; + // do Motif-specific initialization and create the window; // this also creates the core object initWindow(fullScreen); @@ -400,6 +405,8 @@ title = app->getTitle() ? app->getTitle()->getCString() : (char *)xpdfAppName; XtVaSetValues(win, XmNtitle, title, XmNiconName, title, NULL); + setTitle(title,0); + setTitle(title,1); s = XmStringCreateLocalized(""); XtVaSetValues(pageNumText, XmNlabelString, s, NULL); XmStringFree(s); @@ -2227,6 +2234,10 @@ about_height, fg, arm, depth), NULL); + if (viewerTitle) { + setTitle(viewerTitle->getCString(),0); + setTitle(viewerTitle->getCString(),1); + } } } @@ -2567,6 +2578,85 @@ XmTextFieldSetString(viewer->pageNumText, buf); } +void XPDFViewer::setTitle(char *title, int icon) { + char* from; + iconv_t cd; + char* inptr; + size_t insize; + char utf8title [4096]; + char* outptr; + size_t outsize; + Atom net_wm_name; + Atom net_wm_icon_name; + Atom utf8_string; + + net_wm_name = XInternAtom (display, "_NET_WM_NAME", False); + net_wm_icon_name = XInternAtom (display, "_NET_WM_ICON_NAME", False); + utf8_string = XInternAtom (display, "UTF8_STRING" ,False); + + from = nl_langinfo (CODESET); + cd = iconv_open ("UTF-8",from); + inptr = title; + outptr = utf8title; + insize = strlen(title); + outsize = sizeof (utf8title); + memset (&utf8title, 0, sizeof(utf8title)); + iconv (cd, &inptr, &insize, &outptr, &outsize); + iconv_close (cd); + Window w; + + if (!win) return; + w = XtWindow(win); + if (!w) return; + + if (icon) { + XSetWMIconName ( + display, w, char_to_xtp (display,utf8title) + ); + XChangeProperty ( + display, w, net_wm_icon_name, utf8_string, 8, + PropModeReplace, (unsigned char *)utf8title, + strlen (utf8title) + ); + } else { + XSetWMName ( + display, w, char_to_xtp (display,utf8title) + ); + XChangeProperty ( + display, w, net_wm_name, utf8_string, 8, + PropModeReplace, (unsigned char *)utf8title, + strlen (utf8title) + ); + } +} + +XTextProperty* XPDFViewer::char_to_xtp ( Display* dpy, char* s ) { + static XTextProperty tp = { 0, 0, 0, 0 }; + static int free_prop = True; + int errCode = 0; + char* tl[2]; + if ( tp.value ) { + if ( free_prop ) { + XFree( tp.value ); + } + tp.value = 0; + free_prop = True; + } + tl[0] = s; + tl[1] = 0; + errCode = XmbTextListToTextProperty ( + dpy,tl, 1, XStdICCTextStyle, &tp + ); + if ( errCode < 0 ) { + tp.value = (unsigned char*)s; + tp.encoding = XA_STRING; + tp.format = 8; + tp.nitems = strlen (s); + free_prop = False; + } + return &tp; +} + void XPDFViewer::updateCbk(void *data, GString *fileName, int pageNum, int numPages, char *linkString) { XPDFViewer *viewer = (XPDFViewer *)data; @@ -2577,9 +2667,14 @@ if (fileName) { if (!(title = viewer->app->getTitle())) { title = (new GString(xpdfAppName))->append(": ")->append(fileName); + if (viewer->viewerTitle) + delete viewer->viewerTitle; + viewer->viewerTitle = title->copy(); } XtVaSetValues(viewer->win, XmNtitle, title->getCString(), XmNiconName, title->getCString(), NULL); + viewer->setTitle(title->getCString(),0); + viewer->setTitle(title->getCString(),1); if (!viewer->app->getTitle()) { delete title; } diff -ur xpdf-orig/xpdf/XPDFViewer.h xpdf-3.02/xpdf/XPDFViewer.h --- xpdf-orig/xpdf/XPDFViewer.h 2007-02-27 23:05:52.000000000 +0100 +++ xpdf-3.02/xpdf/XPDFViewer.h 2007-08-06 13:51:22.000000000 +0200 @@ -287,6 +287,11 @@ static XPDFViewerCmd cmdTab[]; + //----- setting Window and Icon titles: + void setTitle(char *title, int icon); + XTextProperty* XPDFViewer::char_to_xtp ( Display* dpy, char* s ); + GString* viewerTitle; + XPDFApp *app; GBool ok;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor