Dear visitor, welcome to KDE-Forum.org.
If this is your first visit here, please read the Help. It explains in detail how this page works.
To use all features of this page, you should consider registering.
Please use the registration form, to register here or read more information about the registration process.
If you are already registered, please login here.
[Kopete] Chat Window Styles
Hi!
The Window Styles "Kopete" and "MSN" are very good. But i want to create my own style. but i don´t know what i have to do
could somebody help me?
is anywhere a website where i can download kopete styles?
over google search i did not found any result.
thx!
Greetz ViperNeo
Re: [Kopete] Chat Window Styles
Original von ViperNeo
Hi!
The Window Styles "Kopete" and "MSN" are very good. But i want to create my own style. but i don´t know what i have to do
could somebody help me?
is anywhere a website where i can download kopete styles?
over google search i did not found any result.
thx!
Greetz ViperNeo
Here's one I know of:
http://www.kde-look.org/content/show.php?content=11265
I guess that looking at the files can give you an idea of how it works.
You might also ask the author how he did it and if he knows of any docs.
The documentation is short, specially about styles that is a very technical part, at least in the user perspective.
Basically kopete uses XSLT to match a dynamic XML document created from all messages and produce html that is what the user sees. Aditionally the provide some variables that work as abbreviations and are translated to XSLT when the style is used.
Each message is translated to a XML structure like
[code:1]
<message time="<time>"
timestamp="<timestamp as 2004-08-07 19:08>"
formattedTimestamp="<a formatted time stamp, a mistery to me>"
subject="<the message subject>"
direction="<1=outgoing, 2=internal, 3=incomming>"
importance="<a number>"
mainContactId="<the contact id from the message>">
<from>
<contact contactId="<id>" color="<color>">
<contactDisplayname dir="<text dirrection>"
text="<name text>">
<metaContactDisplayname dir="<text dirrection>"
text="<name text>" protocolIcon="<icon path>">
</from>
<to>
<contact contactId="<id>" color="<color>">
<contactDisplayname dir="<text dirrection>"
text="<name text>">
<metaContactDisplayname dir="<text dirrection>"
text="<name text>" protocolIcon="<icon path>">
</to>
<body color="<color>" bgcolor="<color>" dir="<text direction>">
message text
</body>
</message>
[/code:1]
The style is applied agains each message to generate html. The variables that kopete supports are:
[list]
%TIME% - the value of the attribute time
%TIMESTAMP% - the value of the timestamp attribute
%FORMATTEDTIMESTAMP% - same as above for that strange attribute. I think this works like this: if the message is from today then the time is shown; if the message is from other day then a timestamp is shown.
%FROM_CONTACT_DISPLAYNAME% - the from contact name
%TO_CONTACT_DISPLAYNAME% - the to contat name
%FROM_METACONTACT_DISPLAYNAME% - etc
%TO_METACONTACT_DISPLAYNAME% - etc
%FROM_CONTACT_ID%
%TO_CONTACT_ID%
%BODY% - the message body
[/list:u]
NOTE: Variables are used inside "<kopete-i18n></kopete-i18n>" tags.
The rest is XSLT and thats more difficult to explain here. In a basic form you have
[code:1]
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="message">
##
</xsl:template>
</xsl:stylesheet>
[/code:1]
Changes are made were ## is. Everything that does not have a "xsl" prefix is plain html and is used as is. Elements like "xsl:choose" are part of xls and are "interpreted". "xsl:value-of" allows you to select values from the message structure. A path like structure is used to reference nodes like "from/contact/contactDisplayName" and attributes like "from/contact/contactDisplayName/@dir".
It's better if you see examples to see serveral XSL examples. The "Enclosed" style is enough for you to see many uses of the this listed here.
Good luck :-)[/list]
Here is my xsl theme, based around the minimalistic and msn themes.
[code:1]
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="message">
<div class="KopeteMessage" style="padding-bottom:5px;">
<xsl:attribute name="id">
<xsl:value-of select="@id"/>
</xsl:attribute>
<div>
<div>
<xsl:choose>
<xsl:when test="@direction='3'">
<!-- action message -->
</xsl:when>
<xsl:when test="@direction='2'">
<!-- internal message -->
</xsl:when>
<xsl:when test="@direction='1'">
<!-- Outgoing -->
<div style="color: #535353">
<kopete-i18n> %FROM_CONTACT_DISPLAYNAME% says:</kopete-i18n>
</div>
</xsl:when>
<xsl:otherwise>
<!-- Incoming -->
<div style="color: #535353">
<kopete-i18n> %FROM_CONTACT_DISPLAYNAME% says:</kopete-i18n>
</div>
</xsl:otherwise>
</xsl:choose>
</div>
<div style="text-align:right;margin-top:-1em;float:right;">
<xsl:value-of select="@time"/>
</div>
<div>
<xsl:attribute name="dir">
<xsl:value-of select="body/@dir"/>
</xsl:attribute>
<xsl:attribute name="style">
<xsl:text>padding-left:15px;padding-right:15px;</xsl:text>
<xsl:if test="body/@color">
<xsl:text>color:</xsl:text>
<xsl:value-of select="body/@color"/>
<xsl:text>;</xsl:text>
</xsl:if>
<xsl:if test="body/@bgcolor">
<xsl:text>background-color:</xsl:text>
<xsl:value-of select="body/@bgcolor"/>
</xsl:if>
<xsl:if test="body/@font">
<xsl:text>; </xsl:text>
<xsl:value-of select="body/@font"/>
</xsl:if>
</xsl:attribute>
<xsl:if test="@importance='2'">
<xsl:attribute name="class">
<xsl:text>highlight</xsl:text>
</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="@direction='3'">
<!--action message-->
<span style="color:darkgreen">
<xsl:text>* </xsl:text>
<span>
<xsl:attribute name="dir">
<xsl:value-of select="from/contact/metaContactDisplayName/@dir"/>
</xsl:attribute>
<xsl:value-of disable-output-escaping="yes" select="from/contact/metaContactDisplayName/@text"/>
</span>
<xsl:text> </xsl:text>
<xsl:value-of disable-output-escaping="yes" select="body"/>
</span>
</xsl:when>
<xsl:when test="@direction='2'">
<!--internal message-->
<span>
<xsl:attribute name="dir">
<xsl:value-of select="body/@dir"/>
</xsl:attribute>
<xsl:attribute name="style">
<xsl:if test="body/@bgcolor">
<xsl:text>background-color: </xsl:text>
<xsl:value-of select="body/@bgcolor"/>
<xsl:text>; </xsl:text>
</xsl:if>
<xsl:if test="body/@font">
<xsl:text>font: </xsl:text>
<xsl:value-of select="body/@font"/>
<xsl:text>; </xsl:text>
</xsl:if>
<xsl:text>font-size: small; color: #000000; padding: 1px; border-width: 1px; border-style: solid; border-color: #cccccc; </xsl:text>
</xsl:attribute>
<xsl:value-of disable-output-escaping="yes" select="body"/>
</span>
</xsl:when>
<xsl:otherwise>
<xsl:value-of disable-output-escaping="yes" select="body"/>
</xsl:otherwise>
</xsl:choose>
</div>
</div>
</div>
</xsl:template>
</xsl:stylesheet>[/code:1]
How do you get the default font colors? I made a AIM looking style today (just installed KDE today and couldn't stand all the multiline chat styles), and i dont want to have to hardcode the colors for default chat.
time stamp be gone!
How do I ditch the time stamp? I turn my IM messages to text quite often, and that time stamp complicates the process...you have to hunt out each different number in the time stamp and delete it one at a time. That can get time consuming.