Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:12.1:Update
xpdf-poppler
xpdf-poppler-settitle.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xpdf-poppler-settitle.patch of Package xpdf-poppler
Index: xpdf-poppler/XPDFViewer.h =================================================================== --- xpdf-poppler.orig/XPDFViewer.h +++ xpdf-poppler/XPDFViewer.h @@ -293,6 +293,11 @@ private: static XPDFViewerCmd cmdTab[]; + //----- setting Window and Icon titles + void setTitle(char *title, int icon); + XTextProperty* char_to_xtp ( Display* dpy, char* s ); + GooString* viewerTitle; + XPDFApp *app; bool ok; Index: xpdf-poppler/XPDFViewer.cc =================================================================== --- xpdf-poppler.orig/XPDFViewer.cc +++ xpdf-poppler/XPDFViewer.cc @@ -17,11 +17,15 @@ #include <stdlib.h> #include <string.h> #include <ctype.h> +#include <locale.h> +#include <langinfo.h> +#include <iconv.h> #include <X11/keysym.h> #include <X11/cursorfont.h> #ifdef HAVE_X11_XPM_H #include <X11/xpm.h> #endif +#include <X11/Xatom.h> #include "poppler/goo/gmem.h" #include "poppler/goo/gfile.h" #include "poppler/goo/GooString.h" @@ -259,6 +263,8 @@ XPDFViewer::XPDFViewer(XPDFApp *appA, Go outlinePaneWidth = 175; #endif + viewerTitle = NULL; + // do Motif-specific initialization and create the window; // this also creates the core object initWindow(fullScreen); @@ -313,6 +319,8 @@ XPDFViewer::XPDFViewer(XPDFApp *appA, PD outlinePaneWidth = 175; #endif + viewerTitle = NULL; + // do Motif-specific initialization and create the window; // this also creates the core object initWindow(fullScreen); @@ -395,6 +403,8 @@ void XPDFViewer::clear() { title = app->getTitle() ? app->getTitle()->getCString() : (char *)xpdfAppName; XtVaSetValues(win, XmNtitle, title, XmNiconName, title, NULL); + setTitle(title, 0); + setTitle(title, 1); if (toolBar != None) { s = XmStringCreateLocalized(""); @@ -2207,7 +2217,90 @@ void XPDFViewer::mapWindow() { about_height, fg, arm, depth), NULL); - } + if (viewerTitle) { + setTitle(viewerTitle->getCString(),0); + setTitle(viewerTitle->getCString(),1); + } + } +} + +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::closeWindow() { @@ -2556,9 +2649,14 @@ void XPDFViewer::updateCbk(void *data, G if (fileName) { if (!(title = viewer->app->getTitle())) { title = (new GooString(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; }
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