repo
string | commit
string | message
string | diff
string |
---|---|---|---|
diem-project/sfWebBrowserPlugin
|
7fa4c76b2e858ec9560fa6b6c1655b83948f83fe
|
fix sfWebBrowser->decodeGzip() using wrapped stream & base64 when gzinflate fails
|
diff --git a/lib/sfWebBrowser.class.php b/lib/sfWebBrowser.class.php
index 98c1928..5bde1be 100644
--- a/lib/sfWebBrowser.class.php
+++ b/lib/sfWebBrowser.class.php
@@ -223,629 +223,636 @@ class sfWebBrowser
}
return $browser;
}
/**
* Gives a value to a form field in the response
*
* @param string field name
* @param string field value
*
* @return sfWebBrowser The current browser object
*/
public function setField($name, $value)
{
// as we don't know yet the form, just store name/value pairs
$this->parseArgumentAsArray($name, $value, $this->fields);
return $this;
}
/**
* Looks for a link or a button in the response and submits the related request
*
* @param string The link/button value/href/alt
* @param array request parameters (associative array)
*
* @return sfWebBrowser The current browser object
*/
public function click($name, $arguments = array())
{
if (!$dom = $this->getResponseDom())
{
throw new Exception('Cannot click because there is no current page in the browser');
}
$xpath = new DomXpath($dom);
// text link, the name being in an attribute
if ($link = $xpath->query(sprintf('//a[@*="%s"]', $name))->item(0))
{
return $this->get($link->getAttribute('href'));
}
// text link, the name being the text value
if ($links = $xpath->query('//a[@href]'))
{
foreach($links as $link)
{
if(preg_replace(array('/\s{2,}/', '/\\r\\n|\\n|\\r/'), array(' ', ''), $link->nodeValue) == $name)
{
return $this->get($link->getAttribute('href'));
}
}
}
// image link, the name being the alt attribute value
if ($link = $xpath->query(sprintf('//a/img[@alt="%s"]/ancestor::a', $name))->item(0))
{
return $this->get($link->getAttribute('href'));
}
// form, the name being the button or input value
if (!$form = $xpath->query(sprintf('//input[((@type="submit" or @type="button") and @value="%s") or (@type="image" and @alt="%s")]/ancestor::form', $name, $name))->item(0))
{
throw new Exception(sprintf('Cannot find the "%s" link or button.', $name));
}
// form attributes
$url = $form->getAttribute('action');
$method = $form->getAttribute('method') ? strtolower($form->getAttribute('method')) : 'get';
// merge form default values and arguments
$defaults = array();
foreach ($xpath->query('descendant::input | descendant::textarea | descendant::select', $form) as $element)
{
$elementName = $element->getAttribute('name');
$nodeName = $element->nodeName;
$value = null;
if ($nodeName == 'input' && ($element->getAttribute('type') == 'checkbox' || $element->getAttribute('type') == 'radio'))
{
if ($element->getAttribute('checked'))
{
$value = $element->getAttribute('value');
}
}
else if (
$nodeName == 'input'
&&
(($element->getAttribute('type') != 'submit' && $element->getAttribute('type') != 'button') || $element->getAttribute('value') == $name)
&&
($element->getAttribute('type') != 'image' || $element->getAttribute('alt') == $name)
)
{
$value = $element->getAttribute('value');
}
else if ($nodeName == 'textarea')
{
$value = '';
foreach ($element->childNodes as $el)
{
$value .= $dom->saveXML($el);
}
}
else if ($nodeName == 'select')
{
if ($multiple = $element->hasAttribute('multiple'))
{
$elementName = str_replace('[]', '', $elementName);
$value = array();
}
else
{
$value = null;
}
$found = false;
foreach ($xpath->query('descendant::option', $element) as $option)
{
if ($option->getAttribute('selected'))
{
$found = true;
if ($multiple)
{
$value[] = $option->getAttribute('value');
}
else
{
$value = $option->getAttribute('value');
}
}
}
// if no option is selected and if it is a simple select box, take the first option as the value
if (!$found && !$multiple)
{
$value = $xpath->query('descendant::option', $element)->item(0)->getAttribute('value');
}
}
if (null !== $value)
{
$this->parseArgumentAsArray($elementName, $value, $defaults);
}
}
// create request parameters
$arguments = sfToolkit::arrayDeepMerge($defaults, $this->fields, $arguments);
if ('post' == $method)
{
return $this->post($url, $arguments);
}
else
{
return $this->get($url, $arguments);
}
}
protected function parseArgumentAsArray($name, $value, &$vars)
{
if (false !== $pos = strpos($name, '['))
{
$var = &$vars;
$tmps = array_filter(preg_split('/(\[ | \[\] | \])/x', $name));
foreach ($tmps as $tmp)
{
$var = &$var[$tmp];
}
if ($var)
{
if (!is_array($var))
{
$var = array($var);
}
$var[] = $value;
}
else
{
$var = $value;
}
}
else
{
$vars[$name] = $value;
}
}
/**
* Adds the current request to the history stack
*
* @param string The request uri
* @param string The request method
* @param array The request parameters (associative array)
* @param array The request headers (associative array)
*
* @return sfWebBrowser The current browser object
*/
public function addToStack($uri, $method, $parameters, $headers)
{
$this->stack = array_slice($this->stack, 0, $this->stackPosition + 1);
$this->stack[] = array(
'uri' => $uri,
'method' => $method,
'parameters' => $parameters,
'headers' => $headers
);
$this->stackPosition = count($this->stack) - 1;
return $this;
}
/**
* Submits the previous request in history again
*
* @return sfWebBrowser The current browser object
*/
public function back()
{
if ($this->stackPosition < 1)
{
throw new Exception('You are already on the first page.');
}
--$this->stackPosition;
return $this->call($this->stack[$this->stackPosition]['uri'],
$this->stack[$this->stackPosition]['method'],
$this->stack[$this->stackPosition]['parameters'],
$this->stack[$this->stackPosition]['headers'],
false);
}
/**
* Submits the next request in history again
*
* @return sfWebBrowser The current browser object
*/
public function forward()
{
if ($this->stackPosition > count($this->stack) - 2)
{
throw new Exception('You are already on the last page.');
}
++$this->stackPosition;
return $this->call($this->stack[$this->stackPosition]['uri'],
$this->stack[$this->stackPosition]['method'],
$this->stack[$this->stackPosition]['parameters'],
$this->stack[$this->stackPosition]['headers'],
false);
}
/**
* Submits the current request again
*
* @return sfWebBrowser The current browser object
*/
public function reload()
{
if (-1 == $this->stackPosition)
{
throw new Exception('No page to reload.');
}
return $this->call($this->stack[$this->stackPosition]['uri'],
$this->stack[$this->stackPosition]['method'],
$this->stack[$this->stackPosition]['parameters'],
$this->stack[$this->stackPosition]['headers'],
false);
}
/**
* Transforms an associative array of header names => header values to its HTTP equivalent.
*
* @param array $headers
* @return string
*/
public function prepareHeaders($headers = array())
{
$prepared_headers = array();
foreach ($headers as $name => $value)
{
$prepared_headers[] = sprintf("%s: %s\r\n", ucfirst($name), $value);
}
return implode('', $prepared_headers);
}
// Response methods
/**
* Initializes the response and erases all content from prior requests
*/
public function initializeResponse()
{
$this->responseHeaders = array();
$this->responseCode = '';
$this->responseText = '';
$this->responseDom = null;
$this->responseDomCssSelector = null;
$this->responseXml = null;
$this->fields = array();
}
/**
* Set the response headers
*
* @param array The response headers as an array of strings shaped like "key: value"
*
* @return sfWebBrowser The current browser object
*/
public function setResponseHeaders($headers = array())
{
$header_array = array();
foreach($headers as $header)
{
$arr = explode(': ', $header);
if(isset($arr[1]))
{
$header_array[$this->normalizeHeaderName($arr[0])] = trim($arr[1]);
}
}
$this->responseHeaders = $header_array;
return $this;
}
/**
* Set the response code
*
* @param string The first line of the response
*
* @return sfWebBrowser The current browser object
*/
public function setResponseCode($firstLine)
{
preg_match('/\d{3}/', $firstLine, $matches);
if(isset($matches[0]))
{
$this->responseCode = $matches[0];
}
else
{
$this->responseCode = '';
}
return $this;
}
/**
* Set the response contents
*
* @param string The response contents
*
* @return sfWebBrowser The current browser object
*/
public function setResponseText($res)
{
$this->responseText = $res;
return $this;
}
/**
* Get a text version of the response
*
* @return string The response contents
*/
public function getResponseText()
{
$text = $this->responseText;
// Decode any content-encoding (gzip or deflate) if needed
switch (strtolower($this->getResponseHeader('content-encoding'))) {
// Handle gzip encoding
case 'gzip':
$text = $this->decodeGzip($text);
break;
// Handle deflate encoding
case 'deflate':
$text = $this->decodeDeflate($text);
break;
default:
break;
}
return $text;
}
/**
* Get a text version of the body part of the response (without <body> and </body>)
*
* @return string The body part of the response contents
*/
public function getResponseBody()
{
preg_match('/<body.*?>(.*)<\/body>/si', $this->getResponseText(), $matches);
return isset($matches[1]) ? $matches[1] : '';
}
/**
* Get a DOMDocument version of the response
*
* @return DOMDocument The reponse contents
*/
public function getResponseDom()
{
if(!$this->responseDom)
{
// for HTML/XML content, create a DOM object for the response content
if (preg_match('/(x|ht)ml/i', $this->getResponseHeader('Content-Type')))
{
$this->responseDom = new DomDocument('1.0', 'utf8');
$this->responseDom->validateOnParse = true;
@$this->responseDom->loadHTML($this->getResponseText());
}
}
return $this->responseDom;
}
/**
* Get a sfDomCssSelector version of the response
*
* @return sfDomCssSelector The response contents
*/
public function getResponseDomCssSelector()
{
if(!$this->responseDomCssSelector)
{
// for HTML/XML content, create a DOM object for the response content
if (preg_match('/(x|ht)ml/i', $this->getResponseHeader('Content-Type')))
{
$this->responseDomCssSelector = new sfDomCssSelector($this->getResponseDom());
}
}
return $this->responseDomCssSelector;
}
/**
* Get a SimpleXML version of the response
*
* @return SimpleXMLElement The reponse contents
* @throws sfWebBrowserInvalidResponseException when response is not in a valid format
*/
public function getResponseXML()
{
if(!$this->responseXml)
{
// for HTML/XML content, create a DOM object for the response content
if (preg_match('/(x|ht)ml/i', $this->getResponseHeader('Content-Type')))
{
$this->responseXml = @simplexml_load_string($this->getResponseText());
}
}
// Throw an exception if response is not valid XML
if (get_class($this->responseXml) != 'SimpleXMLElement')
{
$msg = sprintf("Response is not a valid XML string : \n%s", $this->getResponseText());
throw new sfWebBrowserInvalidResponseException($msg);
}
return $this->responseXml;
}
/**
* Returns true if server response is an error.
*
* @return bool
*/
public function responseIsError()
{
return in_array((int)($this->getResponseCode() / 100), array(4, 5));
}
/**
* Get the response headers
*
* @return array The response headers
*/
public function getResponseHeaders()
{
return $this->responseHeaders;
}
/**
* Get a response header
*
* @param string The response header name
*
* @return string The response header value
*/
public function getResponseHeader($key)
{
$normalized_key = $this->normalizeHeaderName($key);
return (isset($this->responseHeaders[$normalized_key])) ? $this->responseHeaders[$normalized_key] : '';
}
/**
* Decodes gzip-encoded content ("content-encoding: gzip" response header).
*
* @param stream $gzip_text
* @return string
*/
protected function decodeGzip($gzip_text)
{
- return gzinflate(substr($gzip_text, 10));
+ $return = gzinflate(substr($gzip_text, 10));
+
+ if(!$return)
+ {
+ $return = file_get_contents('compress.zlib://data:who/cares;base64,'. base64_encode($gzip_text));
+ }
+
+ return $return;
}
/**
* Decodes deflate-encoded content ("content-encoding: deflate" response header).
*
* @param stream $deflate_text
* @return string
*/
protected function decodeDeflate($deflate_text)
{
return gzuncompress($deflate_text);
}
/**
* Get the response code
*
* @return string The response code
*/
public function getResponseCode()
{
return $this->responseCode;
}
/**
* Returns the response message (the 'Not Found' part in 'HTTP/1.1 404 Not Found')
*
* @return string
*/
public function getResponseMessage()
{
return $this->responseMessage;
}
/**
* Sets response message.
*
* @param string $message
*/
public function setResponseMessage($msg)
{
$this->responseMessage = $msg;
}
public function getUrlInfo()
{
return $this->urlInfo;
}
public function getDefaultRequestHeaders()
{
return $this->defaultHeaders;
}
/**
* Adds default headers to the supplied headers array.
*
* @param array $headers
* @return array
*/
public function initializeRequestHeaders($headers = array())
{
// Supported encodings
$encodings = array();
if (isset($headers['Accept-Encoding']))
{
$encodings = explode(',', $headers['Accept-Encoding']);
}
if (function_exists('gzinflate') && !in_array('gzip', $encodings))
{
$encodings[] = 'gzip';
}
if (function_exists('gzuncompress') && !in_array('deflate', $encodings))
{
$encodings[] = 'deflate';
}
$headers['Accept-Encoding'] = implode(',', array_unique($encodings));
return $headers;
}
/**
* Validates supplied headers and turns all names to lowercase.
*
* @param array $headers
* @return array
*/
protected function fixHeaders($headers)
{
$fixed_headers = array();
foreach ($headers as $name => $value)
{
if (!preg_match('/([a-z]*)(-[a-z]*)*/i', $name))
{
$msg = sprintf('Invalid header "%s"', $name);
throw new Exception($msg);
}
$fixed_headers[$this->normalizeHeaderName($name)] = trim($value);
}
return $fixed_headers;
}
/**
* Retrieves a normalized Header.
*
* @param string Header name
*
* @return string Normalized header
*/
protected function normalizeHeaderName($name)
{
return preg_replace('/\-(.)/e', "'-'.strtoupper('\\1')", strtr(ucfirst($name), '_', '-'));
}
}
|
diem-project/sfWebBrowserPlugin
|
30e211854a4ed104c4e8ce6366bc29fa5d901ba8
|
Synchronizing svn
|
diff --git a/lib/sfWebBrowser.class.php b/lib/sfWebBrowser.class.php
index 90f9024..98c1928 100644
--- a/lib/sfWebBrowser.class.php
+++ b/lib/sfWebBrowser.class.php
@@ -1,851 +1,851 @@
-<?php
-
-/*
- * This file is part of the sfWebBrowserPlugin package.
- * (c) 2004-2006 Francois Zaninotto <[email protected]>
- * (c) 2004-2006 Fabien Potencier <[email protected]> for the click-related functions
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * sfWebBrowser provides a basic HTTP client.
- *
- * @package sfWebBrowserPlugin
- * @author Francois Zaninotto <[email protected]>
- * @author Tristan Rivoallan <[email protected]>
- * @version 0.9
- */
-class sfWebBrowser
-{
- protected
- $defaultHeaders = array(),
- $stack = array(),
- $stackPosition = -1,
- $responseHeaders = array(),
- $responseCode = '',
- $responseMessage = '',
- $responseText = '',
- $responseDom = null,
- $responseDomCssSelector = null,
- $responseXml = null,
- $fields = array(),
- $urlInfo = array();
-
- public function __construct($defaultHeaders = array(), $adapterClass = null, $adapterOptions = array())
- {
- if(!$adapterClass)
- {
- if (function_exists('curl_init'))
- {
- $adapterClass = 'sfCurlAdapter';
- }
- else if(ini_get('allow_url_fopen') == 1)
- {
- $adapterClass = 'sfFopenAdapter';
- }
- else
- {
- $adapterClass = 'sfSocketsAdapter';
- }
- }
- $this->defaultHeaders = $this->fixHeaders($defaultHeaders);
- $this->adapter = new $adapterClass($adapterOptions);
- }
-
- // Browser methods
-
- /**
- * Restarts the browser
- *
- * @param array default browser options
- *
- * @return sfWebBrowser The current browser object
- */
- public function restart($defaultHeaders = array())
- {
- $this->defaultHeaders = $this->fixHeaders($defaultHeaders);
- $this->stack = array();
- $this->stackPosition = -1;
- $this->urlInfo = array();
- $this->initializeResponse();
-
- return $this;
- }
-
- /**
- * Sets the browser user agent name
- *
- * @param string agent name
- *
- * @return sfWebBrowser The current browser object
- */
- public function setUserAgent($agent)
- {
- $this->defaultHeaders['User-Agent'] = $agent;
-
- return $this;
- }
-
- /**
- * Gets the browser user agent name
- *
- * @return string agent name
- */
- public function getUserAgent()
- {
- return isset($this->defaultHeaders['User-Agent']) ? $this->defaultHeaders['User-Agent'] : '';
- }
-
- /**
- * Submits a GET request
- *
- * @param string The request uri
- * @param array The request parameters (associative array)
- * @param array The request headers (associative array)
- *
- * @return sfWebBrowser The current browser object
- */
- public function get($uri, $parameters = array(), $headers = array())
- {
- if ($parameters)
- {
- $uri .= ((false !== strpos($uri, '?')) ? '&' : '?') . http_build_query($parameters, '', '&');
- }
- return $this->call($uri, 'GET', array(), $headers);
- }
-
- public function head($uri, $parameters = array(), $headers = array())
- {
- if ($parameters)
- {
- $uri .= ((false !== strpos($uri, '?')) ? '&' : '?') . http_build_query($parameters, '', '&');
- }
- return $this->call($uri, 'HEAD', array(), $headers);
- }
-
- /**
- * Submits a POST request
- *
- * @param string The request uri
- * @param array The request parameters (associative array)
- * @param array The request headers (associative array)
- *
- * @return sfWebBrowser The current browser object
- */
- public function post($uri, $parameters = array(), $headers = array())
- {
- return $this->call($uri, 'POST', $parameters, $headers);
- }
-
- /**
- * Submits a PUT request.
- *
- * @param string The request uri
- * @param array The request parameters (associative array)
- * @param array The request headers (associative array)
- *
- * @return sfWebBrowser The current browser object
- */
- public function put($uri, $parameters = array(), $headers = array())
- {
- return $this->call($uri, 'PUT', $parameters, $headers);
- }
-
- /**
- * Submits a DELETE request.
- *
- * @param string The request uri
- * @param array The request parameters (associative array)
- * @param array The request headers (associative array)
- *
- * @return sfWebBrowser The current browser object
- */
- public function delete($uri, $parameters = array(), $headers = array())
- {
- return $this->call($uri, 'DELETE', $parameters, $headers);
- }
-
- /**
- * Submits a request
- *
- * @param string The request uri
- * @param string The request method
- * @param array The request parameters (associative array)
- * @param array The request headers (associative array)
- * @param boolean To specify is the request changes the browser history
- *
- * @return sfWebBrowser The current browser object
- */
- public function call($uri, $method = 'GET', $parameters = array(), $headers = array(), $changeStack = true)
- {
- $urlInfo = parse_url($uri);
-
- // Check headers
- $headers = $this->fixHeaders($headers);
-
- // check port
- if (isset($urlInfo['port']))
- {
- $this->urlInfo['port'] = $urlInfo['port'];
- }
- else if (!isset($this->urlInfo['port']))
- {
- $this->urlInfo['port'] = 80;
- }
-
- if(!isset($urlInfo['host']))
- {
- // relative link
- $uri = $this->urlInfo['scheme'].'://'.$this->urlInfo['host'].':'.$this->urlInfo['port'].'/'.$uri;
- }
- else if($urlInfo['scheme'] != 'http' && $urlInfo['scheme'] != 'https')
- {
- throw new Exception('sfWebBrowser handles only http and https requests');
- }
-
- $this->urlInfo = parse_url($uri);
-
- $this->initializeResponse();
-
- if ($changeStack)
- {
- $this->addToStack($uri, $method, $parameters, $headers);
- }
-
- $browser = $this->adapter->call($this, $uri, $method, $parameters, $headers);
-
- // redirect support
- if ((in_array($browser->getResponseCode(), array(301, 307)) && in_array($method, array('GET', 'HEAD'))) || in_array($browser->getResponseCode(), array(302,303)))
- {
- $this->call($browser->getResponseHeader('Location'), 'GET', array(), $headers);
- }
-
- return $browser;
- }
-
- /**
- * Gives a value to a form field in the response
- *
- * @param string field name
- * @param string field value
- *
- * @return sfWebBrowser The current browser object
- */
- public function setField($name, $value)
- {
- // as we don't know yet the form, just store name/value pairs
- $this->parseArgumentAsArray($name, $value, $this->fields);
-
- return $this;
- }
-
- /**
- * Looks for a link or a button in the response and submits the related request
- *
- * @param string The link/button value/href/alt
- * @param array request parameters (associative array)
- *
- * @return sfWebBrowser The current browser object
- */
- public function click($name, $arguments = array())
- {
- if (!$dom = $this->getResponseDom())
- {
- throw new Exception('Cannot click because there is no current page in the browser');
- }
-
- $xpath = new DomXpath($dom);
-
- // text link, the name being in an attribute
- if ($link = $xpath->query(sprintf('//a[@*="%s"]', $name))->item(0))
- {
- return $this->get($link->getAttribute('href'));
- }
-
- // text link, the name being the text value
- if ($links = $xpath->query('//a[@href]'))
- {
- foreach($links as $link)
- {
- if(preg_replace(array('/\s{2,}/', '/\\r\\n|\\n|\\r/'), array(' ', ''), $link->nodeValue) == $name)
- {
- return $this->get($link->getAttribute('href'));
- }
- }
- }
-
- // image link, the name being the alt attribute value
- if ($link = $xpath->query(sprintf('//a/img[@alt="%s"]/ancestor::a', $name))->item(0))
- {
- return $this->get($link->getAttribute('href'));
- }
-
- // form, the name being the button or input value
- if (!$form = $xpath->query(sprintf('//input[((@type="submit" or @type="button") and @value="%s") or (@type="image" and @alt="%s")]/ancestor::form', $name, $name))->item(0))
- {
- throw new Exception(sprintf('Cannot find the "%s" link or button.', $name));
- }
-
- // form attributes
- $url = $form->getAttribute('action');
- $method = $form->getAttribute('method') ? strtolower($form->getAttribute('method')) : 'get';
-
- // merge form default values and arguments
- $defaults = array();
- foreach ($xpath->query('descendant::input | descendant::textarea | descendant::select', $form) as $element)
- {
- $elementName = $element->getAttribute('name');
- $nodeName = $element->nodeName;
- $value = null;
- if ($nodeName == 'input' && ($element->getAttribute('type') == 'checkbox' || $element->getAttribute('type') == 'radio'))
- {
- if ($element->getAttribute('checked'))
- {
- $value = $element->getAttribute('value');
- }
- }
- else if (
- $nodeName == 'input'
- &&
- (($element->getAttribute('type') != 'submit' && $element->getAttribute('type') != 'button') || $element->getAttribute('value') == $name)
- &&
- ($element->getAttribute('type') != 'image' || $element->getAttribute('alt') == $name)
- )
- {
- $value = $element->getAttribute('value');
- }
- else if ($nodeName == 'textarea')
- {
- $value = '';
- foreach ($element->childNodes as $el)
- {
- $value .= $dom->saveXML($el);
- }
- }
- else if ($nodeName == 'select')
- {
- if ($multiple = $element->hasAttribute('multiple'))
- {
- $elementName = str_replace('[]', '', $elementName);
- $value = array();
- }
- else
- {
- $value = null;
- }
-
- $found = false;
- foreach ($xpath->query('descendant::option', $element) as $option)
- {
- if ($option->getAttribute('selected'))
- {
- $found = true;
- if ($multiple)
- {
- $value[] = $option->getAttribute('value');
- }
- else
- {
- $value = $option->getAttribute('value');
- }
- }
- }
-
- // if no option is selected and if it is a simple select box, take the first option as the value
- if (!$found && !$multiple)
- {
- $value = $xpath->query('descendant::option', $element)->item(0)->getAttribute('value');
- }
- }
-
- if (null !== $value)
- {
- $this->parseArgumentAsArray($elementName, $value, $defaults);
- }
- }
-
- // create request parameters
- $arguments = sfToolkit::arrayDeepMerge($defaults, $this->fields, $arguments);
- if ('post' == $method)
- {
- return $this->post($url, $arguments);
- }
- else
- {
- return $this->get($url, $arguments);
- }
- }
-
- protected function parseArgumentAsArray($name, $value, &$vars)
- {
- if (false !== $pos = strpos($name, '['))
- {
- $var = &$vars;
- $tmps = array_filter(preg_split('/(\[ | \[\] | \])/x', $name));
- foreach ($tmps as $tmp)
- {
- $var = &$var[$tmp];
- }
- if ($var)
- {
- if (!is_array($var))
- {
- $var = array($var);
- }
- $var[] = $value;
- }
- else
- {
- $var = $value;
- }
- }
- else
- {
- $vars[$name] = $value;
- }
- }
-
- /**
- * Adds the current request to the history stack
- *
- * @param string The request uri
- * @param string The request method
- * @param array The request parameters (associative array)
- * @param array The request headers (associative array)
- *
- * @return sfWebBrowser The current browser object
- */
- public function addToStack($uri, $method, $parameters, $headers)
- {
- $this->stack = array_slice($this->stack, 0, $this->stackPosition + 1);
- $this->stack[] = array(
- 'uri' => $uri,
- 'method' => $method,
- 'parameters' => $parameters,
- 'headers' => $headers
- );
- $this->stackPosition = count($this->stack) - 1;
-
- return $this;
- }
-
- /**
- * Submits the previous request in history again
- *
- * @return sfWebBrowser The current browser object
- */
- public function back()
- {
- if ($this->stackPosition < 1)
- {
- throw new Exception('You are already on the first page.');
- }
-
- --$this->stackPosition;
- return $this->call($this->stack[$this->stackPosition]['uri'],
- $this->stack[$this->stackPosition]['method'],
- $this->stack[$this->stackPosition]['parameters'],
- $this->stack[$this->stackPosition]['headers'],
- false);
- }
-
- /**
- * Submits the next request in history again
- *
- * @return sfWebBrowser The current browser object
- */
- public function forward()
- {
- if ($this->stackPosition > count($this->stack) - 2)
- {
- throw new Exception('You are already on the last page.');
- }
-
- ++$this->stackPosition;
- return $this->call($this->stack[$this->stackPosition]['uri'],
- $this->stack[$this->stackPosition]['method'],
- $this->stack[$this->stackPosition]['parameters'],
- $this->stack[$this->stackPosition]['headers'],
- false);
- }
-
- /**
- * Submits the current request again
- *
- * @return sfWebBrowser The current browser object
- */
- public function reload()
- {
- if (-1 == $this->stackPosition)
- {
- throw new Exception('No page to reload.');
- }
-
- return $this->call($this->stack[$this->stackPosition]['uri'],
- $this->stack[$this->stackPosition]['method'],
- $this->stack[$this->stackPosition]['parameters'],
- $this->stack[$this->stackPosition]['headers'],
- false);
- }
-
- /**
- * Transforms an associative array of header names => header values to its HTTP equivalent.
- *
- * @param array $headers
- * @return string
- */
- public function prepareHeaders($headers = array())
- {
- $prepared_headers = array();
- foreach ($headers as $name => $value)
- {
- $prepared_headers[] = sprintf("%s: %s\r\n", ucfirst($name), $value);
- }
-
- return implode('', $prepared_headers);
- }
-
- // Response methods
-
- /**
- * Initializes the response and erases all content from prior requests
- */
- public function initializeResponse()
- {
- $this->responseHeaders = array();
- $this->responseCode = '';
- $this->responseText = '';
- $this->responseDom = null;
- $this->responseDomCssSelector = null;
- $this->responseXml = null;
- $this->fields = array();
- }
-
- /**
- * Set the response headers
- *
- * @param array The response headers as an array of strings shaped like "key: value"
- *
- * @return sfWebBrowser The current browser object
- */
- public function setResponseHeaders($headers = array())
- {
- $header_array = array();
- foreach($headers as $header)
- {
- $arr = explode(': ', $header);
- if(isset($arr[1]))
- {
- $header_array[$this->normalizeHeaderName($arr[0])] = trim($arr[1]);
- }
- }
-
- $this->responseHeaders = $header_array;
-
- return $this;
- }
-
- /**
- * Set the response code
- *
- * @param string The first line of the response
- *
- * @return sfWebBrowser The current browser object
- */
- public function setResponseCode($firstLine)
- {
- preg_match('/\d{3}/', $firstLine, $matches);
- if(isset($matches[0]))
- {
- $this->responseCode = $matches[0];
- }
- else
- {
- $this->responseCode = '';
- }
-
- return $this;
- }
-
- /**
- * Set the response contents
- *
- * @param string The response contents
- *
- * @return sfWebBrowser The current browser object
- */
- public function setResponseText($res)
- {
- $this->responseText = $res;
-
- return $this;
- }
-
- /**
- * Get a text version of the response
- *
- * @return string The response contents
- */
- public function getResponseText()
- {
- $text = $this->responseText;
-
- // Decode any content-encoding (gzip or deflate) if needed
- switch (strtolower($this->getResponseHeader('content-encoding'))) {
-
- // Handle gzip encoding
- case 'gzip':
- $text = $this->decodeGzip($text);
- break;
-
- // Handle deflate encoding
- case 'deflate':
- $text = $this->decodeDeflate($text);
- break;
-
- default:
- break;
- }
-
- return $text;
- }
-
- /**
- * Get a text version of the body part of the response (without <body> and </body>)
- *
- * @return string The body part of the response contents
- */
- public function getResponseBody()
- {
- preg_match('/<body.*?>(.*)<\/body>/si', $this->getResponseText(), $matches);
-
- return isset($matches[1]) ? $matches[1] : '';
- }
-
- /**
- * Get a DOMDocument version of the response
- *
- * @return DOMDocument The reponse contents
- */
- public function getResponseDom()
- {
- if(!$this->responseDom)
- {
- // for HTML/XML content, create a DOM object for the response content
- if (preg_match('/(x|ht)ml/i', $this->getResponseHeader('Content-Type')))
- {
- $this->responseDom = new DomDocument('1.0', 'utf8');
- $this->responseDom->validateOnParse = true;
- @$this->responseDom->loadHTML($this->getResponseText());
- }
- }
-
- return $this->responseDom;
- }
-
- /**
- * Get a sfDomCssSelector version of the response
- *
- * @return sfDomCssSelector The response contents
- */
- public function getResponseDomCssSelector()
- {
- if(!$this->responseDomCssSelector)
- {
- // for HTML/XML content, create a DOM object for the response content
- if (preg_match('/(x|ht)ml/i', $this->getResponseHeader('Content-Type')))
- {
- $this->responseDomCssSelector = new sfDomCssSelector($this->getResponseDom());
- }
- }
-
- return $this->responseDomCssSelector;
- }
-
- /**
- * Get a SimpleXML version of the response
- *
- * @return SimpleXMLElement The reponse contents
- * @throws sfWebBrowserInvalidResponseException when response is not in a valid format
- */
- public function getResponseXML()
- {
- if(!$this->responseXml)
- {
- // for HTML/XML content, create a DOM object for the response content
- if (preg_match('/(x|ht)ml/i', $this->getResponseHeader('Content-Type')))
- {
- $this->responseXml = @simplexml_load_string($this->getResponseText());
- }
- }
-
- // Throw an exception if response is not valid XML
- if (get_class($this->responseXml) != 'SimpleXMLElement')
- {
- $msg = sprintf("Response is not a valid XML string : \n%s", $this->getResponseText());
- throw new sfWebBrowserInvalidResponseException($msg);
- }
-
- return $this->responseXml;
- }
-
- /**
- * Returns true if server response is an error.
- *
- * @return bool
- */
- public function responseIsError()
- {
- return in_array((int)($this->getResponseCode() / 100), array(4, 5));
- }
-
- /**
- * Get the response headers
- *
- * @return array The response headers
- */
- public function getResponseHeaders()
- {
- return $this->responseHeaders;
- }
-
- /**
- * Get a response header
- *
- * @param string The response header name
- *
- * @return string The response header value
- */
- public function getResponseHeader($key)
- {
- $normalized_key = $this->normalizeHeaderName($key);
- return (isset($this->responseHeaders[$normalized_key])) ? $this->responseHeaders[$normalized_key] : '';
- }
-
- /**
- * Decodes gzip-encoded content ("content-encoding: gzip" response header).
- *
- * @param stream $gzip_text
- * @return string
- */
- protected function decodeGzip($gzip_text)
- {
- return gzinflate(substr($gzip_text, 10));
- }
-
- /**
- * Decodes deflate-encoded content ("content-encoding: deflate" response header).
- *
- * @param stream $deflate_text
- * @return string
- */
- protected function decodeDeflate($deflate_text)
- {
- return gzuncompress($deflate_text);
- }
-
- /**
- * Get the response code
- *
- * @return string The response code
- */
- public function getResponseCode()
- {
- return $this->responseCode;
- }
-
- /**
- * Returns the response message (the 'Not Found' part in 'HTTP/1.1 404 Not Found')
- *
- * @return string
- */
- public function getResponseMessage()
- {
- return $this->responseMessage;
- }
-
- /**
- * Sets response message.
- *
- * @param string $message
- */
- public function setResponseMessage($msg)
- {
- $this->responseMessage = $msg;
- }
-
- public function getUrlInfo()
- {
- return $this->urlInfo;
- }
-
- public function getDefaultRequestHeaders()
- {
- return $this->defaultHeaders;
- }
-
- /**
- * Adds default headers to the supplied headers array.
- *
- * @param array $headers
- * @return array
- */
- public function initializeRequestHeaders($headers = array())
- {
- // Supported encodings
- $encodings = array();
- if (isset($headers['Accept-Encoding']))
- {
- $encodings = explode(',', $headers['Accept-Encoding']);
- }
- if (function_exists('gzinflate') && !in_array('gzip', $encodings))
- {
- $encodings[] = 'gzip';
- }
- if (function_exists('gzuncompress') && !in_array('deflate', $encodings))
- {
- $encodings[] = 'deflate';
- }
-
- $headers['Accept-Encoding'] = implode(',', array_unique($encodings));
-
- return $headers;
- }
-
- /**
- * Validates supplied headers and turns all names to lowercase.
- *
- * @param array $headers
- * @return array
- */
- private function fixHeaders($headers)
- {
- $fixed_headers = array();
- foreach ($headers as $name => $value)
- {
- if (!preg_match('/([a-z]*)(-[a-z]*)*/i', $name))
- {
- $msg = sprintf('Invalid header "%s"', $name);
- throw new Exception($msg);
- }
- $fixed_headers[$this->normalizeHeaderName($name)] = trim($value);
- }
-
- return $fixed_headers;
- }
-
- /**
- * Retrieves a normalized Header.
- *
- * @param string Header name
- *
- * @return string Normalized header
- */
- protected function normalizeHeaderName($name)
- {
- return preg_replace('/\-(.)/e', "'-'.strtoupper('\\1')", strtr(ucfirst($name), '_', '-'));
- }
-
-}
+<?php
+
+/*
+ * This file is part of the sfWebBrowserPlugin package.
+ * (c) 2004-2006 Francois Zaninotto <[email protected]>
+ * (c) 2004-2006 Fabien Potencier <[email protected]> for the click-related functions
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * sfWebBrowser provides a basic HTTP client.
+ *
+ * @package sfWebBrowserPlugin
+ * @author Francois Zaninotto <[email protected]>
+ * @author Tristan Rivoallan <[email protected]>
+ * @version 0.9
+ */
+class sfWebBrowser
+{
+ protected
+ $defaultHeaders = array(),
+ $stack = array(),
+ $stackPosition = -1,
+ $responseHeaders = array(),
+ $responseCode = '',
+ $responseMessage = '',
+ $responseText = '',
+ $responseDom = null,
+ $responseDomCssSelector = null,
+ $responseXml = null,
+ $fields = array(),
+ $urlInfo = array();
+
+ public function __construct($defaultHeaders = array(), $adapterClass = null, $adapterOptions = array())
+ {
+ if(!$adapterClass)
+ {
+ if (function_exists('curl_init'))
+ {
+ $adapterClass = 'sfCurlAdapter';
+ }
+ else if(ini_get('allow_url_fopen') == 1)
+ {
+ $adapterClass = 'sfFopenAdapter';
+ }
+ else
+ {
+ $adapterClass = 'sfSocketsAdapter';
+ }
+ }
+ $this->defaultHeaders = $this->fixHeaders($defaultHeaders);
+ $this->adapter = new $adapterClass($adapterOptions);
+ }
+
+ // Browser methods
+
+ /**
+ * Restarts the browser
+ *
+ * @param array default browser options
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function restart($defaultHeaders = array())
+ {
+ $this->defaultHeaders = $this->fixHeaders($defaultHeaders);
+ $this->stack = array();
+ $this->stackPosition = -1;
+ $this->urlInfo = array();
+ $this->initializeResponse();
+
+ return $this;
+ }
+
+ /**
+ * Sets the browser user agent name
+ *
+ * @param string agent name
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function setUserAgent($agent)
+ {
+ $this->defaultHeaders['User-Agent'] = $agent;
+
+ return $this;
+ }
+
+ /**
+ * Gets the browser user agent name
+ *
+ * @return string agent name
+ */
+ public function getUserAgent()
+ {
+ return isset($this->defaultHeaders['User-Agent']) ? $this->defaultHeaders['User-Agent'] : '';
+ }
+
+ /**
+ * Submits a GET request
+ *
+ * @param string The request uri
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function get($uri, $parameters = array(), $headers = array())
+ {
+ if ($parameters)
+ {
+ $uri .= ((false !== strpos($uri, '?')) ? '&' : '?') . http_build_query($parameters, '', '&');
+ }
+ return $this->call($uri, 'GET', array(), $headers);
+ }
+
+ public function head($uri, $parameters = array(), $headers = array())
+ {
+ if ($parameters)
+ {
+ $uri .= ((false !== strpos($uri, '?')) ? '&' : '?') . http_build_query($parameters, '', '&');
+ }
+ return $this->call($uri, 'HEAD', array(), $headers);
+ }
+
+ /**
+ * Submits a POST request
+ *
+ * @param string The request uri
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function post($uri, $parameters = array(), $headers = array())
+ {
+ return $this->call($uri, 'POST', $parameters, $headers);
+ }
+
+ /**
+ * Submits a PUT request.
+ *
+ * @param string The request uri
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function put($uri, $parameters = array(), $headers = array())
+ {
+ return $this->call($uri, 'PUT', $parameters, $headers);
+ }
+
+ /**
+ * Submits a DELETE request.
+ *
+ * @param string The request uri
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function delete($uri, $parameters = array(), $headers = array())
+ {
+ return $this->call($uri, 'DELETE', $parameters, $headers);
+ }
+
+ /**
+ * Submits a request
+ *
+ * @param string The request uri
+ * @param string The request method
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ * @param boolean To specify is the request changes the browser history
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function call($uri, $method = 'GET', $parameters = array(), $headers = array(), $changeStack = true)
+ {
+ $urlInfo = parse_url($uri);
+
+ // Check headers
+ $headers = $this->fixHeaders($headers);
+
+ // check port
+ if (isset($urlInfo['port']))
+ {
+ $this->urlInfo['port'] = $urlInfo['port'];
+ }
+ else if (!isset($this->urlInfo['port']))
+ {
+ $this->urlInfo['port'] = 80;
+ }
+
+ if(!isset($urlInfo['host']))
+ {
+ // relative link
+ $uri = $this->urlInfo['scheme'].'://'.$this->urlInfo['host'].':'.$this->urlInfo['port'].'/'.$uri;
+ }
+ else if($urlInfo['scheme'] != 'http' && $urlInfo['scheme'] != 'https')
+ {
+ throw new Exception('sfWebBrowser handles only http and https requests');
+ }
+
+ $this->urlInfo = parse_url($uri);
+
+ $this->initializeResponse();
+
+ if ($changeStack)
+ {
+ $this->addToStack($uri, $method, $parameters, $headers);
+ }
+
+ $browser = $this->adapter->call($this, $uri, $method, $parameters, $headers);
+
+ // redirect support
+ if ((in_array($browser->getResponseCode(), array(301, 307)) && in_array($method, array('GET', 'HEAD'))) || in_array($browser->getResponseCode(), array(302,303)))
+ {
+ $this->call($browser->getResponseHeader('Location'), 'GET', array(), $headers);
+ }
+
+ return $browser;
+ }
+
+ /**
+ * Gives a value to a form field in the response
+ *
+ * @param string field name
+ * @param string field value
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function setField($name, $value)
+ {
+ // as we don't know yet the form, just store name/value pairs
+ $this->parseArgumentAsArray($name, $value, $this->fields);
+
+ return $this;
+ }
+
+ /**
+ * Looks for a link or a button in the response and submits the related request
+ *
+ * @param string The link/button value/href/alt
+ * @param array request parameters (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function click($name, $arguments = array())
+ {
+ if (!$dom = $this->getResponseDom())
+ {
+ throw new Exception('Cannot click because there is no current page in the browser');
+ }
+
+ $xpath = new DomXpath($dom);
+
+ // text link, the name being in an attribute
+ if ($link = $xpath->query(sprintf('//a[@*="%s"]', $name))->item(0))
+ {
+ return $this->get($link->getAttribute('href'));
+ }
+
+ // text link, the name being the text value
+ if ($links = $xpath->query('//a[@href]'))
+ {
+ foreach($links as $link)
+ {
+ if(preg_replace(array('/\s{2,}/', '/\\r\\n|\\n|\\r/'), array(' ', ''), $link->nodeValue) == $name)
+ {
+ return $this->get($link->getAttribute('href'));
+ }
+ }
+ }
+
+ // image link, the name being the alt attribute value
+ if ($link = $xpath->query(sprintf('//a/img[@alt="%s"]/ancestor::a', $name))->item(0))
+ {
+ return $this->get($link->getAttribute('href'));
+ }
+
+ // form, the name being the button or input value
+ if (!$form = $xpath->query(sprintf('//input[((@type="submit" or @type="button") and @value="%s") or (@type="image" and @alt="%s")]/ancestor::form', $name, $name))->item(0))
+ {
+ throw new Exception(sprintf('Cannot find the "%s" link or button.', $name));
+ }
+
+ // form attributes
+ $url = $form->getAttribute('action');
+ $method = $form->getAttribute('method') ? strtolower($form->getAttribute('method')) : 'get';
+
+ // merge form default values and arguments
+ $defaults = array();
+ foreach ($xpath->query('descendant::input | descendant::textarea | descendant::select', $form) as $element)
+ {
+ $elementName = $element->getAttribute('name');
+ $nodeName = $element->nodeName;
+ $value = null;
+ if ($nodeName == 'input' && ($element->getAttribute('type') == 'checkbox' || $element->getAttribute('type') == 'radio'))
+ {
+ if ($element->getAttribute('checked'))
+ {
+ $value = $element->getAttribute('value');
+ }
+ }
+ else if (
+ $nodeName == 'input'
+ &&
+ (($element->getAttribute('type') != 'submit' && $element->getAttribute('type') != 'button') || $element->getAttribute('value') == $name)
+ &&
+ ($element->getAttribute('type') != 'image' || $element->getAttribute('alt') == $name)
+ )
+ {
+ $value = $element->getAttribute('value');
+ }
+ else if ($nodeName == 'textarea')
+ {
+ $value = '';
+ foreach ($element->childNodes as $el)
+ {
+ $value .= $dom->saveXML($el);
+ }
+ }
+ else if ($nodeName == 'select')
+ {
+ if ($multiple = $element->hasAttribute('multiple'))
+ {
+ $elementName = str_replace('[]', '', $elementName);
+ $value = array();
+ }
+ else
+ {
+ $value = null;
+ }
+
+ $found = false;
+ foreach ($xpath->query('descendant::option', $element) as $option)
+ {
+ if ($option->getAttribute('selected'))
+ {
+ $found = true;
+ if ($multiple)
+ {
+ $value[] = $option->getAttribute('value');
+ }
+ else
+ {
+ $value = $option->getAttribute('value');
+ }
+ }
+ }
+
+ // if no option is selected and if it is a simple select box, take the first option as the value
+ if (!$found && !$multiple)
+ {
+ $value = $xpath->query('descendant::option', $element)->item(0)->getAttribute('value');
+ }
+ }
+
+ if (null !== $value)
+ {
+ $this->parseArgumentAsArray($elementName, $value, $defaults);
+ }
+ }
+
+ // create request parameters
+ $arguments = sfToolkit::arrayDeepMerge($defaults, $this->fields, $arguments);
+ if ('post' == $method)
+ {
+ return $this->post($url, $arguments);
+ }
+ else
+ {
+ return $this->get($url, $arguments);
+ }
+ }
+
+ protected function parseArgumentAsArray($name, $value, &$vars)
+ {
+ if (false !== $pos = strpos($name, '['))
+ {
+ $var = &$vars;
+ $tmps = array_filter(preg_split('/(\[ | \[\] | \])/x', $name));
+ foreach ($tmps as $tmp)
+ {
+ $var = &$var[$tmp];
+ }
+ if ($var)
+ {
+ if (!is_array($var))
+ {
+ $var = array($var);
+ }
+ $var[] = $value;
+ }
+ else
+ {
+ $var = $value;
+ }
+ }
+ else
+ {
+ $vars[$name] = $value;
+ }
+ }
+
+ /**
+ * Adds the current request to the history stack
+ *
+ * @param string The request uri
+ * @param string The request method
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function addToStack($uri, $method, $parameters, $headers)
+ {
+ $this->stack = array_slice($this->stack, 0, $this->stackPosition + 1);
+ $this->stack[] = array(
+ 'uri' => $uri,
+ 'method' => $method,
+ 'parameters' => $parameters,
+ 'headers' => $headers
+ );
+ $this->stackPosition = count($this->stack) - 1;
+
+ return $this;
+ }
+
+ /**
+ * Submits the previous request in history again
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function back()
+ {
+ if ($this->stackPosition < 1)
+ {
+ throw new Exception('You are already on the first page.');
+ }
+
+ --$this->stackPosition;
+ return $this->call($this->stack[$this->stackPosition]['uri'],
+ $this->stack[$this->stackPosition]['method'],
+ $this->stack[$this->stackPosition]['parameters'],
+ $this->stack[$this->stackPosition]['headers'],
+ false);
+ }
+
+ /**
+ * Submits the next request in history again
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function forward()
+ {
+ if ($this->stackPosition > count($this->stack) - 2)
+ {
+ throw new Exception('You are already on the last page.');
+ }
+
+ ++$this->stackPosition;
+ return $this->call($this->stack[$this->stackPosition]['uri'],
+ $this->stack[$this->stackPosition]['method'],
+ $this->stack[$this->stackPosition]['parameters'],
+ $this->stack[$this->stackPosition]['headers'],
+ false);
+ }
+
+ /**
+ * Submits the current request again
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function reload()
+ {
+ if (-1 == $this->stackPosition)
+ {
+ throw new Exception('No page to reload.');
+ }
+
+ return $this->call($this->stack[$this->stackPosition]['uri'],
+ $this->stack[$this->stackPosition]['method'],
+ $this->stack[$this->stackPosition]['parameters'],
+ $this->stack[$this->stackPosition]['headers'],
+ false);
+ }
+
+ /**
+ * Transforms an associative array of header names => header values to its HTTP equivalent.
+ *
+ * @param array $headers
+ * @return string
+ */
+ public function prepareHeaders($headers = array())
+ {
+ $prepared_headers = array();
+ foreach ($headers as $name => $value)
+ {
+ $prepared_headers[] = sprintf("%s: %s\r\n", ucfirst($name), $value);
+ }
+
+ return implode('', $prepared_headers);
+ }
+
+ // Response methods
+
+ /**
+ * Initializes the response and erases all content from prior requests
+ */
+ public function initializeResponse()
+ {
+ $this->responseHeaders = array();
+ $this->responseCode = '';
+ $this->responseText = '';
+ $this->responseDom = null;
+ $this->responseDomCssSelector = null;
+ $this->responseXml = null;
+ $this->fields = array();
+ }
+
+ /**
+ * Set the response headers
+ *
+ * @param array The response headers as an array of strings shaped like "key: value"
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function setResponseHeaders($headers = array())
+ {
+ $header_array = array();
+ foreach($headers as $header)
+ {
+ $arr = explode(': ', $header);
+ if(isset($arr[1]))
+ {
+ $header_array[$this->normalizeHeaderName($arr[0])] = trim($arr[1]);
+ }
+ }
+
+ $this->responseHeaders = $header_array;
+
+ return $this;
+ }
+
+ /**
+ * Set the response code
+ *
+ * @param string The first line of the response
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function setResponseCode($firstLine)
+ {
+ preg_match('/\d{3}/', $firstLine, $matches);
+ if(isset($matches[0]))
+ {
+ $this->responseCode = $matches[0];
+ }
+ else
+ {
+ $this->responseCode = '';
+ }
+
+ return $this;
+ }
+
+ /**
+ * Set the response contents
+ *
+ * @param string The response contents
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function setResponseText($res)
+ {
+ $this->responseText = $res;
+
+ return $this;
+ }
+
+ /**
+ * Get a text version of the response
+ *
+ * @return string The response contents
+ */
+ public function getResponseText()
+ {
+ $text = $this->responseText;
+
+ // Decode any content-encoding (gzip or deflate) if needed
+ switch (strtolower($this->getResponseHeader('content-encoding'))) {
+
+ // Handle gzip encoding
+ case 'gzip':
+ $text = $this->decodeGzip($text);
+ break;
+
+ // Handle deflate encoding
+ case 'deflate':
+ $text = $this->decodeDeflate($text);
+ break;
+
+ default:
+ break;
+ }
+
+ return $text;
+ }
+
+ /**
+ * Get a text version of the body part of the response (without <body> and </body>)
+ *
+ * @return string The body part of the response contents
+ */
+ public function getResponseBody()
+ {
+ preg_match('/<body.*?>(.*)<\/body>/si', $this->getResponseText(), $matches);
+
+ return isset($matches[1]) ? $matches[1] : '';
+ }
+
+ /**
+ * Get a DOMDocument version of the response
+ *
+ * @return DOMDocument The reponse contents
+ */
+ public function getResponseDom()
+ {
+ if(!$this->responseDom)
+ {
+ // for HTML/XML content, create a DOM object for the response content
+ if (preg_match('/(x|ht)ml/i', $this->getResponseHeader('Content-Type')))
+ {
+ $this->responseDom = new DomDocument('1.0', 'utf8');
+ $this->responseDom->validateOnParse = true;
+ @$this->responseDom->loadHTML($this->getResponseText());
+ }
+ }
+
+ return $this->responseDom;
+ }
+
+ /**
+ * Get a sfDomCssSelector version of the response
+ *
+ * @return sfDomCssSelector The response contents
+ */
+ public function getResponseDomCssSelector()
+ {
+ if(!$this->responseDomCssSelector)
+ {
+ // for HTML/XML content, create a DOM object for the response content
+ if (preg_match('/(x|ht)ml/i', $this->getResponseHeader('Content-Type')))
+ {
+ $this->responseDomCssSelector = new sfDomCssSelector($this->getResponseDom());
+ }
+ }
+
+ return $this->responseDomCssSelector;
+ }
+
+ /**
+ * Get a SimpleXML version of the response
+ *
+ * @return SimpleXMLElement The reponse contents
+ * @throws sfWebBrowserInvalidResponseException when response is not in a valid format
+ */
+ public function getResponseXML()
+ {
+ if(!$this->responseXml)
+ {
+ // for HTML/XML content, create a DOM object for the response content
+ if (preg_match('/(x|ht)ml/i', $this->getResponseHeader('Content-Type')))
+ {
+ $this->responseXml = @simplexml_load_string($this->getResponseText());
+ }
+ }
+
+ // Throw an exception if response is not valid XML
+ if (get_class($this->responseXml) != 'SimpleXMLElement')
+ {
+ $msg = sprintf("Response is not a valid XML string : \n%s", $this->getResponseText());
+ throw new sfWebBrowserInvalidResponseException($msg);
+ }
+
+ return $this->responseXml;
+ }
+
+ /**
+ * Returns true if server response is an error.
+ *
+ * @return bool
+ */
+ public function responseIsError()
+ {
+ return in_array((int)($this->getResponseCode() / 100), array(4, 5));
+ }
+
+ /**
+ * Get the response headers
+ *
+ * @return array The response headers
+ */
+ public function getResponseHeaders()
+ {
+ return $this->responseHeaders;
+ }
+
+ /**
+ * Get a response header
+ *
+ * @param string The response header name
+ *
+ * @return string The response header value
+ */
+ public function getResponseHeader($key)
+ {
+ $normalized_key = $this->normalizeHeaderName($key);
+ return (isset($this->responseHeaders[$normalized_key])) ? $this->responseHeaders[$normalized_key] : '';
+ }
+
+ /**
+ * Decodes gzip-encoded content ("content-encoding: gzip" response header).
+ *
+ * @param stream $gzip_text
+ * @return string
+ */
+ protected function decodeGzip($gzip_text)
+ {
+ return gzinflate(substr($gzip_text, 10));
+ }
+
+ /**
+ * Decodes deflate-encoded content ("content-encoding: deflate" response header).
+ *
+ * @param stream $deflate_text
+ * @return string
+ */
+ protected function decodeDeflate($deflate_text)
+ {
+ return gzuncompress($deflate_text);
+ }
+
+ /**
+ * Get the response code
+ *
+ * @return string The response code
+ */
+ public function getResponseCode()
+ {
+ return $this->responseCode;
+ }
+
+ /**
+ * Returns the response message (the 'Not Found' part in 'HTTP/1.1 404 Not Found')
+ *
+ * @return string
+ */
+ public function getResponseMessage()
+ {
+ return $this->responseMessage;
+ }
+
+ /**
+ * Sets response message.
+ *
+ * @param string $message
+ */
+ public function setResponseMessage($msg)
+ {
+ $this->responseMessage = $msg;
+ }
+
+ public function getUrlInfo()
+ {
+ return $this->urlInfo;
+ }
+
+ public function getDefaultRequestHeaders()
+ {
+ return $this->defaultHeaders;
+ }
+
+ /**
+ * Adds default headers to the supplied headers array.
+ *
+ * @param array $headers
+ * @return array
+ */
+ public function initializeRequestHeaders($headers = array())
+ {
+ // Supported encodings
+ $encodings = array();
+ if (isset($headers['Accept-Encoding']))
+ {
+ $encodings = explode(',', $headers['Accept-Encoding']);
+ }
+ if (function_exists('gzinflate') && !in_array('gzip', $encodings))
+ {
+ $encodings[] = 'gzip';
+ }
+ if (function_exists('gzuncompress') && !in_array('deflate', $encodings))
+ {
+ $encodings[] = 'deflate';
+ }
+
+ $headers['Accept-Encoding'] = implode(',', array_unique($encodings));
+
+ return $headers;
+ }
+
+ /**
+ * Validates supplied headers and turns all names to lowercase.
+ *
+ * @param array $headers
+ * @return array
+ */
+ protected function fixHeaders($headers)
+ {
+ $fixed_headers = array();
+ foreach ($headers as $name => $value)
+ {
+ if (!preg_match('/([a-z]*)(-[a-z]*)*/i', $name))
+ {
+ $msg = sprintf('Invalid header "%s"', $name);
+ throw new Exception($msg);
+ }
+ $fixed_headers[$this->normalizeHeaderName($name)] = trim($value);
+ }
+
+ return $fixed_headers;
+ }
+
+ /**
+ * Retrieves a normalized Header.
+ *
+ * @param string Header name
+ *
+ * @return string Normalized header
+ */
+ protected function normalizeHeaderName($name)
+ {
+ return preg_replace('/\-(.)/e', "'-'.strtoupper('\\1')", strtr(ucfirst($name), '_', '-'));
+ }
+
+}
|
diem-project/sfWebBrowserPlugin
|
5bbe57d5cad2b9d0701a5065889e68995203e1ee
|
Synchronizing svn
|
diff --git a/lib/sfCurlAdapter.class.php b/lib/sfCurlAdapter.class.php
index 7de90c3..d0eb968 100644
--- a/lib/sfCurlAdapter.class.php
+++ b/lib/sfCurlAdapter.class.php
@@ -1,237 +1,242 @@
<?php
/*
* This file is part of the sfWebBrowserPlugin package.
* (c) 2004-2006 Francois Zaninotto <[email protected]>
* (c) 2004-2006 Fabien Potencier <[email protected]> for the click-related functions
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* sfWebBrowser provides a basic HTTP client.
*
* @package sfWebBrowserPlugin
* @author Francois Zaninotto <[email protected]>
* @author Ben Meynell <[email protected]>
* @version 0.9
*/
class sfCurlAdapter
{
protected
$options = array(),
$curl = null,
$headers = array();
/**
* Build a curl adapter instance
* Accepts an option of parameters passed to the PHP curl adapter:
* ssl_verify => [true/false]
* verbose => [true/false]
* verbose_log => [true/false]
* Additional options are passed as curl options, under the form:
* userpwd => CURL_USERPWD
* timeout => CURL_TIMEOUT
* ...
*
* @param array $options Curl-specific options
*/
public function __construct($options = array())
{
if (!extension_loaded('curl'))
{
throw new Exception('Curl extension not loaded');
}
$this->options = $options;
$curl_options = $options;
$this->curl = curl_init();
// cookies
if (isset($curl_options['cookies']))
{
if (isset($curl_options['cookies_file']))
{
$cookie_file = $curl_options['cookies_file'];
unset($curl_options['cookies_file']);
}
else
{
$cookie_file = sfConfig::get('sf_data_dir').'/sfWebBrowserPlugin/sfCurlAdapter/cookies.txt';
}
if (isset($curl_options['cookies_dir']))
{
$cookie_dir = $curl_options['cookies_dir'];
unset($curl_options['cookies_dir']);
}
else
{
$cookie_dir = sfConfig::get('sf_data_dir').'/sfWebBrowserPlugin/sfCurlAdapter';
}
if (!is_dir($cookie_dir))
{
if (!mkdir($cookie_dir, 0777, true))
{
throw new Exception(sprintf('Could not create directory "%s"', $cookie_dir));
}
}
curl_setopt($this->curl, CURLOPT_COOKIESESSION, false);
curl_setopt($this->curl, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($this->curl, CURLOPT_COOKIEFILE, $cookie_file);
unset($curl_options['cookies']);
}
// default settings
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($this->curl, CURLOPT_AUTOREFERER, true);
curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($this->curl, CURLOPT_FRESH_CONNECT, true);
- if(isset($this->options['followlocation']))
+ if(isset($curl_options['followlocation']))
{
curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, (bool) $this->options['followlocation']);
+ unset($curl_options['followlocation']);
}
// activate ssl certificate verification?
-
- if (isset($this->options['ssl_verify_host']))
+ if (isset($curl_options['ssl_verify_host']))
{
curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, (bool) $this->options['ssl_verify_host']);
+ unset($curl_options['ssl_verify_host']);
}
+
if (isset($curl_options['ssl_verify']))
{
curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, (bool) $this->options['ssl_verify']);
unset($curl_options['ssl_verify']);
}
+
// verbose execution?
if (isset($curl_options['verbose']))
{
curl_setopt($this->curl, CURLOPT_NOPROGRESS, false);
curl_setopt($this->curl, CURLOPT_VERBOSE, true);
unset($curl_options['cookies']);
}
+
if (isset($curl_options['verbose_log']))
{
$log_file = sfConfig::get('sf_log_dir').'/sfCurlAdapter_verbose.log';
curl_setopt($this->curl, CURLOPT_VERBOSE, true);
$this->fh = fopen($log_file, 'a+b');
curl_setopt($this->curl, CURLOPT_STDERR, $this->fh);
unset($curl_options['verbose_log']);
}
// Additional options
foreach ($curl_options as $key => $value)
{
$const = constant('CURLOPT_' . strtoupper($key));
if(!is_null($const))
{
curl_setopt($this->curl, $const, $value);
}
}
// response header storage - uses callback function
curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, array($this, 'read_header'));
}
/**
* Submits a request
*
* @param string The request uri
* @param string The request method
* @param array The request parameters (associative array)
* @param array The request headers (associative array)
*
* @return sfWebBrowser The current browser object
*/
public function call($browser, $uri, $method = 'GET', $parameters = array(), $headers = array())
{
// uri
curl_setopt($this->curl, CURLOPT_URL, $uri);
// request headers
$m_headers = array_merge($browser->getDefaultRequestHeaders(), $browser->initializeRequestHeaders($headers));
$request_headers = explode("\r\n", $browser->prepareHeaders($m_headers));
curl_setopt($this->curl, CURLOPT_HTTPHEADER, $request_headers);
// encoding support
if(isset($headers['Accept-Encoding']))
{
curl_setopt($this->curl, CURLOPT_ENCODING, $headers['Accept-Encoding']);
}
// timeout support
if(isset($this->options['Timeout']))
{
curl_setopt($this->curl, CURLOPT_TIMEOUT, $this->options['Timeout']);
}
if (!empty($parameters))
{
if (!is_array($parameters))
{
curl_setopt($this->curl, CURLOPT_POSTFIELDS, $parameters);
}
else
{
// multipart posts (file upload support)
$has_files = false;
foreach ($parameters as $name => $value)
{
if (is_array($value)) {
continue;
}
if (is_file($value))
{
$has_files = true;
$parameters[$name] = '@'.realpath($value);
}
}
if($has_files)
{
curl_setopt($this->curl, CURLOPT_POSTFIELDS, $parameters);
}
else
{
curl_setopt($this->curl, CURLOPT_POSTFIELDS, http_build_query($parameters, '', '&'));
}
}
}
// handle any request method
curl_setopt($this->curl, CURLOPT_CUSTOMREQUEST, $method);
- $response = curl_exec($this->curl);
+ $response = curl_exec($this->curl);
+
if (curl_errno($this->curl))
{
throw new Exception(curl_error($this->curl));
}
$requestInfo = curl_getinfo($this->curl);
$browser->setResponseCode($requestInfo['http_code']);
$browser->setResponseHeaders($this->headers);
$browser->setResponseText($response);
// clear response headers
$this->headers = array();
return $browser;
}
public function __destruct()
{
curl_close($this->curl);
}
protected function read_header($curl, $headers)
{
$this->headers[] = $headers;
return strlen($headers);
}
}
|
diem-project/sfWebBrowserPlugin
|
0202ec846b48b519cc0fee04e51a6eb38f7fe6a1
|
Synchronizing svn
|
diff --git a/.gitignore b/.gitignore
index 1b53ace..e40818c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
.svn/
+.svn*
|
diem-project/sfWebBrowserPlugin
|
238f4154457fff9b628338cbb0f0e662367c5f6b
|
Synchronizing svn
|
diff --git a/.svn/all-wcprops b/.svn/all-wcprops
new file mode 100644
index 0000000..6c4d604
--- /dev/null
+++ b/.svn/all-wcprops
@@ -0,0 +1,23 @@
+K 25
+svn:wc:ra_dav:version-url
+V 48
+/!svn/ver/18169/plugins/sfWebBrowserPlugin/trunk
+END
+LICENSE
+K 25
+svn:wc:ra_dav:version-url
+V 56
+/!svn/ver/13162/plugins/sfWebBrowserPlugin/trunk/LICENSE
+END
+package.xml
+K 25
+svn:wc:ra_dav:version-url
+V 60
+/!svn/ver/18168/plugins/sfWebBrowserPlugin/trunk/package.xml
+END
+README
+K 25
+svn:wc:ra_dav:version-url
+V 55
+/!svn/ver/18169/plugins/sfWebBrowserPlugin/trunk/README
+END
diff --git a/.svn/entries b/.svn/entries
new file mode 100644
index 0000000..ce61d63
--- /dev/null
+++ b/.svn/entries
@@ -0,0 +1,136 @@
+10
+
+dir
+27927
+http://svn.symfony-project.com/plugins/sfWebBrowserPlugin/trunk
+http://svn.symfony-project.com
+
+
+
+2009-05-12T14:01:12.036661Z
+18169
+francois
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ee427ae8-e902-0410-961c-c3ed070cd9f9
+
+test
+dir
+
+LICENSE
+file
+
+
+
+
+2010-02-09T21:41:24.000000Z
+e3129364106e59e5c6b572234b914ec7
+2008-11-19T17:28:36.420592Z
+13162
+Kris.Wallsmith
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1074
+
+lib
+dir
+
+package.xml
+file
+
+
+
+
+2010-02-09T21:41:24.000000Z
+4a25a69eb6d10dac5a7a869a923d6623
+2009-05-12T13:49:19.279886Z
+18168
+francois
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4482
+
+README
+file
+
+
+
+
+2010-02-09T21:41:24.000000Z
+faad5445742c16b60092118c6be45a13
+2009-05-12T14:01:12.036661Z
+18169
+francois
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10872
+
diff --git a/.svn/prop-base/LICENSE.svn-base b/.svn/prop-base/LICENSE.svn-base
new file mode 100644
index 0000000..3160658
--- /dev/null
+++ b/.svn/prop-base/LICENSE.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mergeinfo
+V 0
+
+END
diff --git a/.svn/prop-base/README.svn-base b/.svn/prop-base/README.svn-base
new file mode 100644
index 0000000..3160658
--- /dev/null
+++ b/.svn/prop-base/README.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mergeinfo
+V 0
+
+END
diff --git a/.svn/prop-base/package.xml.svn-base b/.svn/prop-base/package.xml.svn-base
new file mode 100644
index 0000000..3160658
--- /dev/null
+++ b/.svn/prop-base/package.xml.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mergeinfo
+V 0
+
+END
diff --git a/.svn/text-base/LICENSE.svn-base b/.svn/text-base/LICENSE.svn-base
new file mode 100644
index 0000000..f5c493b
--- /dev/null
+++ b/.svn/text-base/LICENSE.svn-base
@@ -0,0 +1,7 @@
+Copyright (c) 2004-2008 Francois Zaninotto
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/.svn/text-base/README.svn-base b/.svn/text-base/README.svn-base
new file mode 100644
index 0000000..aabe594
--- /dev/null
+++ b/.svn/text-base/README.svn-base
@@ -0,0 +1,269 @@
+sfWebBrowser plugin
+===================
+
+The `sfWebBrowserPlugin` proposes an HTTP client capable of making web requests. The interface is similar to that of `sfTestBrowser`.
+
+Possible uses
+-------------
+
+ * Querying a Web service
+ * Monitoring a Website
+ * Mashup of content from several websites
+ * Aggregation of RSS feeds
+ * Proxy to another server
+ * Cross-domain AJAX interactions
+ * API to foreign websites
+ * Fetch images and other types of content
+ * ...
+
+Contents
+--------
+
+This plugin contains four classes: `sfWebBrowser`, `sfCurlAdapter`, `sfFopenAdapter`, and `sfSocketsAdapter`. Unit tests are available in the SVN repository, to be placed in a symfony application's `test/` directory.
+
+Features
+--------
+
+The `sfWebBrowser` class makes web requests based on a URI:
+
+ [php]
+ $b = new sfWebBrowser();
+ $b->get('http://www.example.com/');
+ $res = $b->getResponseText();
+
+The usual methods of the `sfTestBrowser` also work there, with the fluid interface.
+
+ [php]
+ // Inline
+ $b->get('http://www.example.com/')->get('http://www.google.com/')->back()->reload();
+ // More readable
+ $b->get('http://www.example.com/')
+ ->get('http://www.google.com/')
+ ->back()
+ ->reload();
+
+The browser accepts absolute and relative URIs
+
+ [php]
+ $b->get('http://www.example.com/test.html');
+ $b->get('test.html');
+
+The `get()` method accepts parameters either as a query string, or as an associative array.
+
+ [php]
+ $b->get('http://www.example.com/test.php?foo=bar');
+ $b->get('http://www.example.com/test.php', array('foo' => 'bar'));
+
+POST, PUT and DELETE requests are also supported.
+
+ [php]
+ $b->post('http://www.example.com/test.php', array('foo' => 'bar'));
+ $b->put('http://www.example.com/test.php', array('foo' => 'bar'));
+ $b->delete('http://www.example.com/test.php', array('foo' => 'bar'));
+
+You can access the response in various formats, at your convenience:
+
+ [php]
+ $myString = $b->getResponseText();
+ $myString = $b->getResponseBody(); // drop the <head> part
+ $myDomDocument = $b->getResponseDom();
+ $myDomCssSelector = $b->getResponseDomCssSelector();
+ $mySimpleXml = $b->getResponseXml();
+
+You can also interact with the response with the `setFields()` and `click()` methods.
+
+ [php]
+ $b->get('http://www.example.com/login')
+ ->setField('user', 'foobar')
+ ->setField('password', 'barbaz')
+ ->click('submit');
+
+The browser supports HTTP and HTTPS requests, proxies, redirects, and timeouts.
+
+Gzip and deflate content-encoded response bodies are also supported, provided that you have the [http://php.net/zlib zlib extention] enabled.
+
+Adapters
+--------
+
+The browser can use various adapters to perform the requests, and uses the following selection order by default:
+
+ * `sfCurlAdapter`: Uses [Curl](http://php.net/curl) to fetch pages. This adapter is a lot faster than `sfFopenAdapter`, however PHP must be compiled with the `with-curl` option, and the `curl` extension must be enabled in `php.ini` (which is rarely the case by default) for it to work.
+
+ * `sfFopenAdapter`: Uses [`fopen()`](http://php.net/fopen ) to fetch pages. `fopen()` can take an URL as a parameter provided that PHP is compiled with sockets support, and `allow_url_fopen` is defined to `true` in `php.ini`. This is the case in most PHP distributions, so the default adapter should work in almost every platform. On the other hand, the compatibility has a cost: this adapter is slow.
+
+ * `sfSocketsAdapter`: Uses [`fsockopen()`](http://php.net/fsockopen) to fetch pages.
+
+Alternatively, you can specify an adapter explicitly when you create a new browser object, as follows:
+
+ [php]
+ // use default adapter, i.e. sfCurlAdapter
+ $b = new sfWebBrowser(array());
+ // use sfFopenAdapter
+ $b = new sfWebBrowser(array(), 'sfFopenAdapter');
+
+Currenly, `sfCurlAdapter` offers slightly more functionality than the other adapters. Namely, it supports multipart file uploads and cookies, which means you can login to a site as well as upload files via forms.
+
+ [php]
+ // upload files via a form
+ $b = new sfWebBrowser();
+ $b->post($url_of_form, array(
+ 'file_field' => '/path/to/my/local/file.jpg'
+ ));
+ // login to a website
+ $b = new sfWebBrowser(array(), 'sfCurlAdapter', array('cookies' => true));
+ $b->post($url_of_login_form, array(
+ 'user_field' => $username,
+ 'pass_field' => $password
+ ));
+
+Full examples are available in the unit tests.
+
+Error Handling
+--------------
+
+`sfWebBrowser` distinguishes to types of error: adapter errors and response errors. Thus, `sfWebBrowser` calls should be run this way :
+
+ [php]
+ $b = new sfWebBrowser();
+ try
+ {
+ if (!$b->get($url)->responseIsError())
+ {
+ // Successful response (eg. 200, 201, etc)
+ }
+ else
+ {
+ // Error response (eg. 404, 500, etc)
+ }
+ }
+ catch (Exception $e)
+ {
+ // Adapter error (eg. Host not found)
+ }
+
+Besides, you should always remember that the response contents may contain incorrect code. Consider it as 'tainted', and therefore always use the [escaping](http://www.symfony-project.com/book/trunk/07-Inside-the-View-Layer#Output%20Escaping) when outputting it to a template.
+
+ [php]
+ // In the action
+ $this->title = (string) $b->getResponseXml()->body->h1
+
+ // In the template
+ <?php echo $title // dangerous ?>
+ <?php echo $sf_data->get('title') // correct ?>
+
+Installation
+------------
+
+* Install the plugin
+
+ > php symfony plugin:install sfWebBrowserPlugin # for symfony 1.1 and 1.2
+ > php symfony plugin-install http://plugins.symfony-project.com/sfWebBrowserPlugin # for symfony 1.0
+
+* Clear the cache to enable the autoloading to find the new class
+
+ > symfony cc
+
+Known limitations
+-----------------
+
+Cookies, caching, and file uploads are not yet supported in any of the packages (some of this functionality is available with `sfCurlAdapter`, see above).
+
+Changelog
+---------
+
+### Trunk
+
+### 2009-05-12 | 1.1.2 Stable
+
+ * francois: Fixed sfCurlAdapter destructor
+ * francois: Fixed sf1.2 compatibility issue for custom exception
+ * francois: Fixed a few limit case bugs and made the tests pass
+
+### 2009-04-22 | 1.1.1 Stable
+
+ * francois: Fixed README syntax for parameters array
+ * bmeynell: Fixed custom options in `sfCurlAdapter`
+
+### 2008-09-23 | 1.1.0 Stable
+
+ * francois: Translated README to Markdown
+ * francois: Added support for custom options in `sfCurlAdapter`
+ * francois: Added suppot for Timeout with `sfCurlAdapter` (based on a patch by adoanhuu)
+ * blacksun: Allow for SSL certificate verification
+ * francois: Added a test to check exceptions thrown by `getResponseXML`
+ * bmeynell: added multipart file upload support to `sfCurlAdapter`
+ * bmeynell: fixed regex in getResponseBody() which was returning an empty body
+ * bmeynell: `sfCurlAdapter`: Added new options: 'cookies', 'cookies_dir', 'cookies_file', 'verbose', 'verbose_log'
+ * bmeynell: `sfCurlAdapter`: Increased speed by Moving some initialization from call() to the constructer
+ * tristan: Easier management of invalid XML responses
+ * francois: Fixed a bug in `sfFopenAdapter` error handler
+ * bmeynell: Added chunked transfer encoding support to `sfSocketsAdapter`
+ * bmeynell: Added support for 301 redirects in `sfSocketsAdapter`
+
+### 2007-03-27 | 1.0.1 stable
+
+ * bmeynell: Fixed a bug with `sfCurlAdapter` causing 'Bad Request' error responses
+ * francois: Fixed a bug with `get()` when `arg_separator.output` is not set to '&' in `php.ini` (patch from river.bright)
+ * francois: Fixed a bug with `get()` when query string is already present in the url (based on a patch from Jeff Merlet)
+ * francois: Fixed auto-adapter decision in `sfWebBrowser::__construct()`
+
+### 2007-03-08 | 1.0.0 stable
+
+ * francois: Added auto-adapter decision in `sfWebBrowser::__construct()`
+ * francois: Changed tested URLs a bit to avoid redirection issues with google
+ * bmeynell: Added `sfSocketsAdapter`
+ * bmeynell: `sfCurlAdapter`: more detailed error messages & leaner request setup
+
+### 2007-02-22 | 0.9.6 Beta
+
+ * bmeynell, tristan: Allowed for requests with any method in `sfCurlAdapter`
+ * tristan: Added `sfWebBrowser::responseIsError()`
+ * tristan: Added `sfWebBrowser::getResponseMessage()`
+ * tristan: Refactored error management in `sfFopenAdapter`
+
+### 2007-02-21 | 0.9.5 Beta
+
+ * bmeynell: Fixed bug with relative uri's attempting to use a port other than 80 (sfWebBrowser, 132 - 146)
+ * bmeynell: Fixed small bug not printing hostname on exception (sfFopenAdapter, 61-62)
+ * bmeynell: Created sfCurlAdapter and passes all unit tests
+ * bmeynell: Removed '$changeStack = true' from call() prototype in sfCurlAdapter, sfFopenAdapter, and moved changestack check to sfWebBrowser
+ * bmeynell: Added $askeet_url to sfWebBrowserTest
+ * bmeynell: Added easy toggling between adapters in sfWebBrowserTest
+ * tristan: Added put() and delete() public methods
+ * tristan: Added unit tests to validate request HTTP method
+
+### 2007-02-16 | 0.9.4 Beta
+
+ * francois: Refactored the browser to make it multi-adapter
+ * francois: '''BC break''' constructor signature changed : `new sfWebBrowser(array $headers, string $adapter_class, array $adapter_options)`
+ * francois: Fixed notice when trying to retrieve inexistent header
+ * francois: Fixed header case normalization
+ * francois: Transformed setResponseXXX() methods to public
+ * francois: Fixed caps in `initializeRequestHeaders()`
+ * francois: Fixed unit test #40
+
+### 2007-02-16 | 0.9.3 Beta
+
+ * tristan: Added support for gzip and deflate.
+ * tristan: Possibility to pass default request headers to sfWebBrowser's constructor
+ * tristan: "Accept-Encoding" header is automatically set depending on PHP capabilities
+ * tristan: Fixed problems with request and response headers case
+ * tristan: Renamed "browser options" to "adapter options" (http://www.symfony-project.com/forum/index.php/m/21635/)
+ * tristan: '''BC break''' constructor signature changed : `new sfWebBrowser(array $headers, array $adapter_options)`
+ * tristan: Unit tested POST requests
+ * tristan: Changed way httpd headers are stored internally
+ * tristan: Fixed small bug in `getResponseBody()`
+ * francois: Fixed unit test for malformed headers
+
+### 2007-02-09 | 0.9.2 Beta
+
+ * francois: Fixed notice with `getResponseXML()`
+
+### 2007-02-08 | 0.9.1 Beta
+
+ * francois: Fixed notice with some headers
+ * francois: Added license and copyright
+
+### 2007-02-08 | 0.9.0 Beta
+
+ * francois: Initial release
diff --git a/.svn/text-base/package.xml.svn-base b/.svn/text-base/package.xml.svn-base
new file mode 100644
index 0000000..c3c66fb
--- /dev/null
+++ b/.svn/text-base/package.xml.svn-base
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" packagerversion="1.4.1" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
+ <name>sfWebBrowserPlugin</name>
+ <channel>pear.symfony-project.com</channel>
+ <summary>Standalone HTTP client</summary>
+ <description>The sfWebBrowserPlugin proposes an HTTP client capable of making web requests. The interface is similar to that of sfTestBrowser.</description>
+ <lead>
+ <name>François Zaninotto</name>
+ <user>fzaninotto</user>
+ <email>[email protected]</email>
+ <active>yes</active>
+ </lead>
+ <date>2009-05-12</date>
+ <version>
+ <release>1.1.2</release>
+ <api>1.1.2</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.symfony-project.com/license">MIT license</license>
+ <notes>-</notes>
+ <contents>
+ <dir name="/">
+ <dir name="lib">
+ <file name="sfCurlAdapter.class.php" role="data"/>
+ <file name="sfFopenAdapter.class.php" role="data"/>
+ <file name="sfSocketsAdapter.class.php" role="data"/>
+ <file name="sfWebBrowser.class.php" role="data"/>
+ <file name="sfWebBrowserInvalidResponseException.class.php" role="data"/>
+ </dir>
+ <file name="README" role="data"/>
+ <file name="LICENSE" role="data"/>
+ </dir>
+ </contents>
+
+ <dependencies>
+ <required>
+ <php>
+ <min>5.1.0</min>
+ </php>
+ <pearinstaller>
+ <min>1.4.1</min>
+ </pearinstaller>
+ <package>
+ <name>symfony</name>
+ <channel>pear.symfony-project.com</channel>
+ <min>0.8.1</min>
+ <max>2.0.0</max>
+ <exclude>2.0.0</exclude>
+ </package>
+ </required>
+ </dependencies>
+
+ <phprelease>
+ </phprelease>
+
+ <changelog>
+ <release>
+ <version>
+ <release>1.1.2</release>
+ <api>1.1.2</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.symfony-project.com/license">MIT license</license>
+ <date>2009-05-12</date>
+ <license>MIT</license>
+ <notes>
+ * francois: Fixed sfCurlAdapter destructor
+ * francois: Fixed sf1.2 compatibility issue for custom exception
+ * francois: Fixed a few limit case bugs and made the tests pass
+ </notes>
+ </release>
+ <release>
+ <version>
+ <release>1.1.1</release>
+ <api>1.1.1</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.symfony-project.com/license">MIT license</license>
+ <date>2009-04-22</date>
+ <license>MIT</license>
+ <notes>
+ * francois: Fixed README syntax for parameters array
+ * bmeynell: Fixed custom options in `sfCurlAdapter`
+ </notes>
+ </release>
+ <release>
+ <version>
+ <release>1.1.0</release>
+ <api>1.1.0</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.symfony-project.com/license">MIT license</license>
+ <date>2008-09-23</date>
+ <license>MIT</license>
+ <notes>
+ * francois: Translated README to Markdown
+ * francois: Added support for custom options in `sfCurlAdapter`
+ * francois: Added suppot for Timeout with `sfCurlAdapter` (based on a patch by adoanhuu)
+ * blacksun: Allow for SSL certificate verification
+ * francois: Added a test to check exceptions thrown by `getResponseXML`
+ * bmeynell: added multipart file upload support to `sfCurlAdapter`
+ * bmeynell: fixed regex in getResponseBody() which was returning an empty body
+ * bmeynell: `sfCurlAdapter`: Added new options: 'cookies', 'cookies_dir', 'cookies_file', 'verbose', 'verbose_log'
+ * bmeynell: `sfCurlAdapter`: Increased speed by Moving some initialization from call() to the constructer
+ * tristan: Easier management of invalid XML responses
+ * francois: Fixed a bug in `sfFopenAdapter` error handler
+ * bmeynell: Added chunked transfer encoding support to `sfSocketsAdapter`
+ * bmeynell: Added support for 301 redirects in `sfSocketsAdapter`
+ </notes>
+ </release>
+ </changelog>
+</package>
diff --git a/lib/.svn/all-wcprops b/lib/.svn/all-wcprops
new file mode 100644
index 0000000..206f6a1
--- /dev/null
+++ b/lib/.svn/all-wcprops
@@ -0,0 +1,35 @@
+K 25
+svn:wc:ra_dav:version-url
+V 52
+/!svn/ver/18167/plugins/sfWebBrowserPlugin/trunk/lib
+END
+sfSocketsAdapter.class.php
+K 25
+svn:wc:ra_dav:version-url
+V 79
+/!svn/ver/18167/plugins/sfWebBrowserPlugin/trunk/lib/sfSocketsAdapter.class.php
+END
+sfWebBrowser.class.php
+K 25
+svn:wc:ra_dav:version-url
+V 75
+/!svn/ver/18167/plugins/sfWebBrowserPlugin/trunk/lib/sfWebBrowser.class.php
+END
+sfCurlAdapter.class.php
+K 25
+svn:wc:ra_dav:version-url
+V 76
+/!svn/ver/18165/plugins/sfWebBrowserPlugin/trunk/lib/sfCurlAdapter.class.php
+END
+sfWebBrowserInvalidResponseException.class.php
+K 25
+svn:wc:ra_dav:version-url
+V 99
+/!svn/ver/18166/plugins/sfWebBrowserPlugin/trunk/lib/sfWebBrowserInvalidResponseException.class.php
+END
+sfFopenAdapter.class.php
+K 25
+svn:wc:ra_dav:version-url
+V 77
+/!svn/ver/18167/plugins/sfWebBrowserPlugin/trunk/lib/sfFopenAdapter.class.php
+END
diff --git a/lib/.svn/dir-prop-base b/lib/.svn/dir-prop-base
new file mode 100644
index 0000000..3160658
--- /dev/null
+++ b/lib/.svn/dir-prop-base
@@ -0,0 +1,5 @@
+K 13
+svn:mergeinfo
+V 0
+
+END
diff --git a/lib/.svn/entries b/lib/.svn/entries
new file mode 100644
index 0000000..9a0e103
--- /dev/null
+++ b/lib/.svn/entries
@@ -0,0 +1,198 @@
+10
+
+dir
+27927
+http://svn.symfony-project.com/plugins/sfWebBrowserPlugin/trunk/lib
+http://svn.symfony-project.com
+
+
+
+2009-05-12T13:43:50.573589Z
+18167
+francois
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+ee427ae8-e902-0410-961c-c3ed070cd9f9
+
+sfSocketsAdapter.class.php
+file
+
+
+
+
+2010-02-09T21:41:24.000000Z
+f4f1fcdc1f949f624d82c15a41de5eab
+2009-05-12T13:43:50.573589Z
+18167
+francois
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4335
+
+sfWebBrowser.class.php
+file
+
+
+
+
+2010-02-09T21:41:24.000000Z
+da0f80ca4be0a7b49e3969b30f540e82
+2009-05-12T13:43:50.573589Z
+18167
+francois
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+23449
+
+sfCurlAdapter.class.php
+file
+
+
+
+
+2010-02-09T21:41:24.000000Z
+75f4a1c23bd0cd24f82b8758fce92f7f
+2009-05-12T13:41:47.482226Z
+18165
+francois
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7042
+
+sfWebBrowserInvalidResponseException.class.php
+file
+
+
+
+
+2010-02-09T21:41:24.000000Z
+2f39ae64a4c00e7e9a7f41e4d92d5bf4
+2009-05-12T13:43:01.083636Z
+18166
+francois
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+619
+
+sfFopenAdapter.class.php
+file
+
+
+
+
+2010-02-09T21:41:24.000000Z
+566d09923c07a01581cdb382b51061df
+2009-05-12T13:43:50.573589Z
+18167
+francois
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4494
+
diff --git a/lib/.svn/text-base/sfCurlAdapter.class.php.svn-base b/lib/.svn/text-base/sfCurlAdapter.class.php.svn-base
new file mode 100644
index 0000000..7de90c3
--- /dev/null
+++ b/lib/.svn/text-base/sfCurlAdapter.class.php.svn-base
@@ -0,0 +1,237 @@
+<?php
+
+/*
+ * This file is part of the sfWebBrowserPlugin package.
+ * (c) 2004-2006 Francois Zaninotto <[email protected]>
+ * (c) 2004-2006 Fabien Potencier <[email protected]> for the click-related functions
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * sfWebBrowser provides a basic HTTP client.
+ *
+ * @package sfWebBrowserPlugin
+ * @author Francois Zaninotto <[email protected]>
+ * @author Ben Meynell <[email protected]>
+ * @version 0.9
+ */
+
+class sfCurlAdapter
+{
+ protected
+ $options = array(),
+ $curl = null,
+ $headers = array();
+
+ /**
+ * Build a curl adapter instance
+ * Accepts an option of parameters passed to the PHP curl adapter:
+ * ssl_verify => [true/false]
+ * verbose => [true/false]
+ * verbose_log => [true/false]
+ * Additional options are passed as curl options, under the form:
+ * userpwd => CURL_USERPWD
+ * timeout => CURL_TIMEOUT
+ * ...
+ *
+ * @param array $options Curl-specific options
+ */
+ public function __construct($options = array())
+ {
+ if (!extension_loaded('curl'))
+ {
+ throw new Exception('Curl extension not loaded');
+ }
+
+ $this->options = $options;
+ $curl_options = $options;
+
+ $this->curl = curl_init();
+
+ // cookies
+ if (isset($curl_options['cookies']))
+ {
+ if (isset($curl_options['cookies_file']))
+ {
+ $cookie_file = $curl_options['cookies_file'];
+ unset($curl_options['cookies_file']);
+ }
+ else
+ {
+ $cookie_file = sfConfig::get('sf_data_dir').'/sfWebBrowserPlugin/sfCurlAdapter/cookies.txt';
+ }
+ if (isset($curl_options['cookies_dir']))
+ {
+ $cookie_dir = $curl_options['cookies_dir'];
+ unset($curl_options['cookies_dir']);
+ }
+ else
+ {
+ $cookie_dir = sfConfig::get('sf_data_dir').'/sfWebBrowserPlugin/sfCurlAdapter';
+ }
+ if (!is_dir($cookie_dir))
+ {
+ if (!mkdir($cookie_dir, 0777, true))
+ {
+ throw new Exception(sprintf('Could not create directory "%s"', $cookie_dir));
+ }
+ }
+
+ curl_setopt($this->curl, CURLOPT_COOKIESESSION, false);
+ curl_setopt($this->curl, CURLOPT_COOKIEJAR, $cookie_file);
+ curl_setopt($this->curl, CURLOPT_COOKIEFILE, $cookie_file);
+ unset($curl_options['cookies']);
+ }
+
+ // default settings
+ curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($this->curl, CURLOPT_AUTOREFERER, true);
+ curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, false);
+ curl_setopt($this->curl, CURLOPT_FRESH_CONNECT, true);
+
+ if(isset($this->options['followlocation']))
+ {
+ curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, (bool) $this->options['followlocation']);
+ }
+
+ // activate ssl certificate verification?
+
+ if (isset($this->options['ssl_verify_host']))
+ {
+ curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, (bool) $this->options['ssl_verify_host']);
+ }
+ if (isset($curl_options['ssl_verify']))
+ {
+ curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, (bool) $this->options['ssl_verify']);
+ unset($curl_options['ssl_verify']);
+ }
+ // verbose execution?
+ if (isset($curl_options['verbose']))
+ {
+ curl_setopt($this->curl, CURLOPT_NOPROGRESS, false);
+ curl_setopt($this->curl, CURLOPT_VERBOSE, true);
+ unset($curl_options['cookies']);
+ }
+ if (isset($curl_options['verbose_log']))
+ {
+ $log_file = sfConfig::get('sf_log_dir').'/sfCurlAdapter_verbose.log';
+ curl_setopt($this->curl, CURLOPT_VERBOSE, true);
+ $this->fh = fopen($log_file, 'a+b');
+ curl_setopt($this->curl, CURLOPT_STDERR, $this->fh);
+ unset($curl_options['verbose_log']);
+ }
+
+ // Additional options
+ foreach ($curl_options as $key => $value)
+ {
+ $const = constant('CURLOPT_' . strtoupper($key));
+ if(!is_null($const))
+ {
+ curl_setopt($this->curl, $const, $value);
+ }
+ }
+
+ // response header storage - uses callback function
+ curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, array($this, 'read_header'));
+ }
+
+ /**
+ * Submits a request
+ *
+ * @param string The request uri
+ * @param string The request method
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function call($browser, $uri, $method = 'GET', $parameters = array(), $headers = array())
+ {
+ // uri
+ curl_setopt($this->curl, CURLOPT_URL, $uri);
+
+ // request headers
+ $m_headers = array_merge($browser->getDefaultRequestHeaders(), $browser->initializeRequestHeaders($headers));
+ $request_headers = explode("\r\n", $browser->prepareHeaders($m_headers));
+ curl_setopt($this->curl, CURLOPT_HTTPHEADER, $request_headers);
+
+ // encoding support
+ if(isset($headers['Accept-Encoding']))
+ {
+ curl_setopt($this->curl, CURLOPT_ENCODING, $headers['Accept-Encoding']);
+ }
+
+ // timeout support
+ if(isset($this->options['Timeout']))
+ {
+ curl_setopt($this->curl, CURLOPT_TIMEOUT, $this->options['Timeout']);
+ }
+
+ if (!empty($parameters))
+ {
+ if (!is_array($parameters))
+ {
+ curl_setopt($this->curl, CURLOPT_POSTFIELDS, $parameters);
+ }
+ else
+ {
+ // multipart posts (file upload support)
+ $has_files = false;
+ foreach ($parameters as $name => $value)
+ {
+ if (is_array($value)) {
+ continue;
+ }
+ if (is_file($value))
+ {
+ $has_files = true;
+ $parameters[$name] = '@'.realpath($value);
+ }
+ }
+ if($has_files)
+ {
+ curl_setopt($this->curl, CURLOPT_POSTFIELDS, $parameters);
+ }
+ else
+ {
+ curl_setopt($this->curl, CURLOPT_POSTFIELDS, http_build_query($parameters, '', '&'));
+ }
+ }
+ }
+
+ // handle any request method
+ curl_setopt($this->curl, CURLOPT_CUSTOMREQUEST, $method);
+
+ $response = curl_exec($this->curl);
+
+ if (curl_errno($this->curl))
+ {
+ throw new Exception(curl_error($this->curl));
+ }
+
+ $requestInfo = curl_getinfo($this->curl);
+
+ $browser->setResponseCode($requestInfo['http_code']);
+ $browser->setResponseHeaders($this->headers);
+ $browser->setResponseText($response);
+
+ // clear response headers
+ $this->headers = array();
+
+ return $browser;
+ }
+
+ public function __destruct()
+ {
+ curl_close($this->curl);
+ }
+
+ protected function read_header($curl, $headers)
+ {
+ $this->headers[] = $headers;
+
+ return strlen($headers);
+ }
+}
diff --git a/lib/.svn/text-base/sfFopenAdapter.class.php.svn-base b/lib/.svn/text-base/sfFopenAdapter.class.php.svn-base
new file mode 100644
index 0000000..3c63c00
--- /dev/null
+++ b/lib/.svn/text-base/sfFopenAdapter.class.php.svn-base
@@ -0,0 +1,123 @@
+<?php
+
+/*
+ * This file is part of the sfWebBrowserPlugin package.
+ * (c) 2004-2006 Francois Zaninotto <[email protected]>
+ * (c) 2004-2006 Fabien Potencier <[email protected]> for the click-related functions
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * sfWebBrowser provides a basic HTTP client.
+ *
+ * @package sfWebBrowserPlugin
+ * @author Francois Zaninotto <[email protected]>
+ * @version 0.9
+ */
+class sfFopenAdapter
+{
+ protected
+ $options = array(),
+ $adapterErrorMessage = null,
+ $browser = null;
+
+ public function __construct($options = array())
+ {
+ $this->options = $options;
+ }
+
+ /**
+ * Submits a request
+ *
+ * @param string The request uri
+ * @param string The request method
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ * @param boolean To specify is the request changes the browser history
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function call($browser, $uri, $method = 'GET', $parameters = array(), $headers = array())
+ {
+ $m_headers = array_merge(array('Content-Type' => 'application/x-www-form-urlencoded'), $browser->getDefaultRequestHeaders(), $browser->initializeRequestHeaders($headers));
+ $request_headers = $browser->prepareHeaders($m_headers);
+
+ // Read the response from the server
+ // FIXME: use sockets to avoid depending on allow_url_fopen
+ $context = stream_context_create(array('http' => array_merge(
+ $this->options,
+ array('method' => $method),
+ array('content' => is_array($parameters) ? http_build_query($parameters) : $parameters),
+ array('header' => $request_headers)
+ )));
+
+ // Custom error handler
+ // -- browser instance must be accessible from handleRuntimeError()
+ $this->browser = $browser;
+ set_error_handler(array($this, 'handleRuntimeError'), E_WARNING);
+ if($handle = fopen($uri, 'r', false, $context))
+ {
+ $response_headers = stream_get_meta_data($handle);
+ $browser->setResponseCode(array_shift($response_headers['wrapper_data']));
+ $browser->setResponseHeaders($response_headers['wrapper_data']);
+ $browser->setResponseText(stream_get_contents($handle));
+ fclose($handle);
+ }
+
+ restore_error_handler();
+
+ if ($this->adapterErrorMessage == true)
+ {
+ $msg = $this->adapterErrorMessage;
+ $this->adapterErrorMessage = null;
+ throw new Exception($msg);
+ }
+
+ return $browser;
+ }
+
+ /**
+ * Handles PHP runtime error.
+ *
+ * This handler is used to catch any warnigns sent by fopen($url) and reformat them to something
+ * usable.
+ *
+ * @see http://php.net/set_error_handler
+ */
+ function handleRuntimeError($errno, $errstr, $errfile = null, $errline = null, $errcontext = array() )
+ {
+ $error_types = array (
+ E_ERROR => 'Error',
+ E_WARNING => 'Warning',
+ E_PARSE => 'Parsing Error',
+ E_NOTICE => 'Notice',
+ E_CORE_ERROR => 'Core Error',
+ E_CORE_WARNING => 'Core Warning',
+ E_COMPILE_ERROR => 'Compile Error',
+ E_COMPILE_WARNING => 'Compile Warning',
+ E_USER_ERROR => 'User Error',
+ E_USER_WARNING => 'User Warning',
+ E_USER_NOTICE => 'User Notice',
+ E_STRICT => 'Runtime Notice',
+ E_RECOVERABLE_ERROR => 'Catchable Fatal Error'
+ );
+
+ $msg = sprintf('%s : "%s" occured in %s on line %d',
+ $error_types[$errno], $errstr, $errfile, $errline);
+
+ $matches = array();
+ if (preg_match('/HTTP\/\d\.\d (\d{3}) (.*)$/', $errstr, $matches))
+ {
+ $this->browser->setResponseCode($matches[1]);
+ $this->browser->setResponseMessage($matches[2]);
+ $body = sprintf('The %s adapter cannot handle error responses body. Try using another adapter.', __CLASS__);
+ $this->browser->setResponseText($body);
+ }
+ else
+ {
+ $this->adapterErrorMessage = $msg;
+ }
+ }
+}
diff --git a/lib/.svn/text-base/sfSocketsAdapter.class.php.svn-base b/lib/.svn/text-base/sfSocketsAdapter.class.php.svn-base
new file mode 100644
index 0000000..b2539e1
--- /dev/null
+++ b/lib/.svn/text-base/sfSocketsAdapter.class.php.svn-base
@@ -0,0 +1,152 @@
+<?php
+
+/*
+ * This file is part of the sfWebBrowserPlugin package.
+ * (c) 2004-2006 Francois Zaninotto <[email protected]>
+ * (c) 2004-2006 Fabien Potencier <[email protected]> for the click-related functions
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * sfWebBrowser provides a basic HTTP client.
+ *
+ * @package sfWebBrowserPlugin
+ * @author Francois Zaninotto <[email protected]>
+ * @author Benjamin Meynell <[email protected]>
+ * @version 0.9
+ */
+class sfSocketsAdapter
+{
+ protected
+ $options = array(),
+ $adapterErrorMessage = null,
+ $browser = null;
+
+ public function __construct($options = array())
+ {
+ $this->options = $options;
+ }
+
+ /**
+ * Submits a request
+ *
+ * @param string The request uri
+ * @param string The request method
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function call($browser, $uri, $method = 'GET', $parameters = array(), $headers = array())
+ {
+ $m_headers = array_merge(array('Content-Type' => 'application/x-www-form-urlencoded'), $browser->getDefaultRequestHeaders(), $browser->initializeRequestHeaders($headers));
+ $request_headers = $browser->prepareHeaders($m_headers);
+
+ $url_info = parse_url($uri);
+
+ // initialize default values
+ isset($url_info['path']) ? $path = $url_info['path'] : $path = '/';
+ isset($url_info['query']) ? $qstring = '?'.$url_info['query'] : $qstring = null;
+ isset($url_info['port']) ? null : $url_info['port'] = 80;
+
+ if (!$socket = @fsockopen($url_info['host'], $url_info['port'], $errno, $errstr, 15))
+ {
+ throw new Exception("Could not connect ($errno): $errstr");
+ }
+
+ // build request
+ $request = "$method $path$qstring HTTP/1.1\r\n";
+ $request .= 'Host: '.$url_info['host'].':'.$url_info['port']."\r\n";
+ $request .= $request_headers;
+ $request .= "Connection: Close\r\n";
+
+ if ($method == 'PUT' && is_array($parameters) && array_key_exists('file', $parameters))
+ {
+ $fp = fopen($parameters['file'], 'rb');
+ $sent = 0;
+ $blocksize = (2 << 20); // 2MB chunks
+ $filesize = filesize($parameters['file']);
+
+ $request .= 'Content-Length: '.$filesize."\r\n";
+
+ $request .= "\r\n";
+
+ fwrite($socket, $request);
+
+ while ($sent < $filesize)
+ {
+ $data = fread($fp, $blocksize);
+ fwrite($socket, $data);
+ $sent += $blocksize;
+ }
+ fclose($fp);
+ }
+ elseif ($method == 'POST' || $method == 'PUT')
+ {
+ $body = is_array($parameters) ? http_build_query($parameters, '', '&') : $parameters;
+ $request .= 'Content-Length: '.strlen($body)."\r\n";
+ $request .= "\r\n";
+ $request .= $body;
+ }
+
+ $request .= "\r\n";
+
+ fwrite($socket, $request);
+
+ $response = '';
+ $response_body = '';
+ while (!feof($socket))
+ {
+ $response .= fgets($socket, 1024);
+ }
+ fclose($socket);
+
+ // parse response components: status line, headers and body
+ $response_lines = explode("\r\n", $response);
+
+ // http status line (ie "HTTP 1.1 200 OK")
+ $status_line = array_shift($response_lines);
+
+ $start_body = false;
+ $response_headers = array();
+ for($i=0; $i<count($response_lines); $i++)
+ {
+ // grab body
+ if ($start_body == true)
+ {
+ // ignore chunked encoding size
+ if (!preg_match('@^[0-9A-Fa-f]+\s*$@', $response_lines[$i]))
+ {
+ $response_body .= $response_lines[$i];
+ }
+ }
+
+ // body starts after first blank line
+ else if ($start_body == false && $response_lines[$i] == '')
+ {
+ $start_body = true;
+ }
+
+ // grab headers
+ else
+ {
+ $response_headers[] = $response_lines[$i];
+ }
+ }
+
+ $browser->setResponseHeaders($response_headers);
+
+ // grab status code
+ preg_match('@(\d{3})@', $status_line, $status_code);
+ if(isset($status_code[1]))
+ {
+ $browser->setResponseCode($status_code[1]);
+ }
+ $browser->setResponseText(trim($response_body));
+
+ return $browser;
+ }
+
+}
diff --git a/lib/.svn/text-base/sfWebBrowser.class.php.svn-base b/lib/.svn/text-base/sfWebBrowser.class.php.svn-base
new file mode 100644
index 0000000..90f9024
--- /dev/null
+++ b/lib/.svn/text-base/sfWebBrowser.class.php.svn-base
@@ -0,0 +1,851 @@
+<?php
+
+/*
+ * This file is part of the sfWebBrowserPlugin package.
+ * (c) 2004-2006 Francois Zaninotto <[email protected]>
+ * (c) 2004-2006 Fabien Potencier <[email protected]> for the click-related functions
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * sfWebBrowser provides a basic HTTP client.
+ *
+ * @package sfWebBrowserPlugin
+ * @author Francois Zaninotto <[email protected]>
+ * @author Tristan Rivoallan <[email protected]>
+ * @version 0.9
+ */
+class sfWebBrowser
+{
+ protected
+ $defaultHeaders = array(),
+ $stack = array(),
+ $stackPosition = -1,
+ $responseHeaders = array(),
+ $responseCode = '',
+ $responseMessage = '',
+ $responseText = '',
+ $responseDom = null,
+ $responseDomCssSelector = null,
+ $responseXml = null,
+ $fields = array(),
+ $urlInfo = array();
+
+ public function __construct($defaultHeaders = array(), $adapterClass = null, $adapterOptions = array())
+ {
+ if(!$adapterClass)
+ {
+ if (function_exists('curl_init'))
+ {
+ $adapterClass = 'sfCurlAdapter';
+ }
+ else if(ini_get('allow_url_fopen') == 1)
+ {
+ $adapterClass = 'sfFopenAdapter';
+ }
+ else
+ {
+ $adapterClass = 'sfSocketsAdapter';
+ }
+ }
+ $this->defaultHeaders = $this->fixHeaders($defaultHeaders);
+ $this->adapter = new $adapterClass($adapterOptions);
+ }
+
+ // Browser methods
+
+ /**
+ * Restarts the browser
+ *
+ * @param array default browser options
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function restart($defaultHeaders = array())
+ {
+ $this->defaultHeaders = $this->fixHeaders($defaultHeaders);
+ $this->stack = array();
+ $this->stackPosition = -1;
+ $this->urlInfo = array();
+ $this->initializeResponse();
+
+ return $this;
+ }
+
+ /**
+ * Sets the browser user agent name
+ *
+ * @param string agent name
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function setUserAgent($agent)
+ {
+ $this->defaultHeaders['User-Agent'] = $agent;
+
+ return $this;
+ }
+
+ /**
+ * Gets the browser user agent name
+ *
+ * @return string agent name
+ */
+ public function getUserAgent()
+ {
+ return isset($this->defaultHeaders['User-Agent']) ? $this->defaultHeaders['User-Agent'] : '';
+ }
+
+ /**
+ * Submits a GET request
+ *
+ * @param string The request uri
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function get($uri, $parameters = array(), $headers = array())
+ {
+ if ($parameters)
+ {
+ $uri .= ((false !== strpos($uri, '?')) ? '&' : '?') . http_build_query($parameters, '', '&');
+ }
+ return $this->call($uri, 'GET', array(), $headers);
+ }
+
+ public function head($uri, $parameters = array(), $headers = array())
+ {
+ if ($parameters)
+ {
+ $uri .= ((false !== strpos($uri, '?')) ? '&' : '?') . http_build_query($parameters, '', '&');
+ }
+ return $this->call($uri, 'HEAD', array(), $headers);
+ }
+
+ /**
+ * Submits a POST request
+ *
+ * @param string The request uri
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function post($uri, $parameters = array(), $headers = array())
+ {
+ return $this->call($uri, 'POST', $parameters, $headers);
+ }
+
+ /**
+ * Submits a PUT request.
+ *
+ * @param string The request uri
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function put($uri, $parameters = array(), $headers = array())
+ {
+ return $this->call($uri, 'PUT', $parameters, $headers);
+ }
+
+ /**
+ * Submits a DELETE request.
+ *
+ * @param string The request uri
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function delete($uri, $parameters = array(), $headers = array())
+ {
+ return $this->call($uri, 'DELETE', $parameters, $headers);
+ }
+
+ /**
+ * Submits a request
+ *
+ * @param string The request uri
+ * @param string The request method
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ * @param boolean To specify is the request changes the browser history
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function call($uri, $method = 'GET', $parameters = array(), $headers = array(), $changeStack = true)
+ {
+ $urlInfo = parse_url($uri);
+
+ // Check headers
+ $headers = $this->fixHeaders($headers);
+
+ // check port
+ if (isset($urlInfo['port']))
+ {
+ $this->urlInfo['port'] = $urlInfo['port'];
+ }
+ else if (!isset($this->urlInfo['port']))
+ {
+ $this->urlInfo['port'] = 80;
+ }
+
+ if(!isset($urlInfo['host']))
+ {
+ // relative link
+ $uri = $this->urlInfo['scheme'].'://'.$this->urlInfo['host'].':'.$this->urlInfo['port'].'/'.$uri;
+ }
+ else if($urlInfo['scheme'] != 'http' && $urlInfo['scheme'] != 'https')
+ {
+ throw new Exception('sfWebBrowser handles only http and https requests');
+ }
+
+ $this->urlInfo = parse_url($uri);
+
+ $this->initializeResponse();
+
+ if ($changeStack)
+ {
+ $this->addToStack($uri, $method, $parameters, $headers);
+ }
+
+ $browser = $this->adapter->call($this, $uri, $method, $parameters, $headers);
+
+ // redirect support
+ if ((in_array($browser->getResponseCode(), array(301, 307)) && in_array($method, array('GET', 'HEAD'))) || in_array($browser->getResponseCode(), array(302,303)))
+ {
+ $this->call($browser->getResponseHeader('Location'), 'GET', array(), $headers);
+ }
+
+ return $browser;
+ }
+
+ /**
+ * Gives a value to a form field in the response
+ *
+ * @param string field name
+ * @param string field value
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function setField($name, $value)
+ {
+ // as we don't know yet the form, just store name/value pairs
+ $this->parseArgumentAsArray($name, $value, $this->fields);
+
+ return $this;
+ }
+
+ /**
+ * Looks for a link or a button in the response and submits the related request
+ *
+ * @param string The link/button value/href/alt
+ * @param array request parameters (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function click($name, $arguments = array())
+ {
+ if (!$dom = $this->getResponseDom())
+ {
+ throw new Exception('Cannot click because there is no current page in the browser');
+ }
+
+ $xpath = new DomXpath($dom);
+
+ // text link, the name being in an attribute
+ if ($link = $xpath->query(sprintf('//a[@*="%s"]', $name))->item(0))
+ {
+ return $this->get($link->getAttribute('href'));
+ }
+
+ // text link, the name being the text value
+ if ($links = $xpath->query('//a[@href]'))
+ {
+ foreach($links as $link)
+ {
+ if(preg_replace(array('/\s{2,}/', '/\\r\\n|\\n|\\r/'), array(' ', ''), $link->nodeValue) == $name)
+ {
+ return $this->get($link->getAttribute('href'));
+ }
+ }
+ }
+
+ // image link, the name being the alt attribute value
+ if ($link = $xpath->query(sprintf('//a/img[@alt="%s"]/ancestor::a', $name))->item(0))
+ {
+ return $this->get($link->getAttribute('href'));
+ }
+
+ // form, the name being the button or input value
+ if (!$form = $xpath->query(sprintf('//input[((@type="submit" or @type="button") and @value="%s") or (@type="image" and @alt="%s")]/ancestor::form', $name, $name))->item(0))
+ {
+ throw new Exception(sprintf('Cannot find the "%s" link or button.', $name));
+ }
+
+ // form attributes
+ $url = $form->getAttribute('action');
+ $method = $form->getAttribute('method') ? strtolower($form->getAttribute('method')) : 'get';
+
+ // merge form default values and arguments
+ $defaults = array();
+ foreach ($xpath->query('descendant::input | descendant::textarea | descendant::select', $form) as $element)
+ {
+ $elementName = $element->getAttribute('name');
+ $nodeName = $element->nodeName;
+ $value = null;
+ if ($nodeName == 'input' && ($element->getAttribute('type') == 'checkbox' || $element->getAttribute('type') == 'radio'))
+ {
+ if ($element->getAttribute('checked'))
+ {
+ $value = $element->getAttribute('value');
+ }
+ }
+ else if (
+ $nodeName == 'input'
+ &&
+ (($element->getAttribute('type') != 'submit' && $element->getAttribute('type') != 'button') || $element->getAttribute('value') == $name)
+ &&
+ ($element->getAttribute('type') != 'image' || $element->getAttribute('alt') == $name)
+ )
+ {
+ $value = $element->getAttribute('value');
+ }
+ else if ($nodeName == 'textarea')
+ {
+ $value = '';
+ foreach ($element->childNodes as $el)
+ {
+ $value .= $dom->saveXML($el);
+ }
+ }
+ else if ($nodeName == 'select')
+ {
+ if ($multiple = $element->hasAttribute('multiple'))
+ {
+ $elementName = str_replace('[]', '', $elementName);
+ $value = array();
+ }
+ else
+ {
+ $value = null;
+ }
+
+ $found = false;
+ foreach ($xpath->query('descendant::option', $element) as $option)
+ {
+ if ($option->getAttribute('selected'))
+ {
+ $found = true;
+ if ($multiple)
+ {
+ $value[] = $option->getAttribute('value');
+ }
+ else
+ {
+ $value = $option->getAttribute('value');
+ }
+ }
+ }
+
+ // if no option is selected and if it is a simple select box, take the first option as the value
+ if (!$found && !$multiple)
+ {
+ $value = $xpath->query('descendant::option', $element)->item(0)->getAttribute('value');
+ }
+ }
+
+ if (null !== $value)
+ {
+ $this->parseArgumentAsArray($elementName, $value, $defaults);
+ }
+ }
+
+ // create request parameters
+ $arguments = sfToolkit::arrayDeepMerge($defaults, $this->fields, $arguments);
+ if ('post' == $method)
+ {
+ return $this->post($url, $arguments);
+ }
+ else
+ {
+ return $this->get($url, $arguments);
+ }
+ }
+
+ protected function parseArgumentAsArray($name, $value, &$vars)
+ {
+ if (false !== $pos = strpos($name, '['))
+ {
+ $var = &$vars;
+ $tmps = array_filter(preg_split('/(\[ | \[\] | \])/x', $name));
+ foreach ($tmps as $tmp)
+ {
+ $var = &$var[$tmp];
+ }
+ if ($var)
+ {
+ if (!is_array($var))
+ {
+ $var = array($var);
+ }
+ $var[] = $value;
+ }
+ else
+ {
+ $var = $value;
+ }
+ }
+ else
+ {
+ $vars[$name] = $value;
+ }
+ }
+
+ /**
+ * Adds the current request to the history stack
+ *
+ * @param string The request uri
+ * @param string The request method
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function addToStack($uri, $method, $parameters, $headers)
+ {
+ $this->stack = array_slice($this->stack, 0, $this->stackPosition + 1);
+ $this->stack[] = array(
+ 'uri' => $uri,
+ 'method' => $method,
+ 'parameters' => $parameters,
+ 'headers' => $headers
+ );
+ $this->stackPosition = count($this->stack) - 1;
+
+ return $this;
+ }
+
+ /**
+ * Submits the previous request in history again
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function back()
+ {
+ if ($this->stackPosition < 1)
+ {
+ throw new Exception('You are already on the first page.');
+ }
+
+ --$this->stackPosition;
+ return $this->call($this->stack[$this->stackPosition]['uri'],
+ $this->stack[$this->stackPosition]['method'],
+ $this->stack[$this->stackPosition]['parameters'],
+ $this->stack[$this->stackPosition]['headers'],
+ false);
+ }
+
+ /**
+ * Submits the next request in history again
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function forward()
+ {
+ if ($this->stackPosition > count($this->stack) - 2)
+ {
+ throw new Exception('You are already on the last page.');
+ }
+
+ ++$this->stackPosition;
+ return $this->call($this->stack[$this->stackPosition]['uri'],
+ $this->stack[$this->stackPosition]['method'],
+ $this->stack[$this->stackPosition]['parameters'],
+ $this->stack[$this->stackPosition]['headers'],
+ false);
+ }
+
+ /**
+ * Submits the current request again
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function reload()
+ {
+ if (-1 == $this->stackPosition)
+ {
+ throw new Exception('No page to reload.');
+ }
+
+ return $this->call($this->stack[$this->stackPosition]['uri'],
+ $this->stack[$this->stackPosition]['method'],
+ $this->stack[$this->stackPosition]['parameters'],
+ $this->stack[$this->stackPosition]['headers'],
+ false);
+ }
+
+ /**
+ * Transforms an associative array of header names => header values to its HTTP equivalent.
+ *
+ * @param array $headers
+ * @return string
+ */
+ public function prepareHeaders($headers = array())
+ {
+ $prepared_headers = array();
+ foreach ($headers as $name => $value)
+ {
+ $prepared_headers[] = sprintf("%s: %s\r\n", ucfirst($name), $value);
+ }
+
+ return implode('', $prepared_headers);
+ }
+
+ // Response methods
+
+ /**
+ * Initializes the response and erases all content from prior requests
+ */
+ public function initializeResponse()
+ {
+ $this->responseHeaders = array();
+ $this->responseCode = '';
+ $this->responseText = '';
+ $this->responseDom = null;
+ $this->responseDomCssSelector = null;
+ $this->responseXml = null;
+ $this->fields = array();
+ }
+
+ /**
+ * Set the response headers
+ *
+ * @param array The response headers as an array of strings shaped like "key: value"
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function setResponseHeaders($headers = array())
+ {
+ $header_array = array();
+ foreach($headers as $header)
+ {
+ $arr = explode(': ', $header);
+ if(isset($arr[1]))
+ {
+ $header_array[$this->normalizeHeaderName($arr[0])] = trim($arr[1]);
+ }
+ }
+
+ $this->responseHeaders = $header_array;
+
+ return $this;
+ }
+
+ /**
+ * Set the response code
+ *
+ * @param string The first line of the response
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function setResponseCode($firstLine)
+ {
+ preg_match('/\d{3}/', $firstLine, $matches);
+ if(isset($matches[0]))
+ {
+ $this->responseCode = $matches[0];
+ }
+ else
+ {
+ $this->responseCode = '';
+ }
+
+ return $this;
+ }
+
+ /**
+ * Set the response contents
+ *
+ * @param string The response contents
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function setResponseText($res)
+ {
+ $this->responseText = $res;
+
+ return $this;
+ }
+
+ /**
+ * Get a text version of the response
+ *
+ * @return string The response contents
+ */
+ public function getResponseText()
+ {
+ $text = $this->responseText;
+
+ // Decode any content-encoding (gzip or deflate) if needed
+ switch (strtolower($this->getResponseHeader('content-encoding'))) {
+
+ // Handle gzip encoding
+ case 'gzip':
+ $text = $this->decodeGzip($text);
+ break;
+
+ // Handle deflate encoding
+ case 'deflate':
+ $text = $this->decodeDeflate($text);
+ break;
+
+ default:
+ break;
+ }
+
+ return $text;
+ }
+
+ /**
+ * Get a text version of the body part of the response (without <body> and </body>)
+ *
+ * @return string The body part of the response contents
+ */
+ public function getResponseBody()
+ {
+ preg_match('/<body.*?>(.*)<\/body>/si', $this->getResponseText(), $matches);
+
+ return isset($matches[1]) ? $matches[1] : '';
+ }
+
+ /**
+ * Get a DOMDocument version of the response
+ *
+ * @return DOMDocument The reponse contents
+ */
+ public function getResponseDom()
+ {
+ if(!$this->responseDom)
+ {
+ // for HTML/XML content, create a DOM object for the response content
+ if (preg_match('/(x|ht)ml/i', $this->getResponseHeader('Content-Type')))
+ {
+ $this->responseDom = new DomDocument('1.0', 'utf8');
+ $this->responseDom->validateOnParse = true;
+ @$this->responseDom->loadHTML($this->getResponseText());
+ }
+ }
+
+ return $this->responseDom;
+ }
+
+ /**
+ * Get a sfDomCssSelector version of the response
+ *
+ * @return sfDomCssSelector The response contents
+ */
+ public function getResponseDomCssSelector()
+ {
+ if(!$this->responseDomCssSelector)
+ {
+ // for HTML/XML content, create a DOM object for the response content
+ if (preg_match('/(x|ht)ml/i', $this->getResponseHeader('Content-Type')))
+ {
+ $this->responseDomCssSelector = new sfDomCssSelector($this->getResponseDom());
+ }
+ }
+
+ return $this->responseDomCssSelector;
+ }
+
+ /**
+ * Get a SimpleXML version of the response
+ *
+ * @return SimpleXMLElement The reponse contents
+ * @throws sfWebBrowserInvalidResponseException when response is not in a valid format
+ */
+ public function getResponseXML()
+ {
+ if(!$this->responseXml)
+ {
+ // for HTML/XML content, create a DOM object for the response content
+ if (preg_match('/(x|ht)ml/i', $this->getResponseHeader('Content-Type')))
+ {
+ $this->responseXml = @simplexml_load_string($this->getResponseText());
+ }
+ }
+
+ // Throw an exception if response is not valid XML
+ if (get_class($this->responseXml) != 'SimpleXMLElement')
+ {
+ $msg = sprintf("Response is not a valid XML string : \n%s", $this->getResponseText());
+ throw new sfWebBrowserInvalidResponseException($msg);
+ }
+
+ return $this->responseXml;
+ }
+
+ /**
+ * Returns true if server response is an error.
+ *
+ * @return bool
+ */
+ public function responseIsError()
+ {
+ return in_array((int)($this->getResponseCode() / 100), array(4, 5));
+ }
+
+ /**
+ * Get the response headers
+ *
+ * @return array The response headers
+ */
+ public function getResponseHeaders()
+ {
+ return $this->responseHeaders;
+ }
+
+ /**
+ * Get a response header
+ *
+ * @param string The response header name
+ *
+ * @return string The response header value
+ */
+ public function getResponseHeader($key)
+ {
+ $normalized_key = $this->normalizeHeaderName($key);
+ return (isset($this->responseHeaders[$normalized_key])) ? $this->responseHeaders[$normalized_key] : '';
+ }
+
+ /**
+ * Decodes gzip-encoded content ("content-encoding: gzip" response header).
+ *
+ * @param stream $gzip_text
+ * @return string
+ */
+ protected function decodeGzip($gzip_text)
+ {
+ return gzinflate(substr($gzip_text, 10));
+ }
+
+ /**
+ * Decodes deflate-encoded content ("content-encoding: deflate" response header).
+ *
+ * @param stream $deflate_text
+ * @return string
+ */
+ protected function decodeDeflate($deflate_text)
+ {
+ return gzuncompress($deflate_text);
+ }
+
+ /**
+ * Get the response code
+ *
+ * @return string The response code
+ */
+ public function getResponseCode()
+ {
+ return $this->responseCode;
+ }
+
+ /**
+ * Returns the response message (the 'Not Found' part in 'HTTP/1.1 404 Not Found')
+ *
+ * @return string
+ */
+ public function getResponseMessage()
+ {
+ return $this->responseMessage;
+ }
+
+ /**
+ * Sets response message.
+ *
+ * @param string $message
+ */
+ public function setResponseMessage($msg)
+ {
+ $this->responseMessage = $msg;
+ }
+
+ public function getUrlInfo()
+ {
+ return $this->urlInfo;
+ }
+
+ public function getDefaultRequestHeaders()
+ {
+ return $this->defaultHeaders;
+ }
+
+ /**
+ * Adds default headers to the supplied headers array.
+ *
+ * @param array $headers
+ * @return array
+ */
+ public function initializeRequestHeaders($headers = array())
+ {
+ // Supported encodings
+ $encodings = array();
+ if (isset($headers['Accept-Encoding']))
+ {
+ $encodings = explode(',', $headers['Accept-Encoding']);
+ }
+ if (function_exists('gzinflate') && !in_array('gzip', $encodings))
+ {
+ $encodings[] = 'gzip';
+ }
+ if (function_exists('gzuncompress') && !in_array('deflate', $encodings))
+ {
+ $encodings[] = 'deflate';
+ }
+
+ $headers['Accept-Encoding'] = implode(',', array_unique($encodings));
+
+ return $headers;
+ }
+
+ /**
+ * Validates supplied headers and turns all names to lowercase.
+ *
+ * @param array $headers
+ * @return array
+ */
+ private function fixHeaders($headers)
+ {
+ $fixed_headers = array();
+ foreach ($headers as $name => $value)
+ {
+ if (!preg_match('/([a-z]*)(-[a-z]*)*/i', $name))
+ {
+ $msg = sprintf('Invalid header "%s"', $name);
+ throw new Exception($msg);
+ }
+ $fixed_headers[$this->normalizeHeaderName($name)] = trim($value);
+ }
+
+ return $fixed_headers;
+ }
+
+ /**
+ * Retrieves a normalized Header.
+ *
+ * @param string Header name
+ *
+ * @return string Normalized header
+ */
+ protected function normalizeHeaderName($name)
+ {
+ return preg_replace('/\-(.)/e', "'-'.strtoupper('\\1')", strtr(ucfirst($name), '_', '-'));
+ }
+
+}
diff --git a/lib/.svn/text-base/sfWebBrowserInvalidResponseException.class.php.svn-base b/lib/.svn/text-base/sfWebBrowserInvalidResponseException.class.php.svn-base
new file mode 100644
index 0000000..c26d1bd
--- /dev/null
+++ b/lib/.svn/text-base/sfWebBrowserInvalidResponseException.class.php.svn-base
@@ -0,0 +1,25 @@
+<?php
+
+/**
+ * This exception is thrown when response sent to browser is not in a valid format.
+ *
+ * @package sfWebBrowserPlugin
+ * @author Tristan Rivoallan <[email protected]>
+ */
+class sfWebBrowserInvalidResponseException extends sfException
+{
+ /**
+ * Class constructor.
+ *
+ * @param string The error message
+ * @param int The error code
+ */
+ public function __construct($message = null, $code = 0)
+ {
+ if(method_exists($this, 'setName'))
+ {
+ $this->setName('sfWebBrowserInvalidResponseException');
+ }
+ parent::__construct($message, $code);
+ }
+}
diff --git a/test/.svn/all-wcprops b/test/.svn/all-wcprops
new file mode 100644
index 0000000..4e5cd8f
--- /dev/null
+++ b/test/.svn/all-wcprops
@@ -0,0 +1,5 @@
+K 25
+svn:wc:ra_dav:version-url
+V 53
+/!svn/ver/18167/plugins/sfWebBrowserPlugin/trunk/test
+END
diff --git a/test/.svn/dir-prop-base b/test/.svn/dir-prop-base
new file mode 100644
index 0000000..3160658
--- /dev/null
+++ b/test/.svn/dir-prop-base
@@ -0,0 +1,5 @@
+K 13
+svn:mergeinfo
+V 0
+
+END
diff --git a/test/.svn/entries b/test/.svn/entries
new file mode 100644
index 0000000..3f61600
--- /dev/null
+++ b/test/.svn/entries
@@ -0,0 +1,34 @@
+10
+
+dir
+27927
+http://svn.symfony-project.com/plugins/sfWebBrowserPlugin/trunk/test
+http://svn.symfony-project.com
+
+
+
+2009-05-12T13:43:50.573589Z
+18167
+francois
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+ee427ae8-e902-0410-961c-c3ed070cd9f9
+
+unit
+dir
+
+utils
+dir
+
diff --git a/test/unit/.svn/all-wcprops b/test/unit/.svn/all-wcprops
new file mode 100644
index 0000000..ec1f908
--- /dev/null
+++ b/test/unit/.svn/all-wcprops
@@ -0,0 +1,11 @@
+K 25
+svn:wc:ra_dav:version-url
+V 58
+/!svn/ver/18167/plugins/sfWebBrowserPlugin/trunk/test/unit
+END
+sfWebBrowserTest.php
+K 25
+svn:wc:ra_dav:version-url
+V 79
+/!svn/ver/18167/plugins/sfWebBrowserPlugin/trunk/test/unit/sfWebBrowserTest.php
+END
diff --git a/test/unit/.svn/entries b/test/unit/.svn/entries
new file mode 100644
index 0000000..3fbb3d2
--- /dev/null
+++ b/test/unit/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+27927
+http://svn.symfony-project.com/plugins/sfWebBrowserPlugin/trunk/test/unit
+http://svn.symfony-project.com
+
+
+
+2009-05-12T13:43:50.573589Z
+18167
+francois
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ee427ae8-e902-0410-961c-c3ed070cd9f9
+
+sfWebBrowserTest.php
+file
+
+
+
+
+2010-02-09T21:41:24.000000Z
+5122f831eb71d328abb63bf6dd585a34
+2009-05-12T13:43:50.573589Z
+18167
+francois
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+20403
+
diff --git a/test/unit/.svn/text-base/sfWebBrowserTest.php.svn-base b/test/unit/.svn/text-base/sfWebBrowserTest.php.svn-base
new file mode 100644
index 0000000..f7b7a05
--- /dev/null
+++ b/test/unit/.svn/text-base/sfWebBrowserTest.php.svn-base
@@ -0,0 +1,485 @@
+<?php
+
+include(dirname(__FILE__).'/../../../../test/bootstrap/unit.php');
+if(!isset($sf_symfony_lib_dir))
+{
+ $sf_symfony_lib_dir = $configuration->getSymfonyLibDir();
+}
+require_once(dirname(__FILE__).'/../../lib/sfWebBrowser.class.php');
+require_once(dirname(__FILE__).'/../../lib/sfFopenAdapter.class.php');
+require_once(dirname(__FILE__).'/../../lib/sfCurlAdapter.class.php');
+require_once(dirname(__FILE__).'/../../lib/sfSocketsAdapter.class.php');
+require_once($sf_symfony_lib_dir.'/exception/sfException.class.php');
+require_once(dirname(__FILE__).'/../../lib/sfWebBrowserInvalidResponseException.class.php');
+require_once($sf_symfony_lib_dir.'/config/sfConfig.class.php');
+require_once($sf_symfony_lib_dir.'/util/sfDomCssSelector.class.php');
+require_once($sf_symfony_lib_dir.'/util/sfToolkit.class.php');
+
+// Configuration
+// -- this script is needed for some tests. It is located in plugin's test/unit/utils folder
+$dump_headers_url = 'http://localhost/dumpheaders.php';
+
+// tests
+$nb_test_orig = 73;
+$adapter_list = array('sfCurlAdapter', 'sfFopenAdapter', 'sfSocketsAdapter');
+
+// -- sites used for testing requests
+$example_site_url = 'http://www.google.com';
+$askeet_params = array(
+ 'url' => 'http://www.askeet.com',
+ 'login' => 'francois',
+ 'password' => 'llactnevda2',
+);
+
+// -- cookies, file and directory automatically created
+$cookies_dir = dirname(__FILE__).'/../data/sfCurlAdapter';
+$cookies_file = $cookies_dir.'/cookies.txt';
+
+/**
+ * stub class
+ *
+ **/
+class myTestWebBrowser extends sfWebBrowser
+{
+ protected $requestMethod;
+ public function call($uri, $method = 'GET', $parameters = array(), $headers = array(), $changeStack = true)
+ {
+ parent::call($uri, $method, $parameters, $headers, $changeStack);
+ $this->requestMethod = $this->stack[$this->stackPosition]['method'];
+ }
+ public function getRequestMethod()
+ {
+ return $this->requestMethod;
+ }
+}
+
+$t = new lime_test($nb_test_orig * count($adapter_list), new lime_output_color());
+foreach($adapter_list as $adapter)
+{
+ $t->diag('Testing '.$adapter);
+ $t->diag('');
+
+ /******************/
+ /* Initialization */
+ /******************/
+
+ $t->diag('Initialization');
+ $b = new sfWebBrowser(array(), $adapter);
+
+ $t->is($b->getUserAgent(), '', 'a new browser has an empty user agent');
+ $t->is($b->getResponseText(), '', 'a new browser has an empty response');
+ $t->is($b->getResponseCode(), '', 'a new browser has an empty response code');
+ $t->is($b->getResponseHeaders(), array(), 'a new browser has empty reponse headers');
+
+ /*******************/
+ /* Utility methods */
+ /*******************/
+
+ $t->diag('Utility methods');
+ $b = new sfWebBrowser(array(), $adapter);
+ $t->is($b->setUserAgent('foo bar')->getUserAgent(), 'foo bar', 'setUserAgent() sets the user agent');
+ $t->is($b->setResponseText('foo bar')->getResponseText(), 'foo bar', 'setResponseText() extracts the response');
+ $t->is($b->setResponseCode('foo 123 bar')->getResponseCode(), '123', 'setResponseCode() extracts the three-digits code');
+ $t->is($b->setResponseCode('foo 12 bar')->getResponseCode(), '', 'setResponseCode() fails silently when response status is incorrect');
+ $t->is_deeply($b->setResponseHeaders(array('HTTP1.1 200 OK', 'foo: bar', 'bar: baz'))->getResponseHeaders(), array('Foo' => 'bar', 'Bar' => 'baz'), 'setResponseHeaders() extracts the headers array');
+ $t->is_deeply($b->setResponseHeaders(array('ETag: "535a8-9fb-44ff4a13"', 'WWW-Authenticate: Basic realm="Myself"'))->getResponseHeaders(), array('ETag' => '"535a8-9fb-44ff4a13"', 'WWW-Authenticate' => 'Basic realm="Myself"'), 'setResponseHeaders() extracts the headers array and accepts response headers with several uppercase characters');
+ $t->is_deeply($b->setResponseHeaders(array('HTTP1.1 200 OK', 'foo: bar', 'bar:baz', 'baz:bar'))->getResponseHeaders(), array('Foo' => 'bar'), 'setResponseHeaders() ignores malformed headers');
+
+ /**************/
+ /* Exceptions */
+ /**************/
+
+ $t->diag('Exceptions');
+ $b = new sfWebBrowser(array(), $adapter);
+ try
+ {
+ $b->get('htp://askeet');
+ $t->fail('get() throws an exception when passed an uri which is neither http nor https');
+ }
+ catch (Exception $e)
+ {
+ $t->pass('get() throws an exception when passed an uri which is neither http nor https');
+ }
+
+ /**********************/
+ /* Simple GET request */
+ /**********************/
+
+ $t->diag('Simple GET request');
+ $t->like($b->get($dump_headers_url)->getResponseText(), '/\[REQUEST_METHOD\] => GET/', 'get() performs a GET request');
+ $t->isa_ok($b, 'sfWebBrowser', 'get() make a web request and returns a browser object');
+ $t->is($b->getResponseCode(), 200, 'get() fills up the browser status code with the response');
+ $t->like($b->get($example_site_url)->getResponseHeader('Content-Type'), '/text\/html/', 'get() populates the header array');
+ $t->like(strtolower($b->getResponseText()), '/<head>/', 'get() populates the HTML of the response');
+
+ /***********************/
+ /* Simple HEAD request */
+ /***********************/
+
+ $t->diag('Simple HEAD request');
+ $t->like($b->head($dump_headers_url)->getResponseHeader('Content-Type'), '/text\/html/', 'head() populates the header array');
+ $t->is($b->getResponseText(), '', 'HEAD requests do not return a response body');
+
+ /***********************/
+ /* Simple POST request */
+ /***********************/
+
+ $t->diag('Simple POST request');
+ $t->like($b->post($dump_headers_url)->getResponseText(), '/\[REQUEST_METHOD\] => POST/', 'post() performs a POST request');
+ $t->like($b->post($dump_headers_url, array('post body'))->getResponseText(), '/post body/', 'post() sends body to server');
+
+ /**********************/
+ /* Simple PUT request */
+ /**********************/
+
+ $t->diag('Simple PUT request');
+ $t->like($b->put($dump_headers_url)->getResponseText(), '/\[REQUEST_METHOD\] => PUT/', 'put() performs a PUT request');
+ $t->like($b->put($dump_headers_url, array('PUT body'))->getResponseText(), '/PUT body/', 'put() sends body to server');
+
+ /*************************/
+ /* Simple DELETE request */
+ /*************************/
+
+ $t->diag('Simple DELETE request');
+ $t->like($b->delete($dump_headers_url)->getResponseText(), '/\[REQUEST_METHOD\] => DELETE/', 'delete() performs a DELETE request');
+
+ /*********************/
+ /* Arbitrary request */
+ /*********************/
+
+ $t->diag('Arbitrary request');
+ $t->like($b->call($dump_headers_url, 'MICHEL')->getResponseText(), '/\[REQUEST_METHOD\] => MICHEL/', 'call() supports any HTTP methods');
+
+ /****************************/
+ /* Response formats methods */
+ /****************************/
+
+ $t->diag('Response formats methods');
+ $b = new sfWebBrowser(array(), $adapter);
+ $b->get($example_site_url);
+ $t->like($b->getResponseText(), '/<body .*>/', 'getResponseText() returns the response text');
+ $t->unlike($b->getResponseBody(), '/<body>/', 'getResponseBody() returns the response body');
+ $t->isa_ok($b->getResponseDom(), 'DOMDocument', 'getResponseDom() returns the response Dom');
+ $t->isa_ok($b->getResponseDomCssSelector(), 'sfDomCssSelector', 'getResponseDomCssSelector() returns a CSS selector on the response Dom');
+ $b->get('http://rss.cnn.com/rss/cnn_topstories.rss');
+ $t->isa_ok($b->getResponseXml(), 'SimpleXMLElement', 'getResponseXml() returns the response as a SimpleXML Element');
+ $b->get('http://www.w3.org/StyleSheets/home.css');
+ try
+ {
+ $b->getResponseXml();
+ $t->fail('Incorrect XML throws an exception');
+ }
+ catch (Exception $e)
+ {
+ $t->pass('Incorrect XML throws an exception');
+ }
+
+ try
+ {
+ /******************************/
+ /* Absolute and relative URls */
+ /******************************/
+
+ $t->diag('Absolute and relative URls');
+ $b = new sfWebBrowser(array(), $adapter);
+ $t->like($b->get($askeet_params['url'])->getResponseText(), '/<h1>featured questions<\/h1>/', 'get() understands absolute urls');
+ $t->like($b->get($askeet_params['url'].'/index/1')->getResponseText(), '/<h1>popular questions<\/h1>/', 'get() understands absolute urls');
+ $t->like($b->get('/recent/1')->getResponseText(), '/<h1>recent questions<\/h1>/', 'get() understands relative urls with a trailing slash');
+ $t->like($b->get('/')->get('recent/1')->getResponseText(), '/<h1>recent questions<\/h1>/', 'get() understands relative urls without a trailing slash');
+
+ /***********************/
+ /* Interaction methods */
+ /***********************/
+
+ $t->diag('Interaction methods');
+ $b = new sfWebBrowser(array(), $adapter);
+ $t->like($b->get($askeet_params['url'])->click('activities')->getResponseText(), '/tag "activities"/', 'click() clicks on a link and executes the related request');
+ $t->like($b->get($askeet_params['url'])->click('/tag/activities')->getResponseText(), '/tag "activities"/', 'click() clicks on a link and executes the related request');
+ $t->like($b->click('askeet')->getResponseText(), '/<h1>featured questions<\/h1>/', 'click() clicks on an image if it finds the argument in the alt');
+ $t->like($b->click('search it', array('search' => 'foo'))->getResponseText(), '/<h1>questions matching "foo"<\/h1>/', 'click() clicks on a form input');
+ $t->like($b->setField('search', 'bar')->click('search it')->getResponseText(), '/<h1>questions matching "bar"<\/h1>/', 'setField() fills a form input');
+ }
+ catch (Exception $e)
+ {
+ $t->fail(sprintf('%s : skipping askeet related tests', $e->getMessage()));
+ }
+
+ /*******************************/
+ /* GET request with parameters */
+ /*******************************/
+
+ $t->diag('GET request with parameters');
+ $b = new sfWebBrowser(array(), $adapter);
+ $test_params = array('foo' => 'bar', 'baz' => '1');
+ $t->like($b->get($dump_headers_url, $test_params)->getResponseText(), '/\?foo=bar&baz=1/', 'get() can pass parameters with the second argument');
+ $t->like($b->get($dump_headers_url.'?'.http_build_query($test_params))->getResponseText(), '/\?foo=bar&baz=1/', 'get() can pass parameters concatenated to the URI as a query string');
+ $t->unlike($b->get($dump_headers_url.'?'.http_build_query($test_params))->getResponseText(), '/\?foo=bar&baz=1\&/', 'get() with an URL already containing request parameters doesn\'t add an extra &');
+ $t->like($b->get($dump_headers_url.'?'.http_build_query($test_params), array('biz' => 'bil'))->getResponseText(), '/\?foo=bar&baz=1&biz=bil/', 'get() can pass parameters concatenated to the URI as a query string and other parameters as a second argument');
+
+ $b = new sfWebBrowser(array(), $adapter);
+ $b->get($dump_headers_url);
+
+ /***************************/
+ /* Default request headers */
+ /***************************/
+
+ $t->diag('Default request headers');
+ $headers = array('Accept-language' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3');
+ $b = new sfWebBrowser($headers, $adapter);
+ $t->like(
+ $b->get($dump_headers_url)->getResponseText(),
+ "/fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3/",
+ 'sfWebBrowser constructor accepts default request headers as first parameter');
+ $headers = array('Accept-language' => 'en-gb;q=0.8,en-us;q=0.5,en;q=0.3');
+ $t->like(
+ $b->get($dump_headers_url, array(), $headers)->getResponseText(),
+ "/en-gb;q=0.8,en-us;q=0.5,en;q=0.3/",
+ 'Default request headers are overriden by request specific headers');
+
+ /***************************/
+ /* Request headers support */
+ /***************************/
+
+ $t->diag('Request headers support');
+ $b = new sfWebBrowser(array(), $adapter);
+ $headers = array(
+ 'Accept-language' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3',
+ 'Accept' => 'text/xml');
+ $t->like(
+ $b->get($dump_headers_url, array(), $headers)->getResponseText(),
+ "/fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3/",
+ 'get() can pass request headers with the third argument');
+ $t->like(
+ $b->post($dump_headers_url, array(), $headers)->getResponseText(),
+ "/fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3/",
+ 'post() can pass request headers with the third argument');
+ $msg = "get() can pass request headers not common that are defined uppercase in RFC 2616";
+ try
+ {
+ $t->like(
+ $b->get($dump_headers_url, array(), array('TE' => 'trailers, deflate;q=0.5'))->getResponseText(),
+ "/\[TE\] => trailers, deflate;q=0.5/",
+ $msg);
+ }
+ catch (Exception $e)
+ {
+ $t->fail($msg);
+ }
+
+ $msg = 'get() can pass request headers not common that are IE7 dependent: see http://www.w3.org/2006/http-header, now: ';
+ $field = '';
+ try
+ {
+ $headers = array('UA-CPU'=>'x86', 'UA-OS'=>'MacOS', 'UA-Color'=>'color16', 'UA-Pixels'=>'240x320');
+ $resp = $b->get($dump_headers_url, array(), $headers)->getResponseText();
+ foreach ($headers as $field => $value)
+ {
+ $t->like($resp, "/\[$field\] => $value/", $msg.$field);
+ }
+ }
+ catch (Exception $e)
+ {
+ $t->fail($msg.field.' - header refused');
+ }
+
+ /*********************************/
+ /* Encoded response body support */
+ /*********************************/
+
+ $t->diag('Encoded response body support');
+
+ $headers = array('Accept-Encoding' => 'gzip');
+ $t->like(
+ $b->get($dump_headers_url, array(), $headers)->getResponseText(),
+ "/gzip/",
+ 'getResponseText() can decode gzip encoded response body');
+ $headers = array('Accept-Encoding' => 'deflate');
+ $t->like(
+ $b->get($dump_headers_url, array(), $headers)->getResponseText(),
+ "/deflate/",
+ 'getResponseText() can decode deflate encoded response body');
+
+ $encodings = array();
+ if (function_exists('gzuncompress'))
+ {
+ $encodings[] = 'deflate';
+ }
+ if (function_exists('gzinflate'))
+ {
+ $encodings[] = 'gzip';
+ }
+ $target_headers = implode(',', $encodings);
+ $t->like(
+ $b->get($dump_headers_url, array(), $headers)->getResponseText(),
+ "/$target_headers/",
+ 'sfWebBrowser autosets accept-encoding headers depending on php capabilities');
+
+ $encodings = array();
+ if (function_exists('gzinflate'))
+ {
+ $encodings[] = 'gzip';
+ }
+ if (function_exists('gzuncompress'))
+ {
+ $encodings[] = 'deflate';
+ }
+ $headers = array('accept-encoding' => 'bzip2');
+ array_unshift($encodings, 'bzip2');
+ $target_headers = implode(',', $encodings);
+ $t->like(
+ $b->get($dump_headers_url, array(), $headers)->getResponseText(),
+ "/$target_headers/",
+ 'it is possible to set supplementary encodings');
+
+ /*******************/
+ /* History methods */
+ /*******************/
+
+ $t->diag('History methods');
+ $b = new sfWebBrowser(array(), $adapter);
+ $b->get($dump_headers_url);
+ $b->get($dump_headers_url.'?foo=bar');
+ $b->back();
+ $t->unlike($b->getResponseText(), '/foo=bar/', 'back() executes again the previous request in the history');
+ $b->forward();
+ $t->like($b->getResponseText(), '/foo=bar/', 'forward() executes again the next request in the history');
+ $b->reload();
+ $t->like($b->getResponseText(), '/foo=bar/', 'reload() executes again the current request in the history');
+
+ /********************/
+ /* Error management */
+ /********************/
+
+ $t->diag('Error management');
+ try
+ {
+ $b->get('http://nonexistent');
+ $t->fail('an exception is thrown when an adapter error occurs');
+ }
+ catch (Exception $e)
+ {
+ $t->pass('an exception is thrown when an adapter error occurs');
+ }
+
+ $t->is($b->get($example_site_url . '/nonexistentpage.html')->responseIsError(), true, 'responseIsError() returns true when response is an error');
+ $t->is($b->get($example_site_url)->responseIsError(), false, 'responseIsError() returns false when response is not an error');
+
+ /*******************/
+ /* Browser restart */
+ /*******************/
+
+ $t->diag('Browser restart');
+ $b->restart();
+ try
+ {
+ $b->reload();
+ $t->fail('restart() reinitializes the browser history');
+ }
+ catch (Exception $e)
+ {
+ $t->pass('restart() reinitializes the browser history');
+ }
+ $t->is($b->getResponseText(), '', 'restart() reinitializes the response');
+
+ /*************/
+ /* Redirects */
+ /*************/
+
+ $t->diag('Redirects');
+ $b = new sfWebBrowser(array(), $adapter);
+ $b->get('http://www.symfony-project.com/trac/wiki/sfUJSPlugin');
+ $t->like($b->getResponseText(), '/learn more about the unobtrusive approach/', 'follows 302 redirect after a GET');
+
+ $b = new myTestWebBrowser(array(), $adapter);
+ $b->call($askeet_params['url'].'/index.php/login', 'POST', array('nickname' => $askeet_params['login'], 'password' => $askeet_params['password']));
+ //$t->like($b->getResponseText(), '/url='.preg_quote($askeet_params['url'], '/').'\/index\.php/', 'does NOT follow a 302 redirect after a POST');
+ $t->like($b->getResponseText(), '/featured questions/', 'follows 302 redirect after POST ****** DESPITE THE HTTP SPEC ******');
+ $t->is($b->getRequestMethod(), 'GET', 'request method is changed to GET after POST for 302 redirect ***** DESPITE THE HTTP SPEC *****');
+ $t->todo('request method is changed to GET after POST for 303 redirect');
+
+ /***********/
+ /* Cookies */
+ /***********/
+
+ $t->diag('Cookies');
+ if ($adapter == 'sfCurlAdapter')
+ {
+ $b = new sfWebBrowser(array(), $adapter, array(
+ 'cookies' => true,
+ 'cookies_file' => $cookies_file,
+ 'cookies_dir' => $cookies_dir,
+ ));
+ $b->call($askeet_params['url'].'/login', 'POST', array(
+ 'nickname' => $askeet_params['login'],
+ 'password' => $askeet_params['password'],
+ ));
+ $t->like($b->getResponseBody(), '/'.$askeet_params['login'].' profile/', 'Cookies can be added to the request');
+
+ rmdir($cookies_dir);
+ rmdir(dirname(__FILE__).'/../data');
+ }
+ else
+ {
+ $t->todo('Cookies can be added to the request (sfCurlAdapter only for now)');
+ }
+
+ /****************/
+ /* File Uploads */
+ /****************/
+
+ $t->diag('File uploads');
+ if ($adapter == 'sfCurlAdapter')
+ {
+ $b->post($dump_headers_url, array(
+ 'test_file' => realpath(__FILE__),
+ ));
+ $t->like($b->getResponseText(), '/\[test_file\]/', 'The request can upload a file');
+ }
+ else
+ {
+ $t->todo('The request can upload a file (sfCurlAdapter only for now)');
+ }
+
+ /*****************/
+ /* Soap requests */
+ /*****************/
+
+ $t->diag('Soap requests');
+ $url = 'http://www.abundanttech.com/WebServices/Population/population.asmx';
+ $headers = array(
+ 'Soapaction' => 'http://www.abundanttech.com/WebServices/Population/getWorldPopulation',
+ 'Content-Type' => 'text/xml'
+ );
+ $requestBody = <<<EOT
+<?xml version="1.0" encoding="utf-8"?>
+<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <getWorldPopulation xmlns="http://www.abundanttech.com/WebServices/Population" />
+ </soap:Body>
+</soap:Envelope>
+EOT;
+ $b = new sfWebBrowser(array(), $adapter);
+ $b->post($url, $requestBody, $headers);
+ $t->like($b->getResponseText(), '/<Country>World<\/Country>/', 'sfWebBrowser can make a low-level SOAP call without parameter');
+
+ $url = 'http://www.abundanttech.com/WebServices/Population/population.asmx';
+ $headers = array(
+ 'Soapaction' => 'http://www.abundanttech.com/WebServices/Population/getPopulation',
+ 'Content-Type' => 'text/xml'
+ );
+ $requestBody = <<<EOT
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pop="http://www.abundanttech.com/WebServices/Population">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <pop:getPopulation>
+ <pop:strCountry>Comoros</pop:strCountry>
+ </pop:getPopulation>
+ </soapenv:Body>
+</soapenv:Envelope>
+EOT;
+ $b = new sfWebBrowser(array(), $adapter);
+ $b->post($url, $requestBody, $headers);
+ $t->like($b->getResponseText(), '/<Country>Comoros<\/Country>/', 'sfWebBrowser can make a low-level SOAP call with parameter');
+
+ $t->diag('');
+}
diff --git a/test/utils/.svn/all-wcprops b/test/utils/.svn/all-wcprops
new file mode 100644
index 0000000..03541e3
--- /dev/null
+++ b/test/utils/.svn/all-wcprops
@@ -0,0 +1,11 @@
+K 25
+svn:wc:ra_dav:version-url
+V 59
+/!svn/ver/13162/plugins/sfWebBrowserPlugin/trunk/test/utils
+END
+dumpheaders.php
+K 25
+svn:wc:ra_dav:version-url
+V 75
+/!svn/ver/13162/plugins/sfWebBrowserPlugin/trunk/test/utils/dumpheaders.php
+END
diff --git a/test/utils/.svn/entries b/test/utils/.svn/entries
new file mode 100644
index 0000000..8592f26
--- /dev/null
+++ b/test/utils/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+27927
+http://svn.symfony-project.com/plugins/sfWebBrowserPlugin/trunk/test/utils
+http://svn.symfony-project.com
+
+
+
+2008-05-07T19:51:14.825643Z
+8848
+Gilles.Taupenas
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ee427ae8-e902-0410-961c-c3ed070cd9f9
+
+dumpheaders.php
+file
+
+
+
+
+2010-02-09T21:41:24.000000Z
+524efb3f0fa5b2b25f833190723ae8b8
+2008-05-07T19:51:14.825643Z
+8848
+Gilles.Taupenas
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+223
+
diff --git a/test/utils/.svn/text-base/dumpheaders.php.svn-base b/test/utils/.svn/text-base/dumpheaders.php.svn-base
new file mode 100644
index 0000000..14bcbf0
--- /dev/null
+++ b/test/utils/.svn/text-base/dumpheaders.php.svn-base
@@ -0,0 +1,13 @@
+<pre>
+<?php
+ob_start("ob_gzhandler");
+
+print_r($_SERVER);
+
+print_r($_POST);
+
+$putdata = urldecode(file_get_contents("php://input","r"));
+print_r($putdata);
+
+print_r($_FILES);
+print_r(apache_request_headers());
|
diem-project/sfWebBrowserPlugin
|
9b7eff9ecfadc089e422466b7f9117a2800ef795
|
Synchronizing svn
|
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1b53ace
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.svn/
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..f5c493b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,7 @@
+Copyright (c) 2004-2008 Francois Zaninotto
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README b/README
new file mode 100644
index 0000000..aabe594
--- /dev/null
+++ b/README
@@ -0,0 +1,269 @@
+sfWebBrowser plugin
+===================
+
+The `sfWebBrowserPlugin` proposes an HTTP client capable of making web requests. The interface is similar to that of `sfTestBrowser`.
+
+Possible uses
+-------------
+
+ * Querying a Web service
+ * Monitoring a Website
+ * Mashup of content from several websites
+ * Aggregation of RSS feeds
+ * Proxy to another server
+ * Cross-domain AJAX interactions
+ * API to foreign websites
+ * Fetch images and other types of content
+ * ...
+
+Contents
+--------
+
+This plugin contains four classes: `sfWebBrowser`, `sfCurlAdapter`, `sfFopenAdapter`, and `sfSocketsAdapter`. Unit tests are available in the SVN repository, to be placed in a symfony application's `test/` directory.
+
+Features
+--------
+
+The `sfWebBrowser` class makes web requests based on a URI:
+
+ [php]
+ $b = new sfWebBrowser();
+ $b->get('http://www.example.com/');
+ $res = $b->getResponseText();
+
+The usual methods of the `sfTestBrowser` also work there, with the fluid interface.
+
+ [php]
+ // Inline
+ $b->get('http://www.example.com/')->get('http://www.google.com/')->back()->reload();
+ // More readable
+ $b->get('http://www.example.com/')
+ ->get('http://www.google.com/')
+ ->back()
+ ->reload();
+
+The browser accepts absolute and relative URIs
+
+ [php]
+ $b->get('http://www.example.com/test.html');
+ $b->get('test.html');
+
+The `get()` method accepts parameters either as a query string, or as an associative array.
+
+ [php]
+ $b->get('http://www.example.com/test.php?foo=bar');
+ $b->get('http://www.example.com/test.php', array('foo' => 'bar'));
+
+POST, PUT and DELETE requests are also supported.
+
+ [php]
+ $b->post('http://www.example.com/test.php', array('foo' => 'bar'));
+ $b->put('http://www.example.com/test.php', array('foo' => 'bar'));
+ $b->delete('http://www.example.com/test.php', array('foo' => 'bar'));
+
+You can access the response in various formats, at your convenience:
+
+ [php]
+ $myString = $b->getResponseText();
+ $myString = $b->getResponseBody(); // drop the <head> part
+ $myDomDocument = $b->getResponseDom();
+ $myDomCssSelector = $b->getResponseDomCssSelector();
+ $mySimpleXml = $b->getResponseXml();
+
+You can also interact with the response with the `setFields()` and `click()` methods.
+
+ [php]
+ $b->get('http://www.example.com/login')
+ ->setField('user', 'foobar')
+ ->setField('password', 'barbaz')
+ ->click('submit');
+
+The browser supports HTTP and HTTPS requests, proxies, redirects, and timeouts.
+
+Gzip and deflate content-encoded response bodies are also supported, provided that you have the [http://php.net/zlib zlib extention] enabled.
+
+Adapters
+--------
+
+The browser can use various adapters to perform the requests, and uses the following selection order by default:
+
+ * `sfCurlAdapter`: Uses [Curl](http://php.net/curl) to fetch pages. This adapter is a lot faster than `sfFopenAdapter`, however PHP must be compiled with the `with-curl` option, and the `curl` extension must be enabled in `php.ini` (which is rarely the case by default) for it to work.
+
+ * `sfFopenAdapter`: Uses [`fopen()`](http://php.net/fopen ) to fetch pages. `fopen()` can take an URL as a parameter provided that PHP is compiled with sockets support, and `allow_url_fopen` is defined to `true` in `php.ini`. This is the case in most PHP distributions, so the default adapter should work in almost every platform. On the other hand, the compatibility has a cost: this adapter is slow.
+
+ * `sfSocketsAdapter`: Uses [`fsockopen()`](http://php.net/fsockopen) to fetch pages.
+
+Alternatively, you can specify an adapter explicitly when you create a new browser object, as follows:
+
+ [php]
+ // use default adapter, i.e. sfCurlAdapter
+ $b = new sfWebBrowser(array());
+ // use sfFopenAdapter
+ $b = new sfWebBrowser(array(), 'sfFopenAdapter');
+
+Currenly, `sfCurlAdapter` offers slightly more functionality than the other adapters. Namely, it supports multipart file uploads and cookies, which means you can login to a site as well as upload files via forms.
+
+ [php]
+ // upload files via a form
+ $b = new sfWebBrowser();
+ $b->post($url_of_form, array(
+ 'file_field' => '/path/to/my/local/file.jpg'
+ ));
+ // login to a website
+ $b = new sfWebBrowser(array(), 'sfCurlAdapter', array('cookies' => true));
+ $b->post($url_of_login_form, array(
+ 'user_field' => $username,
+ 'pass_field' => $password
+ ));
+
+Full examples are available in the unit tests.
+
+Error Handling
+--------------
+
+`sfWebBrowser` distinguishes to types of error: adapter errors and response errors. Thus, `sfWebBrowser` calls should be run this way :
+
+ [php]
+ $b = new sfWebBrowser();
+ try
+ {
+ if (!$b->get($url)->responseIsError())
+ {
+ // Successful response (eg. 200, 201, etc)
+ }
+ else
+ {
+ // Error response (eg. 404, 500, etc)
+ }
+ }
+ catch (Exception $e)
+ {
+ // Adapter error (eg. Host not found)
+ }
+
+Besides, you should always remember that the response contents may contain incorrect code. Consider it as 'tainted', and therefore always use the [escaping](http://www.symfony-project.com/book/trunk/07-Inside-the-View-Layer#Output%20Escaping) when outputting it to a template.
+
+ [php]
+ // In the action
+ $this->title = (string) $b->getResponseXml()->body->h1
+
+ // In the template
+ <?php echo $title // dangerous ?>
+ <?php echo $sf_data->get('title') // correct ?>
+
+Installation
+------------
+
+* Install the plugin
+
+ > php symfony plugin:install sfWebBrowserPlugin # for symfony 1.1 and 1.2
+ > php symfony plugin-install http://plugins.symfony-project.com/sfWebBrowserPlugin # for symfony 1.0
+
+* Clear the cache to enable the autoloading to find the new class
+
+ > symfony cc
+
+Known limitations
+-----------------
+
+Cookies, caching, and file uploads are not yet supported in any of the packages (some of this functionality is available with `sfCurlAdapter`, see above).
+
+Changelog
+---------
+
+### Trunk
+
+### 2009-05-12 | 1.1.2 Stable
+
+ * francois: Fixed sfCurlAdapter destructor
+ * francois: Fixed sf1.2 compatibility issue for custom exception
+ * francois: Fixed a few limit case bugs and made the tests pass
+
+### 2009-04-22 | 1.1.1 Stable
+
+ * francois: Fixed README syntax for parameters array
+ * bmeynell: Fixed custom options in `sfCurlAdapter`
+
+### 2008-09-23 | 1.1.0 Stable
+
+ * francois: Translated README to Markdown
+ * francois: Added support for custom options in `sfCurlAdapter`
+ * francois: Added suppot for Timeout with `sfCurlAdapter` (based on a patch by adoanhuu)
+ * blacksun: Allow for SSL certificate verification
+ * francois: Added a test to check exceptions thrown by `getResponseXML`
+ * bmeynell: added multipart file upload support to `sfCurlAdapter`
+ * bmeynell: fixed regex in getResponseBody() which was returning an empty body
+ * bmeynell: `sfCurlAdapter`: Added new options: 'cookies', 'cookies_dir', 'cookies_file', 'verbose', 'verbose_log'
+ * bmeynell: `sfCurlAdapter`: Increased speed by Moving some initialization from call() to the constructer
+ * tristan: Easier management of invalid XML responses
+ * francois: Fixed a bug in `sfFopenAdapter` error handler
+ * bmeynell: Added chunked transfer encoding support to `sfSocketsAdapter`
+ * bmeynell: Added support for 301 redirects in `sfSocketsAdapter`
+
+### 2007-03-27 | 1.0.1 stable
+
+ * bmeynell: Fixed a bug with `sfCurlAdapter` causing 'Bad Request' error responses
+ * francois: Fixed a bug with `get()` when `arg_separator.output` is not set to '&' in `php.ini` (patch from river.bright)
+ * francois: Fixed a bug with `get()` when query string is already present in the url (based on a patch from Jeff Merlet)
+ * francois: Fixed auto-adapter decision in `sfWebBrowser::__construct()`
+
+### 2007-03-08 | 1.0.0 stable
+
+ * francois: Added auto-adapter decision in `sfWebBrowser::__construct()`
+ * francois: Changed tested URLs a bit to avoid redirection issues with google
+ * bmeynell: Added `sfSocketsAdapter`
+ * bmeynell: `sfCurlAdapter`: more detailed error messages & leaner request setup
+
+### 2007-02-22 | 0.9.6 Beta
+
+ * bmeynell, tristan: Allowed for requests with any method in `sfCurlAdapter`
+ * tristan: Added `sfWebBrowser::responseIsError()`
+ * tristan: Added `sfWebBrowser::getResponseMessage()`
+ * tristan: Refactored error management in `sfFopenAdapter`
+
+### 2007-02-21 | 0.9.5 Beta
+
+ * bmeynell: Fixed bug with relative uri's attempting to use a port other than 80 (sfWebBrowser, 132 - 146)
+ * bmeynell: Fixed small bug not printing hostname on exception (sfFopenAdapter, 61-62)
+ * bmeynell: Created sfCurlAdapter and passes all unit tests
+ * bmeynell: Removed '$changeStack = true' from call() prototype in sfCurlAdapter, sfFopenAdapter, and moved changestack check to sfWebBrowser
+ * bmeynell: Added $askeet_url to sfWebBrowserTest
+ * bmeynell: Added easy toggling between adapters in sfWebBrowserTest
+ * tristan: Added put() and delete() public methods
+ * tristan: Added unit tests to validate request HTTP method
+
+### 2007-02-16 | 0.9.4 Beta
+
+ * francois: Refactored the browser to make it multi-adapter
+ * francois: '''BC break''' constructor signature changed : `new sfWebBrowser(array $headers, string $adapter_class, array $adapter_options)`
+ * francois: Fixed notice when trying to retrieve inexistent header
+ * francois: Fixed header case normalization
+ * francois: Transformed setResponseXXX() methods to public
+ * francois: Fixed caps in `initializeRequestHeaders()`
+ * francois: Fixed unit test #40
+
+### 2007-02-16 | 0.9.3 Beta
+
+ * tristan: Added support for gzip and deflate.
+ * tristan: Possibility to pass default request headers to sfWebBrowser's constructor
+ * tristan: "Accept-Encoding" header is automatically set depending on PHP capabilities
+ * tristan: Fixed problems with request and response headers case
+ * tristan: Renamed "browser options" to "adapter options" (http://www.symfony-project.com/forum/index.php/m/21635/)
+ * tristan: '''BC break''' constructor signature changed : `new sfWebBrowser(array $headers, array $adapter_options)`
+ * tristan: Unit tested POST requests
+ * tristan: Changed way httpd headers are stored internally
+ * tristan: Fixed small bug in `getResponseBody()`
+ * francois: Fixed unit test for malformed headers
+
+### 2007-02-09 | 0.9.2 Beta
+
+ * francois: Fixed notice with `getResponseXML()`
+
+### 2007-02-08 | 0.9.1 Beta
+
+ * francois: Fixed notice with some headers
+ * francois: Added license and copyright
+
+### 2007-02-08 | 0.9.0 Beta
+
+ * francois: Initial release
diff --git a/lib/sfCurlAdapter.class.php b/lib/sfCurlAdapter.class.php
new file mode 100644
index 0000000..7de90c3
--- /dev/null
+++ b/lib/sfCurlAdapter.class.php
@@ -0,0 +1,237 @@
+<?php
+
+/*
+ * This file is part of the sfWebBrowserPlugin package.
+ * (c) 2004-2006 Francois Zaninotto <[email protected]>
+ * (c) 2004-2006 Fabien Potencier <[email protected]> for the click-related functions
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * sfWebBrowser provides a basic HTTP client.
+ *
+ * @package sfWebBrowserPlugin
+ * @author Francois Zaninotto <[email protected]>
+ * @author Ben Meynell <[email protected]>
+ * @version 0.9
+ */
+
+class sfCurlAdapter
+{
+ protected
+ $options = array(),
+ $curl = null,
+ $headers = array();
+
+ /**
+ * Build a curl adapter instance
+ * Accepts an option of parameters passed to the PHP curl adapter:
+ * ssl_verify => [true/false]
+ * verbose => [true/false]
+ * verbose_log => [true/false]
+ * Additional options are passed as curl options, under the form:
+ * userpwd => CURL_USERPWD
+ * timeout => CURL_TIMEOUT
+ * ...
+ *
+ * @param array $options Curl-specific options
+ */
+ public function __construct($options = array())
+ {
+ if (!extension_loaded('curl'))
+ {
+ throw new Exception('Curl extension not loaded');
+ }
+
+ $this->options = $options;
+ $curl_options = $options;
+
+ $this->curl = curl_init();
+
+ // cookies
+ if (isset($curl_options['cookies']))
+ {
+ if (isset($curl_options['cookies_file']))
+ {
+ $cookie_file = $curl_options['cookies_file'];
+ unset($curl_options['cookies_file']);
+ }
+ else
+ {
+ $cookie_file = sfConfig::get('sf_data_dir').'/sfWebBrowserPlugin/sfCurlAdapter/cookies.txt';
+ }
+ if (isset($curl_options['cookies_dir']))
+ {
+ $cookie_dir = $curl_options['cookies_dir'];
+ unset($curl_options['cookies_dir']);
+ }
+ else
+ {
+ $cookie_dir = sfConfig::get('sf_data_dir').'/sfWebBrowserPlugin/sfCurlAdapter';
+ }
+ if (!is_dir($cookie_dir))
+ {
+ if (!mkdir($cookie_dir, 0777, true))
+ {
+ throw new Exception(sprintf('Could not create directory "%s"', $cookie_dir));
+ }
+ }
+
+ curl_setopt($this->curl, CURLOPT_COOKIESESSION, false);
+ curl_setopt($this->curl, CURLOPT_COOKIEJAR, $cookie_file);
+ curl_setopt($this->curl, CURLOPT_COOKIEFILE, $cookie_file);
+ unset($curl_options['cookies']);
+ }
+
+ // default settings
+ curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($this->curl, CURLOPT_AUTOREFERER, true);
+ curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, false);
+ curl_setopt($this->curl, CURLOPT_FRESH_CONNECT, true);
+
+ if(isset($this->options['followlocation']))
+ {
+ curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, (bool) $this->options['followlocation']);
+ }
+
+ // activate ssl certificate verification?
+
+ if (isset($this->options['ssl_verify_host']))
+ {
+ curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, (bool) $this->options['ssl_verify_host']);
+ }
+ if (isset($curl_options['ssl_verify']))
+ {
+ curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, (bool) $this->options['ssl_verify']);
+ unset($curl_options['ssl_verify']);
+ }
+ // verbose execution?
+ if (isset($curl_options['verbose']))
+ {
+ curl_setopt($this->curl, CURLOPT_NOPROGRESS, false);
+ curl_setopt($this->curl, CURLOPT_VERBOSE, true);
+ unset($curl_options['cookies']);
+ }
+ if (isset($curl_options['verbose_log']))
+ {
+ $log_file = sfConfig::get('sf_log_dir').'/sfCurlAdapter_verbose.log';
+ curl_setopt($this->curl, CURLOPT_VERBOSE, true);
+ $this->fh = fopen($log_file, 'a+b');
+ curl_setopt($this->curl, CURLOPT_STDERR, $this->fh);
+ unset($curl_options['verbose_log']);
+ }
+
+ // Additional options
+ foreach ($curl_options as $key => $value)
+ {
+ $const = constant('CURLOPT_' . strtoupper($key));
+ if(!is_null($const))
+ {
+ curl_setopt($this->curl, $const, $value);
+ }
+ }
+
+ // response header storage - uses callback function
+ curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, array($this, 'read_header'));
+ }
+
+ /**
+ * Submits a request
+ *
+ * @param string The request uri
+ * @param string The request method
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function call($browser, $uri, $method = 'GET', $parameters = array(), $headers = array())
+ {
+ // uri
+ curl_setopt($this->curl, CURLOPT_URL, $uri);
+
+ // request headers
+ $m_headers = array_merge($browser->getDefaultRequestHeaders(), $browser->initializeRequestHeaders($headers));
+ $request_headers = explode("\r\n", $browser->prepareHeaders($m_headers));
+ curl_setopt($this->curl, CURLOPT_HTTPHEADER, $request_headers);
+
+ // encoding support
+ if(isset($headers['Accept-Encoding']))
+ {
+ curl_setopt($this->curl, CURLOPT_ENCODING, $headers['Accept-Encoding']);
+ }
+
+ // timeout support
+ if(isset($this->options['Timeout']))
+ {
+ curl_setopt($this->curl, CURLOPT_TIMEOUT, $this->options['Timeout']);
+ }
+
+ if (!empty($parameters))
+ {
+ if (!is_array($parameters))
+ {
+ curl_setopt($this->curl, CURLOPT_POSTFIELDS, $parameters);
+ }
+ else
+ {
+ // multipart posts (file upload support)
+ $has_files = false;
+ foreach ($parameters as $name => $value)
+ {
+ if (is_array($value)) {
+ continue;
+ }
+ if (is_file($value))
+ {
+ $has_files = true;
+ $parameters[$name] = '@'.realpath($value);
+ }
+ }
+ if($has_files)
+ {
+ curl_setopt($this->curl, CURLOPT_POSTFIELDS, $parameters);
+ }
+ else
+ {
+ curl_setopt($this->curl, CURLOPT_POSTFIELDS, http_build_query($parameters, '', '&'));
+ }
+ }
+ }
+
+ // handle any request method
+ curl_setopt($this->curl, CURLOPT_CUSTOMREQUEST, $method);
+
+ $response = curl_exec($this->curl);
+
+ if (curl_errno($this->curl))
+ {
+ throw new Exception(curl_error($this->curl));
+ }
+
+ $requestInfo = curl_getinfo($this->curl);
+
+ $browser->setResponseCode($requestInfo['http_code']);
+ $browser->setResponseHeaders($this->headers);
+ $browser->setResponseText($response);
+
+ // clear response headers
+ $this->headers = array();
+
+ return $browser;
+ }
+
+ public function __destruct()
+ {
+ curl_close($this->curl);
+ }
+
+ protected function read_header($curl, $headers)
+ {
+ $this->headers[] = $headers;
+
+ return strlen($headers);
+ }
+}
diff --git a/lib/sfFopenAdapter.class.php b/lib/sfFopenAdapter.class.php
new file mode 100644
index 0000000..3c63c00
--- /dev/null
+++ b/lib/sfFopenAdapter.class.php
@@ -0,0 +1,123 @@
+<?php
+
+/*
+ * This file is part of the sfWebBrowserPlugin package.
+ * (c) 2004-2006 Francois Zaninotto <[email protected]>
+ * (c) 2004-2006 Fabien Potencier <[email protected]> for the click-related functions
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * sfWebBrowser provides a basic HTTP client.
+ *
+ * @package sfWebBrowserPlugin
+ * @author Francois Zaninotto <[email protected]>
+ * @version 0.9
+ */
+class sfFopenAdapter
+{
+ protected
+ $options = array(),
+ $adapterErrorMessage = null,
+ $browser = null;
+
+ public function __construct($options = array())
+ {
+ $this->options = $options;
+ }
+
+ /**
+ * Submits a request
+ *
+ * @param string The request uri
+ * @param string The request method
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ * @param boolean To specify is the request changes the browser history
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function call($browser, $uri, $method = 'GET', $parameters = array(), $headers = array())
+ {
+ $m_headers = array_merge(array('Content-Type' => 'application/x-www-form-urlencoded'), $browser->getDefaultRequestHeaders(), $browser->initializeRequestHeaders($headers));
+ $request_headers = $browser->prepareHeaders($m_headers);
+
+ // Read the response from the server
+ // FIXME: use sockets to avoid depending on allow_url_fopen
+ $context = stream_context_create(array('http' => array_merge(
+ $this->options,
+ array('method' => $method),
+ array('content' => is_array($parameters) ? http_build_query($parameters) : $parameters),
+ array('header' => $request_headers)
+ )));
+
+ // Custom error handler
+ // -- browser instance must be accessible from handleRuntimeError()
+ $this->browser = $browser;
+ set_error_handler(array($this, 'handleRuntimeError'), E_WARNING);
+ if($handle = fopen($uri, 'r', false, $context))
+ {
+ $response_headers = stream_get_meta_data($handle);
+ $browser->setResponseCode(array_shift($response_headers['wrapper_data']));
+ $browser->setResponseHeaders($response_headers['wrapper_data']);
+ $browser->setResponseText(stream_get_contents($handle));
+ fclose($handle);
+ }
+
+ restore_error_handler();
+
+ if ($this->adapterErrorMessage == true)
+ {
+ $msg = $this->adapterErrorMessage;
+ $this->adapterErrorMessage = null;
+ throw new Exception($msg);
+ }
+
+ return $browser;
+ }
+
+ /**
+ * Handles PHP runtime error.
+ *
+ * This handler is used to catch any warnigns sent by fopen($url) and reformat them to something
+ * usable.
+ *
+ * @see http://php.net/set_error_handler
+ */
+ function handleRuntimeError($errno, $errstr, $errfile = null, $errline = null, $errcontext = array() )
+ {
+ $error_types = array (
+ E_ERROR => 'Error',
+ E_WARNING => 'Warning',
+ E_PARSE => 'Parsing Error',
+ E_NOTICE => 'Notice',
+ E_CORE_ERROR => 'Core Error',
+ E_CORE_WARNING => 'Core Warning',
+ E_COMPILE_ERROR => 'Compile Error',
+ E_COMPILE_WARNING => 'Compile Warning',
+ E_USER_ERROR => 'User Error',
+ E_USER_WARNING => 'User Warning',
+ E_USER_NOTICE => 'User Notice',
+ E_STRICT => 'Runtime Notice',
+ E_RECOVERABLE_ERROR => 'Catchable Fatal Error'
+ );
+
+ $msg = sprintf('%s : "%s" occured in %s on line %d',
+ $error_types[$errno], $errstr, $errfile, $errline);
+
+ $matches = array();
+ if (preg_match('/HTTP\/\d\.\d (\d{3}) (.*)$/', $errstr, $matches))
+ {
+ $this->browser->setResponseCode($matches[1]);
+ $this->browser->setResponseMessage($matches[2]);
+ $body = sprintf('The %s adapter cannot handle error responses body. Try using another adapter.', __CLASS__);
+ $this->browser->setResponseText($body);
+ }
+ else
+ {
+ $this->adapterErrorMessage = $msg;
+ }
+ }
+}
diff --git a/lib/sfSocketsAdapter.class.php b/lib/sfSocketsAdapter.class.php
new file mode 100644
index 0000000..b2539e1
--- /dev/null
+++ b/lib/sfSocketsAdapter.class.php
@@ -0,0 +1,152 @@
+<?php
+
+/*
+ * This file is part of the sfWebBrowserPlugin package.
+ * (c) 2004-2006 Francois Zaninotto <[email protected]>
+ * (c) 2004-2006 Fabien Potencier <[email protected]> for the click-related functions
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * sfWebBrowser provides a basic HTTP client.
+ *
+ * @package sfWebBrowserPlugin
+ * @author Francois Zaninotto <[email protected]>
+ * @author Benjamin Meynell <[email protected]>
+ * @version 0.9
+ */
+class sfSocketsAdapter
+{
+ protected
+ $options = array(),
+ $adapterErrorMessage = null,
+ $browser = null;
+
+ public function __construct($options = array())
+ {
+ $this->options = $options;
+ }
+
+ /**
+ * Submits a request
+ *
+ * @param string The request uri
+ * @param string The request method
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function call($browser, $uri, $method = 'GET', $parameters = array(), $headers = array())
+ {
+ $m_headers = array_merge(array('Content-Type' => 'application/x-www-form-urlencoded'), $browser->getDefaultRequestHeaders(), $browser->initializeRequestHeaders($headers));
+ $request_headers = $browser->prepareHeaders($m_headers);
+
+ $url_info = parse_url($uri);
+
+ // initialize default values
+ isset($url_info['path']) ? $path = $url_info['path'] : $path = '/';
+ isset($url_info['query']) ? $qstring = '?'.$url_info['query'] : $qstring = null;
+ isset($url_info['port']) ? null : $url_info['port'] = 80;
+
+ if (!$socket = @fsockopen($url_info['host'], $url_info['port'], $errno, $errstr, 15))
+ {
+ throw new Exception("Could not connect ($errno): $errstr");
+ }
+
+ // build request
+ $request = "$method $path$qstring HTTP/1.1\r\n";
+ $request .= 'Host: '.$url_info['host'].':'.$url_info['port']."\r\n";
+ $request .= $request_headers;
+ $request .= "Connection: Close\r\n";
+
+ if ($method == 'PUT' && is_array($parameters) && array_key_exists('file', $parameters))
+ {
+ $fp = fopen($parameters['file'], 'rb');
+ $sent = 0;
+ $blocksize = (2 << 20); // 2MB chunks
+ $filesize = filesize($parameters['file']);
+
+ $request .= 'Content-Length: '.$filesize."\r\n";
+
+ $request .= "\r\n";
+
+ fwrite($socket, $request);
+
+ while ($sent < $filesize)
+ {
+ $data = fread($fp, $blocksize);
+ fwrite($socket, $data);
+ $sent += $blocksize;
+ }
+ fclose($fp);
+ }
+ elseif ($method == 'POST' || $method == 'PUT')
+ {
+ $body = is_array($parameters) ? http_build_query($parameters, '', '&') : $parameters;
+ $request .= 'Content-Length: '.strlen($body)."\r\n";
+ $request .= "\r\n";
+ $request .= $body;
+ }
+
+ $request .= "\r\n";
+
+ fwrite($socket, $request);
+
+ $response = '';
+ $response_body = '';
+ while (!feof($socket))
+ {
+ $response .= fgets($socket, 1024);
+ }
+ fclose($socket);
+
+ // parse response components: status line, headers and body
+ $response_lines = explode("\r\n", $response);
+
+ // http status line (ie "HTTP 1.1 200 OK")
+ $status_line = array_shift($response_lines);
+
+ $start_body = false;
+ $response_headers = array();
+ for($i=0; $i<count($response_lines); $i++)
+ {
+ // grab body
+ if ($start_body == true)
+ {
+ // ignore chunked encoding size
+ if (!preg_match('@^[0-9A-Fa-f]+\s*$@', $response_lines[$i]))
+ {
+ $response_body .= $response_lines[$i];
+ }
+ }
+
+ // body starts after first blank line
+ else if ($start_body == false && $response_lines[$i] == '')
+ {
+ $start_body = true;
+ }
+
+ // grab headers
+ else
+ {
+ $response_headers[] = $response_lines[$i];
+ }
+ }
+
+ $browser->setResponseHeaders($response_headers);
+
+ // grab status code
+ preg_match('@(\d{3})@', $status_line, $status_code);
+ if(isset($status_code[1]))
+ {
+ $browser->setResponseCode($status_code[1]);
+ }
+ $browser->setResponseText(trim($response_body));
+
+ return $browser;
+ }
+
+}
diff --git a/lib/sfWebBrowser.class.php b/lib/sfWebBrowser.class.php
new file mode 100644
index 0000000..90f9024
--- /dev/null
+++ b/lib/sfWebBrowser.class.php
@@ -0,0 +1,851 @@
+<?php
+
+/*
+ * This file is part of the sfWebBrowserPlugin package.
+ * (c) 2004-2006 Francois Zaninotto <[email protected]>
+ * (c) 2004-2006 Fabien Potencier <[email protected]> for the click-related functions
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * sfWebBrowser provides a basic HTTP client.
+ *
+ * @package sfWebBrowserPlugin
+ * @author Francois Zaninotto <[email protected]>
+ * @author Tristan Rivoallan <[email protected]>
+ * @version 0.9
+ */
+class sfWebBrowser
+{
+ protected
+ $defaultHeaders = array(),
+ $stack = array(),
+ $stackPosition = -1,
+ $responseHeaders = array(),
+ $responseCode = '',
+ $responseMessage = '',
+ $responseText = '',
+ $responseDom = null,
+ $responseDomCssSelector = null,
+ $responseXml = null,
+ $fields = array(),
+ $urlInfo = array();
+
+ public function __construct($defaultHeaders = array(), $adapterClass = null, $adapterOptions = array())
+ {
+ if(!$adapterClass)
+ {
+ if (function_exists('curl_init'))
+ {
+ $adapterClass = 'sfCurlAdapter';
+ }
+ else if(ini_get('allow_url_fopen') == 1)
+ {
+ $adapterClass = 'sfFopenAdapter';
+ }
+ else
+ {
+ $adapterClass = 'sfSocketsAdapter';
+ }
+ }
+ $this->defaultHeaders = $this->fixHeaders($defaultHeaders);
+ $this->adapter = new $adapterClass($adapterOptions);
+ }
+
+ // Browser methods
+
+ /**
+ * Restarts the browser
+ *
+ * @param array default browser options
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function restart($defaultHeaders = array())
+ {
+ $this->defaultHeaders = $this->fixHeaders($defaultHeaders);
+ $this->stack = array();
+ $this->stackPosition = -1;
+ $this->urlInfo = array();
+ $this->initializeResponse();
+
+ return $this;
+ }
+
+ /**
+ * Sets the browser user agent name
+ *
+ * @param string agent name
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function setUserAgent($agent)
+ {
+ $this->defaultHeaders['User-Agent'] = $agent;
+
+ return $this;
+ }
+
+ /**
+ * Gets the browser user agent name
+ *
+ * @return string agent name
+ */
+ public function getUserAgent()
+ {
+ return isset($this->defaultHeaders['User-Agent']) ? $this->defaultHeaders['User-Agent'] : '';
+ }
+
+ /**
+ * Submits a GET request
+ *
+ * @param string The request uri
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function get($uri, $parameters = array(), $headers = array())
+ {
+ if ($parameters)
+ {
+ $uri .= ((false !== strpos($uri, '?')) ? '&' : '?') . http_build_query($parameters, '', '&');
+ }
+ return $this->call($uri, 'GET', array(), $headers);
+ }
+
+ public function head($uri, $parameters = array(), $headers = array())
+ {
+ if ($parameters)
+ {
+ $uri .= ((false !== strpos($uri, '?')) ? '&' : '?') . http_build_query($parameters, '', '&');
+ }
+ return $this->call($uri, 'HEAD', array(), $headers);
+ }
+
+ /**
+ * Submits a POST request
+ *
+ * @param string The request uri
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function post($uri, $parameters = array(), $headers = array())
+ {
+ return $this->call($uri, 'POST', $parameters, $headers);
+ }
+
+ /**
+ * Submits a PUT request.
+ *
+ * @param string The request uri
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function put($uri, $parameters = array(), $headers = array())
+ {
+ return $this->call($uri, 'PUT', $parameters, $headers);
+ }
+
+ /**
+ * Submits a DELETE request.
+ *
+ * @param string The request uri
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function delete($uri, $parameters = array(), $headers = array())
+ {
+ return $this->call($uri, 'DELETE', $parameters, $headers);
+ }
+
+ /**
+ * Submits a request
+ *
+ * @param string The request uri
+ * @param string The request method
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ * @param boolean To specify is the request changes the browser history
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function call($uri, $method = 'GET', $parameters = array(), $headers = array(), $changeStack = true)
+ {
+ $urlInfo = parse_url($uri);
+
+ // Check headers
+ $headers = $this->fixHeaders($headers);
+
+ // check port
+ if (isset($urlInfo['port']))
+ {
+ $this->urlInfo['port'] = $urlInfo['port'];
+ }
+ else if (!isset($this->urlInfo['port']))
+ {
+ $this->urlInfo['port'] = 80;
+ }
+
+ if(!isset($urlInfo['host']))
+ {
+ // relative link
+ $uri = $this->urlInfo['scheme'].'://'.$this->urlInfo['host'].':'.$this->urlInfo['port'].'/'.$uri;
+ }
+ else if($urlInfo['scheme'] != 'http' && $urlInfo['scheme'] != 'https')
+ {
+ throw new Exception('sfWebBrowser handles only http and https requests');
+ }
+
+ $this->urlInfo = parse_url($uri);
+
+ $this->initializeResponse();
+
+ if ($changeStack)
+ {
+ $this->addToStack($uri, $method, $parameters, $headers);
+ }
+
+ $browser = $this->adapter->call($this, $uri, $method, $parameters, $headers);
+
+ // redirect support
+ if ((in_array($browser->getResponseCode(), array(301, 307)) && in_array($method, array('GET', 'HEAD'))) || in_array($browser->getResponseCode(), array(302,303)))
+ {
+ $this->call($browser->getResponseHeader('Location'), 'GET', array(), $headers);
+ }
+
+ return $browser;
+ }
+
+ /**
+ * Gives a value to a form field in the response
+ *
+ * @param string field name
+ * @param string field value
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function setField($name, $value)
+ {
+ // as we don't know yet the form, just store name/value pairs
+ $this->parseArgumentAsArray($name, $value, $this->fields);
+
+ return $this;
+ }
+
+ /**
+ * Looks for a link or a button in the response and submits the related request
+ *
+ * @param string The link/button value/href/alt
+ * @param array request parameters (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function click($name, $arguments = array())
+ {
+ if (!$dom = $this->getResponseDom())
+ {
+ throw new Exception('Cannot click because there is no current page in the browser');
+ }
+
+ $xpath = new DomXpath($dom);
+
+ // text link, the name being in an attribute
+ if ($link = $xpath->query(sprintf('//a[@*="%s"]', $name))->item(0))
+ {
+ return $this->get($link->getAttribute('href'));
+ }
+
+ // text link, the name being the text value
+ if ($links = $xpath->query('//a[@href]'))
+ {
+ foreach($links as $link)
+ {
+ if(preg_replace(array('/\s{2,}/', '/\\r\\n|\\n|\\r/'), array(' ', ''), $link->nodeValue) == $name)
+ {
+ return $this->get($link->getAttribute('href'));
+ }
+ }
+ }
+
+ // image link, the name being the alt attribute value
+ if ($link = $xpath->query(sprintf('//a/img[@alt="%s"]/ancestor::a', $name))->item(0))
+ {
+ return $this->get($link->getAttribute('href'));
+ }
+
+ // form, the name being the button or input value
+ if (!$form = $xpath->query(sprintf('//input[((@type="submit" or @type="button") and @value="%s") or (@type="image" and @alt="%s")]/ancestor::form', $name, $name))->item(0))
+ {
+ throw new Exception(sprintf('Cannot find the "%s" link or button.', $name));
+ }
+
+ // form attributes
+ $url = $form->getAttribute('action');
+ $method = $form->getAttribute('method') ? strtolower($form->getAttribute('method')) : 'get';
+
+ // merge form default values and arguments
+ $defaults = array();
+ foreach ($xpath->query('descendant::input | descendant::textarea | descendant::select', $form) as $element)
+ {
+ $elementName = $element->getAttribute('name');
+ $nodeName = $element->nodeName;
+ $value = null;
+ if ($nodeName == 'input' && ($element->getAttribute('type') == 'checkbox' || $element->getAttribute('type') == 'radio'))
+ {
+ if ($element->getAttribute('checked'))
+ {
+ $value = $element->getAttribute('value');
+ }
+ }
+ else if (
+ $nodeName == 'input'
+ &&
+ (($element->getAttribute('type') != 'submit' && $element->getAttribute('type') != 'button') || $element->getAttribute('value') == $name)
+ &&
+ ($element->getAttribute('type') != 'image' || $element->getAttribute('alt') == $name)
+ )
+ {
+ $value = $element->getAttribute('value');
+ }
+ else if ($nodeName == 'textarea')
+ {
+ $value = '';
+ foreach ($element->childNodes as $el)
+ {
+ $value .= $dom->saveXML($el);
+ }
+ }
+ else if ($nodeName == 'select')
+ {
+ if ($multiple = $element->hasAttribute('multiple'))
+ {
+ $elementName = str_replace('[]', '', $elementName);
+ $value = array();
+ }
+ else
+ {
+ $value = null;
+ }
+
+ $found = false;
+ foreach ($xpath->query('descendant::option', $element) as $option)
+ {
+ if ($option->getAttribute('selected'))
+ {
+ $found = true;
+ if ($multiple)
+ {
+ $value[] = $option->getAttribute('value');
+ }
+ else
+ {
+ $value = $option->getAttribute('value');
+ }
+ }
+ }
+
+ // if no option is selected and if it is a simple select box, take the first option as the value
+ if (!$found && !$multiple)
+ {
+ $value = $xpath->query('descendant::option', $element)->item(0)->getAttribute('value');
+ }
+ }
+
+ if (null !== $value)
+ {
+ $this->parseArgumentAsArray($elementName, $value, $defaults);
+ }
+ }
+
+ // create request parameters
+ $arguments = sfToolkit::arrayDeepMerge($defaults, $this->fields, $arguments);
+ if ('post' == $method)
+ {
+ return $this->post($url, $arguments);
+ }
+ else
+ {
+ return $this->get($url, $arguments);
+ }
+ }
+
+ protected function parseArgumentAsArray($name, $value, &$vars)
+ {
+ if (false !== $pos = strpos($name, '['))
+ {
+ $var = &$vars;
+ $tmps = array_filter(preg_split('/(\[ | \[\] | \])/x', $name));
+ foreach ($tmps as $tmp)
+ {
+ $var = &$var[$tmp];
+ }
+ if ($var)
+ {
+ if (!is_array($var))
+ {
+ $var = array($var);
+ }
+ $var[] = $value;
+ }
+ else
+ {
+ $var = $value;
+ }
+ }
+ else
+ {
+ $vars[$name] = $value;
+ }
+ }
+
+ /**
+ * Adds the current request to the history stack
+ *
+ * @param string The request uri
+ * @param string The request method
+ * @param array The request parameters (associative array)
+ * @param array The request headers (associative array)
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function addToStack($uri, $method, $parameters, $headers)
+ {
+ $this->stack = array_slice($this->stack, 0, $this->stackPosition + 1);
+ $this->stack[] = array(
+ 'uri' => $uri,
+ 'method' => $method,
+ 'parameters' => $parameters,
+ 'headers' => $headers
+ );
+ $this->stackPosition = count($this->stack) - 1;
+
+ return $this;
+ }
+
+ /**
+ * Submits the previous request in history again
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function back()
+ {
+ if ($this->stackPosition < 1)
+ {
+ throw new Exception('You are already on the first page.');
+ }
+
+ --$this->stackPosition;
+ return $this->call($this->stack[$this->stackPosition]['uri'],
+ $this->stack[$this->stackPosition]['method'],
+ $this->stack[$this->stackPosition]['parameters'],
+ $this->stack[$this->stackPosition]['headers'],
+ false);
+ }
+
+ /**
+ * Submits the next request in history again
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function forward()
+ {
+ if ($this->stackPosition > count($this->stack) - 2)
+ {
+ throw new Exception('You are already on the last page.');
+ }
+
+ ++$this->stackPosition;
+ return $this->call($this->stack[$this->stackPosition]['uri'],
+ $this->stack[$this->stackPosition]['method'],
+ $this->stack[$this->stackPosition]['parameters'],
+ $this->stack[$this->stackPosition]['headers'],
+ false);
+ }
+
+ /**
+ * Submits the current request again
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function reload()
+ {
+ if (-1 == $this->stackPosition)
+ {
+ throw new Exception('No page to reload.');
+ }
+
+ return $this->call($this->stack[$this->stackPosition]['uri'],
+ $this->stack[$this->stackPosition]['method'],
+ $this->stack[$this->stackPosition]['parameters'],
+ $this->stack[$this->stackPosition]['headers'],
+ false);
+ }
+
+ /**
+ * Transforms an associative array of header names => header values to its HTTP equivalent.
+ *
+ * @param array $headers
+ * @return string
+ */
+ public function prepareHeaders($headers = array())
+ {
+ $prepared_headers = array();
+ foreach ($headers as $name => $value)
+ {
+ $prepared_headers[] = sprintf("%s: %s\r\n", ucfirst($name), $value);
+ }
+
+ return implode('', $prepared_headers);
+ }
+
+ // Response methods
+
+ /**
+ * Initializes the response and erases all content from prior requests
+ */
+ public function initializeResponse()
+ {
+ $this->responseHeaders = array();
+ $this->responseCode = '';
+ $this->responseText = '';
+ $this->responseDom = null;
+ $this->responseDomCssSelector = null;
+ $this->responseXml = null;
+ $this->fields = array();
+ }
+
+ /**
+ * Set the response headers
+ *
+ * @param array The response headers as an array of strings shaped like "key: value"
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function setResponseHeaders($headers = array())
+ {
+ $header_array = array();
+ foreach($headers as $header)
+ {
+ $arr = explode(': ', $header);
+ if(isset($arr[1]))
+ {
+ $header_array[$this->normalizeHeaderName($arr[0])] = trim($arr[1]);
+ }
+ }
+
+ $this->responseHeaders = $header_array;
+
+ return $this;
+ }
+
+ /**
+ * Set the response code
+ *
+ * @param string The first line of the response
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function setResponseCode($firstLine)
+ {
+ preg_match('/\d{3}/', $firstLine, $matches);
+ if(isset($matches[0]))
+ {
+ $this->responseCode = $matches[0];
+ }
+ else
+ {
+ $this->responseCode = '';
+ }
+
+ return $this;
+ }
+
+ /**
+ * Set the response contents
+ *
+ * @param string The response contents
+ *
+ * @return sfWebBrowser The current browser object
+ */
+ public function setResponseText($res)
+ {
+ $this->responseText = $res;
+
+ return $this;
+ }
+
+ /**
+ * Get a text version of the response
+ *
+ * @return string The response contents
+ */
+ public function getResponseText()
+ {
+ $text = $this->responseText;
+
+ // Decode any content-encoding (gzip or deflate) if needed
+ switch (strtolower($this->getResponseHeader('content-encoding'))) {
+
+ // Handle gzip encoding
+ case 'gzip':
+ $text = $this->decodeGzip($text);
+ break;
+
+ // Handle deflate encoding
+ case 'deflate':
+ $text = $this->decodeDeflate($text);
+ break;
+
+ default:
+ break;
+ }
+
+ return $text;
+ }
+
+ /**
+ * Get a text version of the body part of the response (without <body> and </body>)
+ *
+ * @return string The body part of the response contents
+ */
+ public function getResponseBody()
+ {
+ preg_match('/<body.*?>(.*)<\/body>/si', $this->getResponseText(), $matches);
+
+ return isset($matches[1]) ? $matches[1] : '';
+ }
+
+ /**
+ * Get a DOMDocument version of the response
+ *
+ * @return DOMDocument The reponse contents
+ */
+ public function getResponseDom()
+ {
+ if(!$this->responseDom)
+ {
+ // for HTML/XML content, create a DOM object for the response content
+ if (preg_match('/(x|ht)ml/i', $this->getResponseHeader('Content-Type')))
+ {
+ $this->responseDom = new DomDocument('1.0', 'utf8');
+ $this->responseDom->validateOnParse = true;
+ @$this->responseDom->loadHTML($this->getResponseText());
+ }
+ }
+
+ return $this->responseDom;
+ }
+
+ /**
+ * Get a sfDomCssSelector version of the response
+ *
+ * @return sfDomCssSelector The response contents
+ */
+ public function getResponseDomCssSelector()
+ {
+ if(!$this->responseDomCssSelector)
+ {
+ // for HTML/XML content, create a DOM object for the response content
+ if (preg_match('/(x|ht)ml/i', $this->getResponseHeader('Content-Type')))
+ {
+ $this->responseDomCssSelector = new sfDomCssSelector($this->getResponseDom());
+ }
+ }
+
+ return $this->responseDomCssSelector;
+ }
+
+ /**
+ * Get a SimpleXML version of the response
+ *
+ * @return SimpleXMLElement The reponse contents
+ * @throws sfWebBrowserInvalidResponseException when response is not in a valid format
+ */
+ public function getResponseXML()
+ {
+ if(!$this->responseXml)
+ {
+ // for HTML/XML content, create a DOM object for the response content
+ if (preg_match('/(x|ht)ml/i', $this->getResponseHeader('Content-Type')))
+ {
+ $this->responseXml = @simplexml_load_string($this->getResponseText());
+ }
+ }
+
+ // Throw an exception if response is not valid XML
+ if (get_class($this->responseXml) != 'SimpleXMLElement')
+ {
+ $msg = sprintf("Response is not a valid XML string : \n%s", $this->getResponseText());
+ throw new sfWebBrowserInvalidResponseException($msg);
+ }
+
+ return $this->responseXml;
+ }
+
+ /**
+ * Returns true if server response is an error.
+ *
+ * @return bool
+ */
+ public function responseIsError()
+ {
+ return in_array((int)($this->getResponseCode() / 100), array(4, 5));
+ }
+
+ /**
+ * Get the response headers
+ *
+ * @return array The response headers
+ */
+ public function getResponseHeaders()
+ {
+ return $this->responseHeaders;
+ }
+
+ /**
+ * Get a response header
+ *
+ * @param string The response header name
+ *
+ * @return string The response header value
+ */
+ public function getResponseHeader($key)
+ {
+ $normalized_key = $this->normalizeHeaderName($key);
+ return (isset($this->responseHeaders[$normalized_key])) ? $this->responseHeaders[$normalized_key] : '';
+ }
+
+ /**
+ * Decodes gzip-encoded content ("content-encoding: gzip" response header).
+ *
+ * @param stream $gzip_text
+ * @return string
+ */
+ protected function decodeGzip($gzip_text)
+ {
+ return gzinflate(substr($gzip_text, 10));
+ }
+
+ /**
+ * Decodes deflate-encoded content ("content-encoding: deflate" response header).
+ *
+ * @param stream $deflate_text
+ * @return string
+ */
+ protected function decodeDeflate($deflate_text)
+ {
+ return gzuncompress($deflate_text);
+ }
+
+ /**
+ * Get the response code
+ *
+ * @return string The response code
+ */
+ public function getResponseCode()
+ {
+ return $this->responseCode;
+ }
+
+ /**
+ * Returns the response message (the 'Not Found' part in 'HTTP/1.1 404 Not Found')
+ *
+ * @return string
+ */
+ public function getResponseMessage()
+ {
+ return $this->responseMessage;
+ }
+
+ /**
+ * Sets response message.
+ *
+ * @param string $message
+ */
+ public function setResponseMessage($msg)
+ {
+ $this->responseMessage = $msg;
+ }
+
+ public function getUrlInfo()
+ {
+ return $this->urlInfo;
+ }
+
+ public function getDefaultRequestHeaders()
+ {
+ return $this->defaultHeaders;
+ }
+
+ /**
+ * Adds default headers to the supplied headers array.
+ *
+ * @param array $headers
+ * @return array
+ */
+ public function initializeRequestHeaders($headers = array())
+ {
+ // Supported encodings
+ $encodings = array();
+ if (isset($headers['Accept-Encoding']))
+ {
+ $encodings = explode(',', $headers['Accept-Encoding']);
+ }
+ if (function_exists('gzinflate') && !in_array('gzip', $encodings))
+ {
+ $encodings[] = 'gzip';
+ }
+ if (function_exists('gzuncompress') && !in_array('deflate', $encodings))
+ {
+ $encodings[] = 'deflate';
+ }
+
+ $headers['Accept-Encoding'] = implode(',', array_unique($encodings));
+
+ return $headers;
+ }
+
+ /**
+ * Validates supplied headers and turns all names to lowercase.
+ *
+ * @param array $headers
+ * @return array
+ */
+ private function fixHeaders($headers)
+ {
+ $fixed_headers = array();
+ foreach ($headers as $name => $value)
+ {
+ if (!preg_match('/([a-z]*)(-[a-z]*)*/i', $name))
+ {
+ $msg = sprintf('Invalid header "%s"', $name);
+ throw new Exception($msg);
+ }
+ $fixed_headers[$this->normalizeHeaderName($name)] = trim($value);
+ }
+
+ return $fixed_headers;
+ }
+
+ /**
+ * Retrieves a normalized Header.
+ *
+ * @param string Header name
+ *
+ * @return string Normalized header
+ */
+ protected function normalizeHeaderName($name)
+ {
+ return preg_replace('/\-(.)/e', "'-'.strtoupper('\\1')", strtr(ucfirst($name), '_', '-'));
+ }
+
+}
diff --git a/lib/sfWebBrowserInvalidResponseException.class.php b/lib/sfWebBrowserInvalidResponseException.class.php
new file mode 100644
index 0000000..c26d1bd
--- /dev/null
+++ b/lib/sfWebBrowserInvalidResponseException.class.php
@@ -0,0 +1,25 @@
+<?php
+
+/**
+ * This exception is thrown when response sent to browser is not in a valid format.
+ *
+ * @package sfWebBrowserPlugin
+ * @author Tristan Rivoallan <[email protected]>
+ */
+class sfWebBrowserInvalidResponseException extends sfException
+{
+ /**
+ * Class constructor.
+ *
+ * @param string The error message
+ * @param int The error code
+ */
+ public function __construct($message = null, $code = 0)
+ {
+ if(method_exists($this, 'setName'))
+ {
+ $this->setName('sfWebBrowserInvalidResponseException');
+ }
+ parent::__construct($message, $code);
+ }
+}
diff --git a/package.xml b/package.xml
new file mode 100644
index 0000000..c3c66fb
--- /dev/null
+++ b/package.xml
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" packagerversion="1.4.1" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
+ <name>sfWebBrowserPlugin</name>
+ <channel>pear.symfony-project.com</channel>
+ <summary>Standalone HTTP client</summary>
+ <description>The sfWebBrowserPlugin proposes an HTTP client capable of making web requests. The interface is similar to that of sfTestBrowser.</description>
+ <lead>
+ <name>François Zaninotto</name>
+ <user>fzaninotto</user>
+ <email>[email protected]</email>
+ <active>yes</active>
+ </lead>
+ <date>2009-05-12</date>
+ <version>
+ <release>1.1.2</release>
+ <api>1.1.2</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.symfony-project.com/license">MIT license</license>
+ <notes>-</notes>
+ <contents>
+ <dir name="/">
+ <dir name="lib">
+ <file name="sfCurlAdapter.class.php" role="data"/>
+ <file name="sfFopenAdapter.class.php" role="data"/>
+ <file name="sfSocketsAdapter.class.php" role="data"/>
+ <file name="sfWebBrowser.class.php" role="data"/>
+ <file name="sfWebBrowserInvalidResponseException.class.php" role="data"/>
+ </dir>
+ <file name="README" role="data"/>
+ <file name="LICENSE" role="data"/>
+ </dir>
+ </contents>
+
+ <dependencies>
+ <required>
+ <php>
+ <min>5.1.0</min>
+ </php>
+ <pearinstaller>
+ <min>1.4.1</min>
+ </pearinstaller>
+ <package>
+ <name>symfony</name>
+ <channel>pear.symfony-project.com</channel>
+ <min>0.8.1</min>
+ <max>2.0.0</max>
+ <exclude>2.0.0</exclude>
+ </package>
+ </required>
+ </dependencies>
+
+ <phprelease>
+ </phprelease>
+
+ <changelog>
+ <release>
+ <version>
+ <release>1.1.2</release>
+ <api>1.1.2</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.symfony-project.com/license">MIT license</license>
+ <date>2009-05-12</date>
+ <license>MIT</license>
+ <notes>
+ * francois: Fixed sfCurlAdapter destructor
+ * francois: Fixed sf1.2 compatibility issue for custom exception
+ * francois: Fixed a few limit case bugs and made the tests pass
+ </notes>
+ </release>
+ <release>
+ <version>
+ <release>1.1.1</release>
+ <api>1.1.1</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.symfony-project.com/license">MIT license</license>
+ <date>2009-04-22</date>
+ <license>MIT</license>
+ <notes>
+ * francois: Fixed README syntax for parameters array
+ * bmeynell: Fixed custom options in `sfCurlAdapter`
+ </notes>
+ </release>
+ <release>
+ <version>
+ <release>1.1.0</release>
+ <api>1.1.0</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.symfony-project.com/license">MIT license</license>
+ <date>2008-09-23</date>
+ <license>MIT</license>
+ <notes>
+ * francois: Translated README to Markdown
+ * francois: Added support for custom options in `sfCurlAdapter`
+ * francois: Added suppot for Timeout with `sfCurlAdapter` (based on a patch by adoanhuu)
+ * blacksun: Allow for SSL certificate verification
+ * francois: Added a test to check exceptions thrown by `getResponseXML`
+ * bmeynell: added multipart file upload support to `sfCurlAdapter`
+ * bmeynell: fixed regex in getResponseBody() which was returning an empty body
+ * bmeynell: `sfCurlAdapter`: Added new options: 'cookies', 'cookies_dir', 'cookies_file', 'verbose', 'verbose_log'
+ * bmeynell: `sfCurlAdapter`: Increased speed by Moving some initialization from call() to the constructer
+ * tristan: Easier management of invalid XML responses
+ * francois: Fixed a bug in `sfFopenAdapter` error handler
+ * bmeynell: Added chunked transfer encoding support to `sfSocketsAdapter`
+ * bmeynell: Added support for 301 redirects in `sfSocketsAdapter`
+ </notes>
+ </release>
+ </changelog>
+</package>
diff --git a/test/unit/sfWebBrowserTest.php b/test/unit/sfWebBrowserTest.php
new file mode 100644
index 0000000..f7b7a05
--- /dev/null
+++ b/test/unit/sfWebBrowserTest.php
@@ -0,0 +1,485 @@
+<?php
+
+include(dirname(__FILE__).'/../../../../test/bootstrap/unit.php');
+if(!isset($sf_symfony_lib_dir))
+{
+ $sf_symfony_lib_dir = $configuration->getSymfonyLibDir();
+}
+require_once(dirname(__FILE__).'/../../lib/sfWebBrowser.class.php');
+require_once(dirname(__FILE__).'/../../lib/sfFopenAdapter.class.php');
+require_once(dirname(__FILE__).'/../../lib/sfCurlAdapter.class.php');
+require_once(dirname(__FILE__).'/../../lib/sfSocketsAdapter.class.php');
+require_once($sf_symfony_lib_dir.'/exception/sfException.class.php');
+require_once(dirname(__FILE__).'/../../lib/sfWebBrowserInvalidResponseException.class.php');
+require_once($sf_symfony_lib_dir.'/config/sfConfig.class.php');
+require_once($sf_symfony_lib_dir.'/util/sfDomCssSelector.class.php');
+require_once($sf_symfony_lib_dir.'/util/sfToolkit.class.php');
+
+// Configuration
+// -- this script is needed for some tests. It is located in plugin's test/unit/utils folder
+$dump_headers_url = 'http://localhost/dumpheaders.php';
+
+// tests
+$nb_test_orig = 73;
+$adapter_list = array('sfCurlAdapter', 'sfFopenAdapter', 'sfSocketsAdapter');
+
+// -- sites used for testing requests
+$example_site_url = 'http://www.google.com';
+$askeet_params = array(
+ 'url' => 'http://www.askeet.com',
+ 'login' => 'francois',
+ 'password' => 'llactnevda2',
+);
+
+// -- cookies, file and directory automatically created
+$cookies_dir = dirname(__FILE__).'/../data/sfCurlAdapter';
+$cookies_file = $cookies_dir.'/cookies.txt';
+
+/**
+ * stub class
+ *
+ **/
+class myTestWebBrowser extends sfWebBrowser
+{
+ protected $requestMethod;
+ public function call($uri, $method = 'GET', $parameters = array(), $headers = array(), $changeStack = true)
+ {
+ parent::call($uri, $method, $parameters, $headers, $changeStack);
+ $this->requestMethod = $this->stack[$this->stackPosition]['method'];
+ }
+ public function getRequestMethod()
+ {
+ return $this->requestMethod;
+ }
+}
+
+$t = new lime_test($nb_test_orig * count($adapter_list), new lime_output_color());
+foreach($adapter_list as $adapter)
+{
+ $t->diag('Testing '.$adapter);
+ $t->diag('');
+
+ /******************/
+ /* Initialization */
+ /******************/
+
+ $t->diag('Initialization');
+ $b = new sfWebBrowser(array(), $adapter);
+
+ $t->is($b->getUserAgent(), '', 'a new browser has an empty user agent');
+ $t->is($b->getResponseText(), '', 'a new browser has an empty response');
+ $t->is($b->getResponseCode(), '', 'a new browser has an empty response code');
+ $t->is($b->getResponseHeaders(), array(), 'a new browser has empty reponse headers');
+
+ /*******************/
+ /* Utility methods */
+ /*******************/
+
+ $t->diag('Utility methods');
+ $b = new sfWebBrowser(array(), $adapter);
+ $t->is($b->setUserAgent('foo bar')->getUserAgent(), 'foo bar', 'setUserAgent() sets the user agent');
+ $t->is($b->setResponseText('foo bar')->getResponseText(), 'foo bar', 'setResponseText() extracts the response');
+ $t->is($b->setResponseCode('foo 123 bar')->getResponseCode(), '123', 'setResponseCode() extracts the three-digits code');
+ $t->is($b->setResponseCode('foo 12 bar')->getResponseCode(), '', 'setResponseCode() fails silently when response status is incorrect');
+ $t->is_deeply($b->setResponseHeaders(array('HTTP1.1 200 OK', 'foo: bar', 'bar: baz'))->getResponseHeaders(), array('Foo' => 'bar', 'Bar' => 'baz'), 'setResponseHeaders() extracts the headers array');
+ $t->is_deeply($b->setResponseHeaders(array('ETag: "535a8-9fb-44ff4a13"', 'WWW-Authenticate: Basic realm="Myself"'))->getResponseHeaders(), array('ETag' => '"535a8-9fb-44ff4a13"', 'WWW-Authenticate' => 'Basic realm="Myself"'), 'setResponseHeaders() extracts the headers array and accepts response headers with several uppercase characters');
+ $t->is_deeply($b->setResponseHeaders(array('HTTP1.1 200 OK', 'foo: bar', 'bar:baz', 'baz:bar'))->getResponseHeaders(), array('Foo' => 'bar'), 'setResponseHeaders() ignores malformed headers');
+
+ /**************/
+ /* Exceptions */
+ /**************/
+
+ $t->diag('Exceptions');
+ $b = new sfWebBrowser(array(), $adapter);
+ try
+ {
+ $b->get('htp://askeet');
+ $t->fail('get() throws an exception when passed an uri which is neither http nor https');
+ }
+ catch (Exception $e)
+ {
+ $t->pass('get() throws an exception when passed an uri which is neither http nor https');
+ }
+
+ /**********************/
+ /* Simple GET request */
+ /**********************/
+
+ $t->diag('Simple GET request');
+ $t->like($b->get($dump_headers_url)->getResponseText(), '/\[REQUEST_METHOD\] => GET/', 'get() performs a GET request');
+ $t->isa_ok($b, 'sfWebBrowser', 'get() make a web request and returns a browser object');
+ $t->is($b->getResponseCode(), 200, 'get() fills up the browser status code with the response');
+ $t->like($b->get($example_site_url)->getResponseHeader('Content-Type'), '/text\/html/', 'get() populates the header array');
+ $t->like(strtolower($b->getResponseText()), '/<head>/', 'get() populates the HTML of the response');
+
+ /***********************/
+ /* Simple HEAD request */
+ /***********************/
+
+ $t->diag('Simple HEAD request');
+ $t->like($b->head($dump_headers_url)->getResponseHeader('Content-Type'), '/text\/html/', 'head() populates the header array');
+ $t->is($b->getResponseText(), '', 'HEAD requests do not return a response body');
+
+ /***********************/
+ /* Simple POST request */
+ /***********************/
+
+ $t->diag('Simple POST request');
+ $t->like($b->post($dump_headers_url)->getResponseText(), '/\[REQUEST_METHOD\] => POST/', 'post() performs a POST request');
+ $t->like($b->post($dump_headers_url, array('post body'))->getResponseText(), '/post body/', 'post() sends body to server');
+
+ /**********************/
+ /* Simple PUT request */
+ /**********************/
+
+ $t->diag('Simple PUT request');
+ $t->like($b->put($dump_headers_url)->getResponseText(), '/\[REQUEST_METHOD\] => PUT/', 'put() performs a PUT request');
+ $t->like($b->put($dump_headers_url, array('PUT body'))->getResponseText(), '/PUT body/', 'put() sends body to server');
+
+ /*************************/
+ /* Simple DELETE request */
+ /*************************/
+
+ $t->diag('Simple DELETE request');
+ $t->like($b->delete($dump_headers_url)->getResponseText(), '/\[REQUEST_METHOD\] => DELETE/', 'delete() performs a DELETE request');
+
+ /*********************/
+ /* Arbitrary request */
+ /*********************/
+
+ $t->diag('Arbitrary request');
+ $t->like($b->call($dump_headers_url, 'MICHEL')->getResponseText(), '/\[REQUEST_METHOD\] => MICHEL/', 'call() supports any HTTP methods');
+
+ /****************************/
+ /* Response formats methods */
+ /****************************/
+
+ $t->diag('Response formats methods');
+ $b = new sfWebBrowser(array(), $adapter);
+ $b->get($example_site_url);
+ $t->like($b->getResponseText(), '/<body .*>/', 'getResponseText() returns the response text');
+ $t->unlike($b->getResponseBody(), '/<body>/', 'getResponseBody() returns the response body');
+ $t->isa_ok($b->getResponseDom(), 'DOMDocument', 'getResponseDom() returns the response Dom');
+ $t->isa_ok($b->getResponseDomCssSelector(), 'sfDomCssSelector', 'getResponseDomCssSelector() returns a CSS selector on the response Dom');
+ $b->get('http://rss.cnn.com/rss/cnn_topstories.rss');
+ $t->isa_ok($b->getResponseXml(), 'SimpleXMLElement', 'getResponseXml() returns the response as a SimpleXML Element');
+ $b->get('http://www.w3.org/StyleSheets/home.css');
+ try
+ {
+ $b->getResponseXml();
+ $t->fail('Incorrect XML throws an exception');
+ }
+ catch (Exception $e)
+ {
+ $t->pass('Incorrect XML throws an exception');
+ }
+
+ try
+ {
+ /******************************/
+ /* Absolute and relative URls */
+ /******************************/
+
+ $t->diag('Absolute and relative URls');
+ $b = new sfWebBrowser(array(), $adapter);
+ $t->like($b->get($askeet_params['url'])->getResponseText(), '/<h1>featured questions<\/h1>/', 'get() understands absolute urls');
+ $t->like($b->get($askeet_params['url'].'/index/1')->getResponseText(), '/<h1>popular questions<\/h1>/', 'get() understands absolute urls');
+ $t->like($b->get('/recent/1')->getResponseText(), '/<h1>recent questions<\/h1>/', 'get() understands relative urls with a trailing slash');
+ $t->like($b->get('/')->get('recent/1')->getResponseText(), '/<h1>recent questions<\/h1>/', 'get() understands relative urls without a trailing slash');
+
+ /***********************/
+ /* Interaction methods */
+ /***********************/
+
+ $t->diag('Interaction methods');
+ $b = new sfWebBrowser(array(), $adapter);
+ $t->like($b->get($askeet_params['url'])->click('activities')->getResponseText(), '/tag "activities"/', 'click() clicks on a link and executes the related request');
+ $t->like($b->get($askeet_params['url'])->click('/tag/activities')->getResponseText(), '/tag "activities"/', 'click() clicks on a link and executes the related request');
+ $t->like($b->click('askeet')->getResponseText(), '/<h1>featured questions<\/h1>/', 'click() clicks on an image if it finds the argument in the alt');
+ $t->like($b->click('search it', array('search' => 'foo'))->getResponseText(), '/<h1>questions matching "foo"<\/h1>/', 'click() clicks on a form input');
+ $t->like($b->setField('search', 'bar')->click('search it')->getResponseText(), '/<h1>questions matching "bar"<\/h1>/', 'setField() fills a form input');
+ }
+ catch (Exception $e)
+ {
+ $t->fail(sprintf('%s : skipping askeet related tests', $e->getMessage()));
+ }
+
+ /*******************************/
+ /* GET request with parameters */
+ /*******************************/
+
+ $t->diag('GET request with parameters');
+ $b = new sfWebBrowser(array(), $adapter);
+ $test_params = array('foo' => 'bar', 'baz' => '1');
+ $t->like($b->get($dump_headers_url, $test_params)->getResponseText(), '/\?foo=bar&baz=1/', 'get() can pass parameters with the second argument');
+ $t->like($b->get($dump_headers_url.'?'.http_build_query($test_params))->getResponseText(), '/\?foo=bar&baz=1/', 'get() can pass parameters concatenated to the URI as a query string');
+ $t->unlike($b->get($dump_headers_url.'?'.http_build_query($test_params))->getResponseText(), '/\?foo=bar&baz=1\&/', 'get() with an URL already containing request parameters doesn\'t add an extra &');
+ $t->like($b->get($dump_headers_url.'?'.http_build_query($test_params), array('biz' => 'bil'))->getResponseText(), '/\?foo=bar&baz=1&biz=bil/', 'get() can pass parameters concatenated to the URI as a query string and other parameters as a second argument');
+
+ $b = new sfWebBrowser(array(), $adapter);
+ $b->get($dump_headers_url);
+
+ /***************************/
+ /* Default request headers */
+ /***************************/
+
+ $t->diag('Default request headers');
+ $headers = array('Accept-language' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3');
+ $b = new sfWebBrowser($headers, $adapter);
+ $t->like(
+ $b->get($dump_headers_url)->getResponseText(),
+ "/fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3/",
+ 'sfWebBrowser constructor accepts default request headers as first parameter');
+ $headers = array('Accept-language' => 'en-gb;q=0.8,en-us;q=0.5,en;q=0.3');
+ $t->like(
+ $b->get($dump_headers_url, array(), $headers)->getResponseText(),
+ "/en-gb;q=0.8,en-us;q=0.5,en;q=0.3/",
+ 'Default request headers are overriden by request specific headers');
+
+ /***************************/
+ /* Request headers support */
+ /***************************/
+
+ $t->diag('Request headers support');
+ $b = new sfWebBrowser(array(), $adapter);
+ $headers = array(
+ 'Accept-language' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3',
+ 'Accept' => 'text/xml');
+ $t->like(
+ $b->get($dump_headers_url, array(), $headers)->getResponseText(),
+ "/fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3/",
+ 'get() can pass request headers with the third argument');
+ $t->like(
+ $b->post($dump_headers_url, array(), $headers)->getResponseText(),
+ "/fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3/",
+ 'post() can pass request headers with the third argument');
+ $msg = "get() can pass request headers not common that are defined uppercase in RFC 2616";
+ try
+ {
+ $t->like(
+ $b->get($dump_headers_url, array(), array('TE' => 'trailers, deflate;q=0.5'))->getResponseText(),
+ "/\[TE\] => trailers, deflate;q=0.5/",
+ $msg);
+ }
+ catch (Exception $e)
+ {
+ $t->fail($msg);
+ }
+
+ $msg = 'get() can pass request headers not common that are IE7 dependent: see http://www.w3.org/2006/http-header, now: ';
+ $field = '';
+ try
+ {
+ $headers = array('UA-CPU'=>'x86', 'UA-OS'=>'MacOS', 'UA-Color'=>'color16', 'UA-Pixels'=>'240x320');
+ $resp = $b->get($dump_headers_url, array(), $headers)->getResponseText();
+ foreach ($headers as $field => $value)
+ {
+ $t->like($resp, "/\[$field\] => $value/", $msg.$field);
+ }
+ }
+ catch (Exception $e)
+ {
+ $t->fail($msg.field.' - header refused');
+ }
+
+ /*********************************/
+ /* Encoded response body support */
+ /*********************************/
+
+ $t->diag('Encoded response body support');
+
+ $headers = array('Accept-Encoding' => 'gzip');
+ $t->like(
+ $b->get($dump_headers_url, array(), $headers)->getResponseText(),
+ "/gzip/",
+ 'getResponseText() can decode gzip encoded response body');
+ $headers = array('Accept-Encoding' => 'deflate');
+ $t->like(
+ $b->get($dump_headers_url, array(), $headers)->getResponseText(),
+ "/deflate/",
+ 'getResponseText() can decode deflate encoded response body');
+
+ $encodings = array();
+ if (function_exists('gzuncompress'))
+ {
+ $encodings[] = 'deflate';
+ }
+ if (function_exists('gzinflate'))
+ {
+ $encodings[] = 'gzip';
+ }
+ $target_headers = implode(',', $encodings);
+ $t->like(
+ $b->get($dump_headers_url, array(), $headers)->getResponseText(),
+ "/$target_headers/",
+ 'sfWebBrowser autosets accept-encoding headers depending on php capabilities');
+
+ $encodings = array();
+ if (function_exists('gzinflate'))
+ {
+ $encodings[] = 'gzip';
+ }
+ if (function_exists('gzuncompress'))
+ {
+ $encodings[] = 'deflate';
+ }
+ $headers = array('accept-encoding' => 'bzip2');
+ array_unshift($encodings, 'bzip2');
+ $target_headers = implode(',', $encodings);
+ $t->like(
+ $b->get($dump_headers_url, array(), $headers)->getResponseText(),
+ "/$target_headers/",
+ 'it is possible to set supplementary encodings');
+
+ /*******************/
+ /* History methods */
+ /*******************/
+
+ $t->diag('History methods');
+ $b = new sfWebBrowser(array(), $adapter);
+ $b->get($dump_headers_url);
+ $b->get($dump_headers_url.'?foo=bar');
+ $b->back();
+ $t->unlike($b->getResponseText(), '/foo=bar/', 'back() executes again the previous request in the history');
+ $b->forward();
+ $t->like($b->getResponseText(), '/foo=bar/', 'forward() executes again the next request in the history');
+ $b->reload();
+ $t->like($b->getResponseText(), '/foo=bar/', 'reload() executes again the current request in the history');
+
+ /********************/
+ /* Error management */
+ /********************/
+
+ $t->diag('Error management');
+ try
+ {
+ $b->get('http://nonexistent');
+ $t->fail('an exception is thrown when an adapter error occurs');
+ }
+ catch (Exception $e)
+ {
+ $t->pass('an exception is thrown when an adapter error occurs');
+ }
+
+ $t->is($b->get($example_site_url . '/nonexistentpage.html')->responseIsError(), true, 'responseIsError() returns true when response is an error');
+ $t->is($b->get($example_site_url)->responseIsError(), false, 'responseIsError() returns false when response is not an error');
+
+ /*******************/
+ /* Browser restart */
+ /*******************/
+
+ $t->diag('Browser restart');
+ $b->restart();
+ try
+ {
+ $b->reload();
+ $t->fail('restart() reinitializes the browser history');
+ }
+ catch (Exception $e)
+ {
+ $t->pass('restart() reinitializes the browser history');
+ }
+ $t->is($b->getResponseText(), '', 'restart() reinitializes the response');
+
+ /*************/
+ /* Redirects */
+ /*************/
+
+ $t->diag('Redirects');
+ $b = new sfWebBrowser(array(), $adapter);
+ $b->get('http://www.symfony-project.com/trac/wiki/sfUJSPlugin');
+ $t->like($b->getResponseText(), '/learn more about the unobtrusive approach/', 'follows 302 redirect after a GET');
+
+ $b = new myTestWebBrowser(array(), $adapter);
+ $b->call($askeet_params['url'].'/index.php/login', 'POST', array('nickname' => $askeet_params['login'], 'password' => $askeet_params['password']));
+ //$t->like($b->getResponseText(), '/url='.preg_quote($askeet_params['url'], '/').'\/index\.php/', 'does NOT follow a 302 redirect after a POST');
+ $t->like($b->getResponseText(), '/featured questions/', 'follows 302 redirect after POST ****** DESPITE THE HTTP SPEC ******');
+ $t->is($b->getRequestMethod(), 'GET', 'request method is changed to GET after POST for 302 redirect ***** DESPITE THE HTTP SPEC *****');
+ $t->todo('request method is changed to GET after POST for 303 redirect');
+
+ /***********/
+ /* Cookies */
+ /***********/
+
+ $t->diag('Cookies');
+ if ($adapter == 'sfCurlAdapter')
+ {
+ $b = new sfWebBrowser(array(), $adapter, array(
+ 'cookies' => true,
+ 'cookies_file' => $cookies_file,
+ 'cookies_dir' => $cookies_dir,
+ ));
+ $b->call($askeet_params['url'].'/login', 'POST', array(
+ 'nickname' => $askeet_params['login'],
+ 'password' => $askeet_params['password'],
+ ));
+ $t->like($b->getResponseBody(), '/'.$askeet_params['login'].' profile/', 'Cookies can be added to the request');
+
+ rmdir($cookies_dir);
+ rmdir(dirname(__FILE__).'/../data');
+ }
+ else
+ {
+ $t->todo('Cookies can be added to the request (sfCurlAdapter only for now)');
+ }
+
+ /****************/
+ /* File Uploads */
+ /****************/
+
+ $t->diag('File uploads');
+ if ($adapter == 'sfCurlAdapter')
+ {
+ $b->post($dump_headers_url, array(
+ 'test_file' => realpath(__FILE__),
+ ));
+ $t->like($b->getResponseText(), '/\[test_file\]/', 'The request can upload a file');
+ }
+ else
+ {
+ $t->todo('The request can upload a file (sfCurlAdapter only for now)');
+ }
+
+ /*****************/
+ /* Soap requests */
+ /*****************/
+
+ $t->diag('Soap requests');
+ $url = 'http://www.abundanttech.com/WebServices/Population/population.asmx';
+ $headers = array(
+ 'Soapaction' => 'http://www.abundanttech.com/WebServices/Population/getWorldPopulation',
+ 'Content-Type' => 'text/xml'
+ );
+ $requestBody = <<<EOT
+<?xml version="1.0" encoding="utf-8"?>
+<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <getWorldPopulation xmlns="http://www.abundanttech.com/WebServices/Population" />
+ </soap:Body>
+</soap:Envelope>
+EOT;
+ $b = new sfWebBrowser(array(), $adapter);
+ $b->post($url, $requestBody, $headers);
+ $t->like($b->getResponseText(), '/<Country>World<\/Country>/', 'sfWebBrowser can make a low-level SOAP call without parameter');
+
+ $url = 'http://www.abundanttech.com/WebServices/Population/population.asmx';
+ $headers = array(
+ 'Soapaction' => 'http://www.abundanttech.com/WebServices/Population/getPopulation',
+ 'Content-Type' => 'text/xml'
+ );
+ $requestBody = <<<EOT
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pop="http://www.abundanttech.com/WebServices/Population">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <pop:getPopulation>
+ <pop:strCountry>Comoros</pop:strCountry>
+ </pop:getPopulation>
+ </soapenv:Body>
+</soapenv:Envelope>
+EOT;
+ $b = new sfWebBrowser(array(), $adapter);
+ $b->post($url, $requestBody, $headers);
+ $t->like($b->getResponseText(), '/<Country>Comoros<\/Country>/', 'sfWebBrowser can make a low-level SOAP call with parameter');
+
+ $t->diag('');
+}
diff --git a/test/utils/dumpheaders.php b/test/utils/dumpheaders.php
new file mode 100644
index 0000000..14bcbf0
--- /dev/null
+++ b/test/utils/dumpheaders.php
@@ -0,0 +1,13 @@
+<pre>
+<?php
+ob_start("ob_gzhandler");
+
+print_r($_SERVER);
+
+print_r($_POST);
+
+$putdata = urldecode(file_get_contents("php://input","r"));
+print_r($putdata);
+
+print_r($_FILES);
+print_r(apache_request_headers());
|
tormaroe/barnesang.com
|
c18c15db18b9e3aeb9bdb22acbdb74d226574ef6
|
Added a bunch of songs
|
diff --git a/_posts/2010-02-27-amandus-dokkemann.textile b/_posts/2010-02-27-amandus-dokkemann.textile
new file mode 100644
index 0000000..961b3c5
--- /dev/null
+++ b/_posts/2010-02-27-amandus-dokkemann.textile
@@ -0,0 +1,39 @@
+---
+layout: song
+title: Amandus Dokkemann
+---
+Amandus var en dokkemann,
+og lange fine bukser hadde han.
+Og alltid var han blid og glad,
+og alltid gikk han rundt omkring sa:
+Ha ha ha, nå må jeg le.
+Det er så mye rart å se.
+Ja, hvor han gikk og hvor han sto,
+Amandus bare lo og lo og lo
+
+En dag Amandus gikk en tur,
+så møtte han en mann som var så sur.
+Det var en stor og voksen mann,
+og vet du hva Amandus sa til han:
+Ha ha ha - så sint du er,
+er det fordi du er så svær?
+Da er jeg glad at ikke jeg,
+er like stor og sint og sur som deg.
+
+En dag Amandus løp om kapp,
+så falt Amandus ned en diger trapp.
+Og hele hodet hans gikk 'a,
+men vet du hva Amandus sa:
+Ha ha ha - her ligger jeg,
+og hele hodet falt av meg;
+Men Kari er min gode venn,
+hun syr nok hele hodet på igjen.
+
+Og Kari hentet nål og tråd,
+og sydde så Amandus' hode på,
+"Nå må du gå og legge deg" sa hun;
+"og ta en bitteliten høneblund"
+Ha ha ha - nå sover jeg.
+Nå må ingen vekke meg!
+Nå sover jeg som Kari sa,
+og drømmer litt og har det veldig bra!
diff --git a/_posts/2010-02-27-bolla-pinnsvin.textile b/_posts/2010-02-27-bolla-pinnsvin.textile
new file mode 100644
index 0000000..5929cf0
--- /dev/null
+++ b/_posts/2010-02-27-bolla-pinnsvin.textile
@@ -0,0 +1,33 @@
+---
+layout: song
+title: Bolla Pinnsvin
+---
+Når sola stiger rund og gul og farger åsens topp,
+vet alle dyr i skoge at nå skal de snart stå opp.
+Og fuglene de starter med sitt vekkerklokkekor,
+da rasler det i grøfta der hvor bregneløvet gror.
+For nå skal Bolla Pinnsvin gå til skolen.
+
+Det første Bolla Pinnsvin gjør, det er å hente vann.
+Hun vasker fjes og labbene så godt hun bare kan,
+og mamma børster piggene som stritter rundt omkring,
+og selv om mamma lugger gjør det ingen verdend ting,
+for nå skal Bolla Pinnsvin gå til skolen.
+
+Og mamma smører niste, kan du gjette hva det er?
+Jo, åtte stykker museflesk og fire bringebær,
+og så en liten melkeskvett, og da blir Bolla gla'
+for pinnsvinfar har sagt at den får ingen lov å ta,
+for den skal Bolla Pinnsvin ha på skolen.
+
+Og så er Bolla ferdigkledd, og så kan Bolla gå,
+hun tusler over tunet under blåbærlyng og strå,
+langs hekken borti bakken rundt et digert furutre,
+hun tenker litt på mamman sin men kjabber trutt avsted,
+for nå skal Bolla Pinnsvin gå til skolen.
+
+I skogen er en furulund med fire stubber på,
+og det er dyreskolen, dit skal Bolla Pinnsvin gå
+På skolen er det moro, der er mange barn i lag,
+hun krabber opp på stubben sin og grynter blidt goddag.
+Og så er Bolla Pinnsvin nådd til skolen.
diff --git a/_posts/2010-02-27-de-tre-sma-fisk.textile b/_posts/2010-02-27-de-tre-sma-fisk.textile
new file mode 100644
index 0000000..56f78c6
--- /dev/null
+++ b/_posts/2010-02-27-de-tre-sma-fisk.textile
@@ -0,0 +1,33 @@
+---
+layout: song
+title: De tre små fisk
+---
+Har du hørt historien om de tre små fisk.
+Som endte sine dager på en fiskehandlers disk.
+De svømte, og de svømte, og de svømte rundt,
+for deres mor hadde sagt at svømming var sunt.
+
+Refr.:
+Bob bob dædi dædi bob bob suh (3x)
+for deres mor hadde sagt at svømming var sunt.
+
+Den ene hette Per og den andre het Hans,
+den tredje vet jeg ikke for han var utenlands.
+De svømte, og de svømte, og de svømte rundt,
+for deres mor hadde sagt at svømming var sunt.
+
+Refr.
+
+Den ene ble stekt og den andre ble kokt,
+den tredje vet jeg ikke for han var uten lukt.
+De svømte, og de svømte, og de svømte rundt,
+for deres mor hadde sagt at svømming var sunt
+
+Refr.
+
+Den ene svømte bryst og den andre svømte rygg,
+den tredje vet jeg ikke for han var veldig stygg.
+De svømte, og de svømte, og de svømte rundt,
+for deres mor hadde sagt at svømming var sunt
+
+Refr.
diff --git a/_posts/2010-02-27-gatevise.textile b/_posts/2010-02-27-gatevise.textile
new file mode 100644
index 0000000..d778560
--- /dev/null
+++ b/_posts/2010-02-27-gatevise.textile
@@ -0,0 +1,39 @@
+---
+layout: song
+title: Gåtevise
+---
+Hvem har pels så fin og så bløt
+og går på jakt om natten,
+og liker melk og honning og grøt?
+Jo det er... (katten)
+Og hvem er bitte liten og søt
+og veldig redd for pusen,
+men glad i flesk og ost og kjøtt?
+Jo - det er ....(musen)
+
+Og hvem har blanke fjær på sin kropp
+og har den gode vanen
+å vekke oss når sola står opp?
+Jo - det er ....(hanen)
+Og hvem er sint på ku og på katt,
+men veldig snill i grunnen,
+og passer huset dag og natt?
+Jo - det er ....(hunden)
+
+Og hvem skal bli til pølser og mat,
+så du og jeg kan spise'n?
+Ja hvem er tykk og doven og lat?
+Jo - det er ....(grisen)
+men hvem er ikke doven det spor,
+men rask som biler nesten,
+og veldig klok og sterk og stor?
+Jo - det er ....(hesten)
+
+Og hvem har gitt oss fløte og smør
+og osten vår i bua?
+Det dyret har du sikkert sett før:
+Jo - det er ....(kua)
+Og hvem er full av krøller og krull
+og spiser gras på haugen.
+og gir oss masse deilig ull?
+Jo - det er ....(sauen)
diff --git a/_posts/2010-02-27-hode-skulder-kne-og-ta.textile b/_posts/2010-02-27-hode-skulder-kne-og-ta.textile
new file mode 100644
index 0000000..85790b8
--- /dev/null
+++ b/_posts/2010-02-27-hode-skulder-kne-og-ta.textile
@@ -0,0 +1,8 @@
+---
+layout: song
+title: Hode, skulder, kne og tå
+---
+Hode, skulder, kne og tå, kne og tå.
+Hode, skulder, kne og tå, kne og tå.
+Øyne, øre, kinn og klappe på.
+Hode, skulder, kne og tå, kne og tå.
diff --git a/_posts/2010-02-27-jeg-vil-bygge-meg-en-gard.textile b/_posts/2010-02-27-jeg-vil-bygge-meg-en-gard.textile
new file mode 100644
index 0000000..15ad96d
--- /dev/null
+++ b/_posts/2010-02-27-jeg-vil-bygge-meg-en-gard.textile
@@ -0,0 +1,31 @@
+---
+layout: song
+title: Jeg vil bygge meg en gård
+---
+Jeg vil bygge meg en gård
+med en hage utenfor.
+Eng og åker må der være,
+lam og sauer bak et gjerde,
+og så bygger jeg til sist,
+rødmalt hus med trapp og kvist.
+
+Fjøset skal stå like ved.
+Der skal være plass til tre
+brune kuer som jeg steller
+alle morgener og kvelder.
+Og i stallen står en hest
+som jeg liker aller best.
+
+Gjess og høns og gris er bra.
+Og et stabbur vil jeg ha.
+Der skal stå i lange rekker
+fulle tønner tunge sekker.
+Også trenger jeg en pus
+som kan fange stabbur-mus.
+
+Tett ved sjøen vil jeg bo.
+Og om kvelden skal jeg ro
+ut og se til garn og ruse
+for å skaffe mat til huset.
+Og så ror jeg hjem til mor,
+for hun bor jo der jeg bor.
diff --git a/_posts/2010-02-27-kjerringa-med-staven.textile b/_posts/2010-02-27-kjerringa-med-staven.textile
new file mode 100644
index 0000000..d54f51f
--- /dev/null
+++ b/_posts/2010-02-27-kjerringa-med-staven.textile
@@ -0,0 +1,28 @@
+---
+layout: song
+title: Kjerringa med staven
+---
+Kjerringa med staven høgt oppi Hakkadalen
+Åtte potter rømme, fire merker smør
+Så kinna Kari, Ola hadde førr
+Kjerringa med staven
+
+Kjerringa med kjeppen hoppa over bekken
+Og så datt ho uti, og så var ho blaut
+Og så gikk ho heimatt, og så fikk ho graut
+Kjerringa med kjeppen
+
+Kjerringa me sleiva satt høgt oppi kleiva
+Og så vart ho vare jutulad'n då
+Jammen var det kara' før i verda og
+Kjerringa med sleiva
+
+Kjerringa med turua satt høgt oppi furua
+Og så kom ein hare hoppande forbi
+Han sa, sit du bare, tiritiriti
+Kjerringa med turua
+
+Kjerringa ho stridde, så kom ein fyr og fridde
+Vil du vera kjerring, skal eg vera mann
+Vil du koke kaffi, skal eg bera vann
+Kjerringa ho stridd
diff --git a/_posts/2010-02-27-lille-olle-bolle.textile b/_posts/2010-02-27-lille-olle-bolle.textile
new file mode 100644
index 0000000..15eb9df
--- /dev/null
+++ b/_posts/2010-02-27-lille-olle-bolle.textile
@@ -0,0 +1,9 @@
+---
+layout: song
+title: Lille Olle Bolle
+---
+Oppe på fjellet der bor det tre troller,
+Trollemor og trollefar og lille Olle Bolle
+"BØ!!" sier Trollefar,
+"Bø!" sier Trollemor,
+men den lille Olle Bolle sier bare "bø"
diff --git a/_posts/2010-02-27-lillebrors-vise.textile b/_posts/2010-02-27-lillebrors-vise.textile
new file mode 100644
index 0000000..f00c4dd
--- /dev/null
+++ b/_posts/2010-02-27-lillebrors-vise.textile
@@ -0,0 +1,48 @@
+---
+layout: song
+title: Lillebrors vise
+---
+Lillebror synes det er så trist,
+fryktelig trist, sikkert og visst,
+alle de andre har dratt av sted,
+og uten at han fikk bli med!
+Men når de så kommer hjem igjen,
+ja, hvem er det da som kan helt slippe skjenn?
+Det kan bare Lillebror, og bare, bare han.
+Det er det bare Lillebror og ingen fler som kan.
+
+Kari og Mari er svært så kry,
+fryktelig kry, fordi de kan sy.
+Men triller en snelle på golvet,
+da er Lillebror nyttig å ha.
+Vips under senga med veldig hast,
+og uten at pompen blir sittende fast.
+Det kan bare Lillebror, og bare, bare han.
+Det er det bare Lillebror og ingen fler som kan.
+
+Pelle har lagd seg et hus av bar
+inni et snar, fått lov av far.
+Der møtes guttene klokka tolv
+med klubbe og stor protokoll!
+Taket er lavt, de må stå på kne,
+nei, ingen av dem kan stå rett opp og ned.
+Det kan bare Lillebror, og bare, bare han.
+Det er det bare Lillebror og ingen fler som kan.
+
+Kjell han kan tegne så fint og flott,
+fryktelig flott, hytter og slott,
+busser og biler med lasteplan,
+men vet du hva Lillebror kan?
+Jo han kan tegne en krusedull
+og tydelig se det er sau som har ull!
+Det kan bare Lillebror, og bare, bare han.
+Det er det bare Lillebror og ingen fler som kan.
+
+En gang skal Lillebror selv bli stor!
+Fryktelig stor! Større enn mor!
+Da skal han lære hvert minste grann
+av det som de kan alle mann,
+lekser og leker av alle slag.
+Men dette som Lillebror greier i dag
+det kan bare Lillebror, og bare, bare han.
+Det er det bare Lillebror og ingen fler som kan.
diff --git a/_posts/2010-02-27-min-hatt-den-har-tre-kanter.textile b/_posts/2010-02-27-min-hatt-den-har-tre-kanter.textile
new file mode 100644
index 0000000..766de1d
--- /dev/null
+++ b/_posts/2010-02-27-min-hatt-den-har-tre-kanter.textile
@@ -0,0 +1,8 @@
+---
+layout: song
+title: Min hatt den har tre kanter
+---
+Min hatt den har tre kanter,
+tre kanter har min hatt.
+Og har den ei tre kanter
+så er det ei min hatt.
diff --git a/_posts/2010-02-27-morgendagens-sosken.textile b/_posts/2010-02-27-morgendagens-sosken.textile
new file mode 100644
index 0000000..ec28a23
--- /dev/null
+++ b/_posts/2010-02-27-morgendagens-sosken.textile
@@ -0,0 +1,35 @@
+---
+layout: song
+title: Morgendagens søsken
+---
+Mange barn rundt samme bord
+Mange barn på samme jord
+Det er vi, det er vi
+Morgendagens søsken
+
+Refr:
+Som søsken av jorden, bror sol, søster vind
+Står du og jeg sammen med kinn i mot kinn
+Jeg tar dine hender som rekkes mot meg
+Du ser mine øyne som smiler mot deg
+
+Mange øyne som kan se
+Mange munner som kan le
+Det er vi, det er vi
+Morgendagens søsken
+
+Refr.
+
+Mange føtter som kan gå
+Dit hvor hjelpen trenges nå
+Mange hender vendt mot dem
+Som har mistet sine hjem
+
+Refr.
+
+Mange tunger som kan si
+Ord som gjør deg glad og fri
+Det er vi, det er vi
+Morgendagens søsken
+
+Refr.
diff --git a/_posts/2010-02-27-nisser-og-dverger.textile b/_posts/2010-02-27-nisser-og-dverger.textile
new file mode 100644
index 0000000..764ee07
--- /dev/null
+++ b/_posts/2010-02-27-nisser-og-dverger.textile
@@ -0,0 +1,23 @@
+---
+layout: song
+title: Nisser og dverger
+---
+Nisser og dverge bygger i berge;
+men vi skal mine dem alle her ut.
+Ti mens vi synger muntre i klynger,
+sprenger vi berget i lufta med krutt.
+
+Ja, la oss bore dype og store
+huller i gråstein og blåstein og flint!
+Da, mens vi synger muntre i klynger,
+sprenger vi berget i stykker og splint.
+
+Hurra, det knaller; for et rabalder!
+Hurra, minerer, du vinner til sist.
+Ti mens vi synger muntre i klynger,
+sprenger vi berget ved makt og ved list.
+
+Fjellet skal beve under vår neve;
+hurra, minerer, nå knaller ditt skudd!
+Nisser og dverge bygger i berge,
+hurra, nå miner vi nissene ut!
diff --git a/_posts/2010-02-27-notteliten.textile b/_posts/2010-02-27-notteliten.textile
new file mode 100644
index 0000000..cd029b8
--- /dev/null
+++ b/_posts/2010-02-27-notteliten.textile
@@ -0,0 +1,30 @@
+---
+layout: song
+title: Nøtteliten
+---
+Nøtteliten bor i toppen av et tre
+Han er aldri ferdig når han skal avsted
+Han skal spise fire konglefrø og danse lite grann
+Han skal erte frøken skjære og en gammel kråkemann
+"Nøtteliten" sier mamma, "er du der"
+Nøtteliten svarer: "Neida, jeg er her"
+Og hopp og sprett og tjo og hei og fire kvister deler seg
+Så kommer Nøtteliten: "Her er jeg"
+
+"Nøtteliten" sier mamma "du må gå
+Og vær snar og flink på skoleveien nå
+Ikke fly og finne nøtter, du kan spise før du går
+Du skal sitte pent på stubben din når skoleklokka slår"
+Nøtteliten svarer: "Jada, jada, ja"
+"Men nå tror jeg jeg må stikke, ha det bra"
+Og hopp og sprett og tjo og hei og fire kvister deler seg
+Så hopper Nøtteliten: "Hei på deg"
+
+Nøtteliten gjør så mange rare hopp
+Ifra tre til tre og stamme ned og opp
+Glemmer skolen og det hele, han gjør kast og sprett og sprell
+Finner mange fine nøtter, han er nøtteknekker selv
+Men så hører han at skoleklokka slår
+Ifra tre til tre så bustehalen står
+Og hopp og sprett og tjo og hei og litt før den har ringt fra seg
+Så sitter han på stubben: "Her er jeg"
diff --git a/_posts/2010-02-27-per-spellmann.textile b/_posts/2010-02-27-per-spellmann.textile
new file mode 100644
index 0000000..88086f2
--- /dev/null
+++ b/_posts/2010-02-27-per-spellmann.textile
@@ -0,0 +1,33 @@
+---
+layout: song
+title: Per Spellmann
+---
+Per Spellman han hadde ei einaste ku
+Per Spellman han hadde ei einaste ku
+Han bytta bort kua fikk fela igjen
+Han bytta bort kua fikk fela igjen
+
+Ref:
+Du go'e gamle fiolin
+Du fiolin, du fiolin, du fela mi
+
+Og om eg vart gammal som stein under bru
+Og om eg vart gammal som stein under bru
+så aldri eg bytta bort fele for ku
+så aldri eg bytta bort fele for ku
+
+Ref.
+
+Og om eg vart gammal som mose på kvist
+og om eg vart gammal som mose på kvist
+så aldri eg bytta bort fela som sist
+så aldri eg bytta bort fela som sist
+
+Ref.
+
+Per Spellmann, han spela og fela ho let
+Per Spellmann han spela og fela ho let
+Så gutane dansa og jentene gret
+Så gutane dansa og jentene gret
+
+Ref.
diff --git a/_posts/2010-02-27-sar-du-blomster.textile b/_posts/2010-02-27-sar-du-blomster.textile
new file mode 100644
index 0000000..8f174eb
--- /dev/null
+++ b/_posts/2010-02-27-sar-du-blomster.textile
@@ -0,0 +1,27 @@
+---
+layout: song
+title: Sår du blomster
+---
+Sår du blomster vil blomstene spire
+Sår du ugress vil ugresset gro
+Du skal høste det du sår
+Du skal høste det du sår
+Så ut det gode du får
+
+Sår du godhet vil kjærlighet spire
+Sår du ondskap vil ondskapen gro
+Du skal høste det du sår
+Du skal høste det du sår
+Så ut det gode du får
+
+Sår du tillit vil tryggheten spire
+Sår du tvilen vil rotløshet gro
+Du skal høste det du sår
+Du skal høste det du sår
+Så ut det gode du får
+
+Sår du sannhet vil sannheten spire
+Sår du falskhet vil løgnen få gro
+Du skal høste det du sår
+Du skal høste det du sår
+Så ut det gode du får
diff --git a/_posts/2010-02-27-teddybjornens-vise.textile b/_posts/2010-02-27-teddybjornens-vise.textile
new file mode 100644
index 0000000..a1d00e6
--- /dev/null
+++ b/_posts/2010-02-27-teddybjornens-vise.textile
@@ -0,0 +1,57 @@
+---
+layout: song
+title: Teddybjørnens vise
+---
+Jeg er en gammal teddybjørn så snill som bare det,
+og hver gang jeg skal brumme litt, begynner jeg å le.
+Det har jeg lært av Marian, d'er hun som eier meg,
+og ingen kan vel tøyse slik som Marian og jeg.
+Når Marian har lagt meg, og jeg vet at det er kveld,
+så brummer jeg ei vise jeg har diktet om meg selv,
+og visa kan jeg synge på en gammel melodi
+fra dengang jeg var storgevinst i Sirkustivoli.
+
+Det var et veldig tivoli med lamper og musikk,
+og jeg var syk av lengsel hver gang karusellen gikk.
+Jeg tenkte: Jeg vil håpe den som vinner meg i kveld,
+har penger nok t'å ta meg med og kjøre karusell.
+Så kom ei lita jente bort, og det var Marian,
+med fullt av blanke penger i ei brun og lita hand.
+Hun kjøpte mange lodder, og jeg tenkte: Nei, å nei,
+så moro det skal bli å kjøre karusell med deg!
+
+Men plutselig så kvakk jeg i, for vet du hva hun sa?
+"Nå har jeg ingen penger mer, men jeg er like gla'."
+Jeg brummet da jeg hørte det og tenkte: Isj a meg,
+da vil jeg heller vinnes av en rikere enn deg!
+For mange kjøpte lodd på meg, til slutt en gammal mann,
+Og aldri har jeg sett så mange penger som hos han,
+men enda var'n sparsom, og jeg tenkte: For et hell!
+Han sparer slik at han og jeg skal kjøre karusell.
+
+Og da jeg skulle trekkes vet du hvem som vant meg da?
+Jo, det var han med pengene, og spør om jeg var gla'!
+Nå får jeg kjøre karusell! - Men vet du hva jeg fikk?
+Et gråpapir rundt magen før han tok meg med og gikk.
+Jeg ble'kke pakket opp en gang, han la meg på et kott.
+Og jeg som trodde rike bamser hadde det så godt!
+Da hadde det vært bedre å bli vunnet av en venn
+som ikke eide penger, men som elsket en igjen.
+
+Slik lå jeg lange tier, men en dag tok han meg ned
+og la meg bak i bilen sin og kjørte til et sted.
+Ja, det er nesten underlig at såntno' hende kan,
+for den som pakket opp meg det var lille Marian.
+Og han var hennes bestefar og tok henne på fang.
+"Nå skal du få en Teddybjørn i fødselsdagspresang!"
+Og Marian var ellevill, hun danset og hun sang,
+og jeg fikk snurre rundt og rundt for aller første gang.
+
+Og siden har jeg snurra nesten mere enn jeg vil,
+for Marian er ikke den som lar meg ligge still.
+Og sløyfa mi har Tassen spist, og håra skreller a',
+men det gjør ingen verdens ting, jeg brummer og er gla'.
+For hvis jeg mister større ting, som hue eller ben,
+tar Marian en hyssingstump og syr dem på igjen.
+Og det er mye bedre enn å legges vekk et sted
+med silkebånd om halsen sin - og aldri være med.
diff --git a/_posts/2010-02-27-tyven-tyven.textile b/_posts/2010-02-27-tyven-tyven.textile
new file mode 100644
index 0000000..963adc7
--- /dev/null
+++ b/_posts/2010-02-27-tyven-tyven.textile
@@ -0,0 +1,28 @@
+---
+layout: song
+title: Tyven, tyven
+---
+Tyven, tyven skal du hete
+For du stjal min lille venn
+Men jeg har et håp i vente at jeg snart
+Får en igjen
+
+Tror jeg tralala, tror jeg tralala,
+tror jeg tralala, så tror jeg tralala,
+tror jeg tralala!
+
+Jeg tror du står og sover
+og ikke passer på min venn
+Jeg tror du står og sover
+Og ikke passer på
+-Å nei, og nei jeg sover ei
+Jeg bare står å hviler meg.
+Jeg sover eller våker, så tenker jeg på deg.
+
+Siste gang jeg var i byen mistet jeg min paraply
+Og den kostet mange penger
+Og den var jo ganske ny
+
+Tror jeg tralala, tror jeg tralala,
+tror jeg tralala, så tror jeg tralala,
+tror jeg tralala.
diff --git a/_posts/2010-02-27-under-den-hvite-bro.textile b/_posts/2010-02-27-under-den-hvite-bro.textile
new file mode 100644
index 0000000..95e5514
--- /dev/null
+++ b/_posts/2010-02-27-under-den-hvite-bro.textile
@@ -0,0 +1,21 @@
+---
+layout: song
+title: Under den hvite bro
+---
+Under den hvite bro
+Seiler en båt med to
+Båten den hvælva
+Og Kari hu skreik
+"Ola jeg elsker deg"
+
+"Elsker du meg som før"
+"Ja, det er klart jeg gjør"
+Her skal vi bygge
+og her skal vi bo
+Under den hvite bro
+
+Under den svarte jord ligger
+Min oldemor
+Der har hun ligget
+I fem hundre år
+Uten en kaffetår.
|
tormaroe/barnesang.com
|
12187a4310ca7fe9e7a0cf8897aaff2aca5f1b88
|
Added some more songs. Tried to set different description and keywords for individual pages, but the YAML front mapper does not seem to work as expected :(
|
diff --git a/_layouts/default.html b/_layouts/default.html
index f07b8d5..e13b4b9 100644
--- a/_layouts/default.html
+++ b/_layouts/default.html
@@ -1,103 +1,103 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>{{page.title}}</title>
-<meta name="keywords" content="barnesanger, text" />
-<meta name="description" content="Teksten til alle barnesangene du har lyst til å synge for barna dine finner du på barnesang.com" />
+<meta name="keywords" content="barnesanger, tekst" />
+<meta name="description" content="{{ page.description }}" />
<meta name="google-site-verification" content="dOKE_95xElTnoc_oI0xiTqm9eWlSi7Em-73EdmCQJyI" />
<link href="default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!-- start header -->
<div id="header">
<div id="logo">
- <h1><a href="http://barnesang.com/">Barnesang.com</a></h1>
+ <h1><a href="index.html">Barnesang.com</a></h1>
<h2>Sanger som gjør barn glade</h2>
</div>
<div id="menu">
<ul>
<li class="active"><a href="index.html">alle sangene</a></li>
<!--li><a href="#">alle sanger</a></li>
<li><a href="#">Om barnesang.com</a></li>
<li><a href="#">lenker</a></li-->
</ul>
</div>
</div>
<!-- end header -->
<!-- start page -->
<div id="page">
<!-- start content -->
<div id="content">
<div class="post">
{{ content }}
</div>
</div>
<!-- end content -->
<!-- start sidebar -->
<div id="sidebar">
<ul>
<li id="search">
<h2><b>Søk</b> etter en sang</h2>
<!--form method="get" action="http://www.google.no/search?">
<fieldset>
<input type="text" id="as_q" name="as_q" value="" />
<input type="hidden" id="as_sitesearch" name="as_sitesearch" value="barnesang.com" />
<input type="submit" id="x" value="Søk" />
</fieldset>
</form-->
{% include searchbox.html %}
</li>
</ul>
<ul>
<li>{% include adsense_180_150.html %}</li>
</ul>
</div>
<!-- end sidebar -->
<div style="clear: both;"> </div>
</div>
<!-- end page -->
<!-- start footer -->
<div id="footer">
<div class="wrap">
<div id="fbox1" class="box2">
<h2><b>Om</b> barnesang.com</h2>
<p>Barnesang.com gir deg teksten på tradisjonelle barnesanger som du selv vokste opp med, og som du ønsker å videreføre til dine barn. Spørsmål og andre henvendelser kan rettes til <a href="mailto:[email protected]">[email protected]</a>.</p>
</div>
<div id="fbox2" class="box2">
<h2><b>Utvalgte</b> sanger</h2>
<ul>
{% unless site.related_posts %}
{% for post in site.posts limit:5 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
{% endunless %}
{% for post in site.related_posts limit:5 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
</div>
<div id="fbox3" class="box2">
<h2><b>Mest</b> populære</h2>
<ul>
{% unless site.related_posts %}
{% for post in site.posts limit:5 offset:5 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
{% endunless %}
{% for post in site.related_posts limit:5 offset:5 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
</div>
</div>
<p id="legal">(c) 2010 Barnesang.com. Design by <a href="http://www.nodethirtythree.com/">NodeThirtyThree</a> and <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p>
</div>
<!-- end footer -->
{% include analytics.html %}
</body>
</html>
diff --git a/_posts/2010-02-11-dyrene-i-afrika.textile b/_posts/2010-02-11-dyrene-i-afrika.textile
new file mode 100644
index 0000000..26bc770
--- /dev/null
+++ b/_posts/2010-02-11-dyrene-i-afrika.textile
@@ -0,0 +1,72 @@
+---
+layout: song
+keywords: Foo
+title: Dyrene i Afrika
+description: Dette er en test
+---
+Det er ei lita dyrevise som du nå får høre,
+om dyrene i Afrika og alt de har å gjøre.
+
+Ojajaja ohaha, ojajaja ohaha,
+om dyrene i Afrika og alt de har å gjøre.
+
+Høyt oppi trærne vokser kokosnøtter og bananer,
+og der bor mange fornemme og fine bavianer.
+
+Ojajaja ohaha, ojajaja ohaha,
+der bor mange fornemme og fine bavianer.
+
+Og ungene blir vogget i en palmehengekøye,
+og barnepika er en gammel skravlepapegøye.
+
+Ojajaja ohaha, ojajaja ohaha,
+og barnepika er en gammel skravlepapegøye.
+
+Den store elefanten han er skogens brannkonstabel,
+og blir det brann så slukker han den med sin lange snabel.
+
+Ojajaja ohaha, ojajaja ohaha,
+blir det brann, så slukker han den med sin lange snabel.
+
+Men dronninga og kongen det er løven og løvinna,
+og dronninga er sulten støtt, og kongen er så sinna.
+
+Ojajaja ohaha, ojajaja ohaha,
+og dronninga er sulten støtt, og kongen er så sinna.
+
+I trærne sitter fuglene og synger hele dagen,
+og flodhesten slår tromme ved å dunke seg på magen.
+
+Ojajaja ohaha, ojajaja ohaha,
+flodhesten slår tromme ved å dunke seg på magen.
+
+Og strutsen danser samba med den peneste sjimpansen,
+og snart er alle andre dyra også med i dansen.
+
+Ojajaja ohaha, ojajaja ohaha,
+snart er alle andre dyra også med i dansen.
+
+Den store krokodillen var så dårlig her om dagen,
+den hadde spist en apekatt og fått så vondt i magen.
+
+Ojajaja ohaha, ojajaja ohaha,
+den hadde spist en apekatt og fått så vondt i magen.
+
+Og nede i sjiraffenland der var det sorg i valsen,
+for åtte små sjiraffer hadde fått så vondt i halsen.
+
+Ojajaja ohaha,ojajaja ohaha,
+åtte små sjiraffer hadde fått så vondt i halsen.
+
+Men da kom doktor Nesehorn med hatt og stokk og briller,
+og så fikk alle hostesaft og sorte små pastiller.
+
+Ojajaja ohaha, ojajaja ohaha
+og så fikk alle hostesaft og sorte små pastiller.
+
+Den stakkars krokodillen måtte doktor'n operere,
+og enda er det mange vers, men jeg kan ikke flere.
+
+Ojajaja ohaha, ojajaja ohaha
+og enda er det mange vers, men jeg kan ikke flere.
+
diff --git a/_posts/2010-02-23-alle-hjerter-banker.textile b/_posts/2010-02-23-alle-hjerter-banker.textile
new file mode 100644
index 0000000..7aafaf7
--- /dev/null
+++ b/_posts/2010-02-23-alle-hjerter-banker.textile
@@ -0,0 +1,142 @@
+---
+layout: song
+title: Alle hjerter banker
+---
+Alle hjerter banker.
+Alle hjerter banker.
+Vaffelhjerter banker ei.
+Vaffelhjerter banker ei,
+sier jeg til deg.
+
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri hi hi.
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri.
+
+Alle busser ruller,
+alle busser ruller,
+Busseruller ruller ei.
+Busseruller ruller ei,
+sier jeg til deg.
+
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri hi hi.
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri.
+
+Alle duer flyver.
+Alle duer flyver.
+Vinduer flyver ei.
+Vinduer flyver ei,
+sier jeg til deg.
+
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri hi hi.
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri.
+
+Alle seler svømmer.
+Alle seler svømmer.
+Bukseseler svømmer ei.
+Bukseseler svømmer ei,
+sier jeg til deg
+
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri hi hi.
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri
+
+Alle rister ruster.
+Alle rister ruster.
+Kontorister ruster ei.
+Kontorister ruster ei,
+sier jeg til deg.
+
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri hi hi.
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri
+
+Alle ringer ruller.
+Alle ringer ruller.
+Kjerringer ruller ei.
+Kjerringer ruller ei,
+sier jeg til deg.
+
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri hi hi.
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri
+
+Alle griser grynter.
+Alle griser grynter.
+Sparegriser grynter ei.
+Sparegriser grynter ei,
+sier jeg til deg.
+
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri hi hi.
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri
+
+Alle klokker tikker.
+Alle klokker tikker.
+Blåklokker tikker ei.
+Blåklokker tikker ei,
+sier jeg til deg.
+
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri hi hi.
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri
+
+Alle bier summer.
+Alle bier summer.
+Amfibier summer ei.
+Amfibier summer ei,
+sier jeg til deg.
+
+
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri hi hi.
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri
+
+Alle bølger bruser.
+Alle bølger bruser.
+Hetebølger bruser ei.
+Hetebølger bruser ei,
+sier jeg til deg.
+
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri hi hi.
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri
+
+Alle kammer lugger.
+Alle kammer lugger.
+Bakkekammer lugger ei.
+Bakkekammer lugger ei,
+sier jeg til deg.
+
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri hi hi.
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri
+
+Alt tøy kan vaskes.
+Alt tøy kan vaskes.
+Syltetøy vaskes ei.
+Syltetøy vaskes ei,
+sier jeg til deg.
+
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri hi hi.
+Og derfor denne melo-melo-melodi
+er blitt mitt svermeri
+
+Alt tau kan knytes.
+Alt tau kan knytes.
+Fortau knytes ei.
+Fortau knytes ei,
+sier jeg til deg.
diff --git a/_posts/2010-02-23-dyrene-i-afrika.textile b/_posts/2010-02-23-dyrene-i-afrika.textile
new file mode 100644
index 0000000..4c8678e
--- /dev/null
+++ b/_posts/2010-02-23-dyrene-i-afrika.textile
@@ -0,0 +1,70 @@
+---
+layout: song
+title: Dyrene i Afrika
+---
+Det er ei lita dyrevise som du nå får høre,
+om dyrene i Afrika og alt de har å gjøre.
+
+Ojajaja ohaha, ojajaja ohaha,
+om dyrene i Afrika og alt de har å gjøre.
+
+Høyt oppi trærne vokser kokosnøtter og bananer,
+og der bor mange fornemme og fine bavianer.
+
+Ojajaja ohaha, ojajaja ohaha,
+der bor mange fornemme og fine bavianer.
+
+Og ungene blir vogget i en palmehengekøye,
+og barnepika er en gammel skravlepapegøye.
+
+Ojajaja ohaha, ojajaja ohaha,
+og barnepika er en gammel skravlepapegøye.
+
+Den store elefanten han er skogens brannkonstabel,
+og blir det brann så slukker han den med sin lange snabel.
+
+Ojajaja ohaha, ojajaja ohaha,
+blir det brann, så slukker han den med sin lange snabel.
+
+Men dronninga og kongen det er løven og løvinna,
+og dronninga er sulten støtt, og kongen er så sinna.
+
+Ojajaja ohaha, ojajaja ohaha,
+og dronninga er sulten støtt, og kongen er så sinna.
+
+I trærne sitter fuglene og synger hele dagen,
+og flodhesten slår tromme ved å dunke seg på magen.
+
+Ojajaja ohaha, ojajaja ohaha,
+flodhesten slår tromme ved å dunke seg på magen.
+
+Og strutsen danser samba med den peneste sjimpansen,
+og snart er alle andre dyra også med i dansen.
+
+Ojajaja ohaha, ojajaja ohaha,
+snart er alle andre dyra også med i dansen.
+
+Den store krokodillen var så dårlig her om dagen,
+den hadde spist en apekatt og fått så vondt i magen.
+
+Ojajaja ohaha, ojajaja ohaha,
+den hadde spist en apekatt og fått så vondt i magen.
+
+Og nede i sjiraffenland der var det sorg i valsen,
+for åtte små sjiraffer hadde fått så vondt i halsen.
+
+Ojajaja ohaha,ojajaja ohaha,
+åtte små sjiraffer hadde fått så vondt i halsen.
+
+Men da kom doktor Nesehorn med hatt og stokk og briller,
+og så fikk alle hostesaft og sorte små pastiller.
+
+Ojajaja ohaha, ojajaja ohaha
+og så fikk alle hostesaft og sorte små pastiller.
+
+Den stakkars krokodillen måtte doktor'n operere,
+og enda er det mange vers, men jeg kan ikke flere.
+
+Ojajaja ohaha, ojajaja ohaha
+og enda er det mange vers, men jeg kan ikke flere.
+
diff --git a/_posts/2010-02-23-helene-harefroken.textile b/_posts/2010-02-23-helene-harefroken.textile
new file mode 100644
index 0000000..4a6d306
--- /dev/null
+++ b/_posts/2010-02-23-helene-harefroken.textile
@@ -0,0 +1,38 @@
+---
+layout: song
+title: Helene Harefrøken
+---
+Helene Harefrøken glad og lett
+og søt og vimsete og sommerkledt,
+hun har tatt den hvite vinterkåpen av
+og sommerdrakten har hun første gang i dag,
+Brun over, og grå under
+og lyse-lyserød på snuten.
+
+Helene Harefrøken glad og lett
+og søt og vimsete og sommerkledt -
+haremamma ser på hareungen sin,
+Å, nei, å nei, å nei, ånei, hvor du er fin!
+Brun over, og grå under
+og lyse-lyserød på snuten.
+
+Helene Harefrøken brisker seg,
+og tripper lett og glad på skolevei.
+Jeger Bom-Bom kommer, børse har han med,
+Helene blir så redd, hun hopper fort avsted,
+Brun over, og grå under
+og lyse-lyserød på snuten.
+
+Helene Harefrøken hopper lett,
+men om en stund blir hun så veldig trett,
+Orker ikke mere, hun må hvile her,
+legger seg i mose, kjerringris og bær,
+Brun over, og grå under
+og lyse-lyserød på snuten.
+
+Så kommer Jeger Bom-Bom, hei og hi!
+Han kommer, ja - men har flyr rett forbi.
+Ris og bær og mose, rødt og brunt og grått,
+det er alt han ser, da koser hun seg godt.
+Brun over, og grå under
+og lyse-lyserød på snuten.
diff --git a/index.html b/index.html
index 8f6b25c..6d8eb56 100644
--- a/index.html
+++ b/index.html
@@ -1,15 +1,16 @@
---
layout: default
title: barnesang.com
+description: Teksten til alle barnesangene du har lyst til å synge for barna dine finner du på barnesang.com
---
<div class="box1">
<p>
Her finner du tekstene til barnesangene vi alle er så glad i. Vi har begynt i det små, men flere tekster kommer snart.
</p>
</div>
<div style="margin-top:20px;">
{% for post in site.posts %}
<a href="{{ post.url }}">{{ post.title }}</a> |
{% endfor %}
</div>
|
tormaroe/barnesang.com
|
9393506cb5c83ce0b9b4713597ab9fa99f034821
|
Added a couple of song lyrics
|
diff --git a/_posts/2010-02-23-a-jeg-vet-en-seter.textile b/_posts/2010-02-23-a-jeg-vet-en-seter.textile
new file mode 100644
index 0000000..5d8e6d7
--- /dev/null
+++ b/_posts/2010-02-23-a-jeg-vet-en-seter.textile
@@ -0,0 +1,31 @@
+---
+layout: song
+title: 'Å, jeg vet en seter'
+---
+Å, jeg vet en seter,
+med så mange gjeter!
+Noen har en bjelle
+når de går i fjellet!
+Geitene de springer,
+bjellene, de klinger
+Singe-linge-linge-linge
+lang, lang, lang.
+
+Horn i toppen, ragget på kroppen,
+blakke og svarte og hvite og grå.
+Lang i kjaken, skjegg under haken,
+listig og lystig og lett på tå.
+
+Alle springer løse,
+skynder seg av fjøset!
+Geitebukken fore,
+opp igjennom går'e:
+Killingene leker,
+alle sammen breker:
+Mæ-æ-æ-æ-æ-æ-æ-æ-æ-æ-æ-æ!
+
+Viltert vinden tuter om tinden,
+snøen, den skinner på høyeste topp
+men i hellet, nedover fjellet
+vokser de vakreste blomster opp.
+
diff --git a/_posts/2010-02-23-tuppen-og-lillemor.textile b/_posts/2010-02-23-tuppen-og-lillemor.textile
new file mode 100644
index 0000000..f6529c6
--- /dev/null
+++ b/_posts/2010-02-23-tuppen-og-lillemor.textile
@@ -0,0 +1,41 @@
+---
+layout: song
+title: Tuppen og Lillemor
+---
+Tuppen og Lillemor bor gård i gård;
+begge har øyne blå, lysegult hår,
+sløyfer i flettene, sløyfer på sko,
+forkle med lomme på har de begge to.
+
+Hjem i fra skolen pent hånd i hånd
+daglig de knytter "evig vennskaps bånd".
+Men plutselig en dag kom de opp å slåss,
+"Nå får du aldri mere komme hjem til oss!
+
+Du få'kke leke mer i våres gård!
+Jeg er'kke venner med deg mer.
+Jeg skal skli på kjeller-lemmen,
+mens du står utenfor og ser.
+Du får'ke klyve mer i våres trær
+for jeg er'ke glad i deg!
+Du får'ke leke mer i våres gård,
+når du er så slem mot meg."
+
+Veien til skolen var fryktelig lang
+da de gikk hver sin vei for første gang.
+Time på time gikk - ikke et ord!
+Begge var på gråten. Sorgen var så stor.
+Men i det siste store frikvarter
+kan ikke Lillemor greie det mer.
+"Tuppen! Jeg angrer så på det du vet.
+La oss være venner i all evighet.
+
+Kom å bli med bort i våres gård!
+Vær'ke sinna på meg mer!
+Vi skal skli på kjellerlemmen,
+mens de andre står og ser.
+Du kan gjerne klyve i våres trær.
+Det skal bare du og jeg.
+Kom og bli med bort i våres gård,
+for jeg er så glad i deg!"
+
|
tormaroe/barnesang.com
|
c200f976b228e3d6a53651bed06edf8b94612e95
|
After patching glynn I now added real glynn config settings and a rake task for publishing.
|
diff --git a/_config.yml b/_config.yml
index d995415..e8e7e70 100644
--- a/_config.yml
+++ b/_config.yml
@@ -1,7 +1,7 @@
auto: false
server: false
permalink: /:title.html
exclude: README.markdown, rakefile
ftp_host: ftp.kjempekjekt.com
-ftp_dir: /barnesang.com/glynn
+ftp_dir: /barnesang.com
diff --git a/rakefile b/rakefile
index 242f90f..1412630 100644
--- a/rakefile
+++ b/rakefile
@@ -1,14 +1,18 @@
task :default => [
:clean,
:generate
] do
end
+task :pub do
+ sh "glynn"
+end
+
task :generate do
sh "jekyll --auto --server"
end
task :clean do
sh 'del /S /Q _site\*'
end
|
tormaroe/barnesang.com
|
db4386e2ddb769fa575ec8f0876bae16b5acbe95
|
One more song..
|
diff --git a/_posts/2010-02-11-tulla.textile b/_posts/2010-02-11-tulla.textile
new file mode 100644
index 0000000..425e47f
--- /dev/null
+++ b/_posts/2010-02-11-tulla.textile
@@ -0,0 +1,34 @@
+---
+layout: song
+title: Tulla
+---
+Vi har en tulle med øyne blå
+med silkehår og med ører små
+og midt i fjeset
+en liten nese
+så stor som så -
+
+Så bløt som fløyel er hennes kinn
+og hun er deilig og tykk og trinn
+med dukkehender
+og to små tenner
+i munnen sin
+
+Og hun kan bite i sine tær
+og hun kan danse foruten klær
+og hun kan spise
+og stå og vise
+hvor stor hun er
+
+Og tulla rusker i pappas hår
+og ler og vinker til den som går
+og baker kake
+og lar oss smake
+på alt hun får
+
+I baljen plasker hun, kan du tro!
+Vi hører aldri hun skriker nó
+Nei, jamen skulle
+du se vår tulle
+hvor hun er god!
+
|
tormaroe/barnesang.com
|
055f17a125379504889bf9d0d91bf90f2fa6f5d7
|
Four new songs added
|
diff --git a/_posts/2010-02-11-lua-av.textile b/_posts/2010-02-11-lua-av.textile
new file mode 100644
index 0000000..63cb7ea
--- /dev/null
+++ b/_posts/2010-02-11-lua-av.textile
@@ -0,0 +1,18 @@
+---
+layout: song
+title: Lua av
+---
+Nei, nei gutt,
+dette må bli slutt!
+Ikke storme inn i stua
+før du har fått av deg lua!
+Glemte du det rent?
+Det var ikke pent.
+
+Husk å ta
+alltid lua a'!
+Ikke kast den, ikke sleng den,
+pent og rett på knaggen heng den!
+Tørk av foten din
+og gå stille inn.
+
diff --git a/_posts/2010-02-11-ole-lukkeoye.textile b/_posts/2010-02-11-ole-lukkeoye.textile
new file mode 100644
index 0000000..87e4103
--- /dev/null
+++ b/_posts/2010-02-11-ole-lukkeoye.textile
@@ -0,0 +1,44 @@
+---
+layout: song
+title: Ole Lukkeøye
+---
+Lillemanns dag er slutt
+leken er nu forbi,
+kinnet er hett og øye matt.
+"Mor" tror du jeg får besøk i natt?
+Har jeg vært snill hele dagen i dag?
+Det er ikke så greit må du tro.
+Si til Lukkeøye at jeg har vært snill,
+Du kan, kjære mor, om du vil!
+
+Tror du Ole Lukkeøye kommer nu?
+Jeg har lagt meg nu og venter, kjære du.
+Mine hender har jeg vasket, aftenbønnen har jeg bedt,
+og jeg kjenner nu at jeg er ganske trett.
+Send den drømmen som jeg drømte i går natt,
+jeg var stor,jeg var pol`ti og sto på vakt.
+Guttene de var så redden, tok av lua si for meg.
+Det var så moro, ja, den drømmen likte jeg!
+
+Mamma, når jeg blir stor,
+Større enn du tror-
+skal jeg kjøre bil og ride på hest
+og i Holmenkollen skal jeg bli best.
+En blå uniform og et fint gevær,
+på buksene mine revær,
+ska` jeg ha når jeg går foran slottet i takt
+med kongens garde på vakt.
+Refr.:
+Tror du Ole Lukkeøye......
+
+Snart har han sovnet inn-
+god og varm om kinn.
+Mor sitter stille- hun smiler ømt.
+"Sov, lillemann, og drøm så skjønt!"
+Nei, det er ikke så greit, lille gutten min,
+å være liten som du,
+men sov du godt, for når du blir stor,
+er verden større enn du tror.
+Refr.:
+Tror du Ole Lukkeøye.....
+
diff --git a/_posts/2010-02-11-so-ro-lillemann.textile b/_posts/2010-02-11-so-ro-lillemann.textile
new file mode 100644
index 0000000..70b3246
--- /dev/null
+++ b/_posts/2010-02-11-so-ro-lillemann.textile
@@ -0,0 +1,10 @@
+---
+layout: song
+title: So ro Lillemann
+---
+So ro lillemann, nå er dagen over.
+Alle mus i alle land ligger nå å sover.
+So og ro og tipp på tå,
+sov min vesle pode.
+Reven sover også nå med halen under hodet
+
diff --git a/_posts/2010-02-11-undulatsangen.textile b/_posts/2010-02-11-undulatsangen.textile
new file mode 100644
index 0000000..dfd890b
--- /dev/null
+++ b/_posts/2010-02-11-undulatsangen.textile
@@ -0,0 +1,14 @@
+---
+layout: song
+title: Undulatsangen
+---
+Jeg er en liten undulat
+som får så dårlig med mat
+for de jeg bor hos, ja de jeg bor hos
+er så gjerrig.
+
+De gir meg sild hver eneste dag,
+men sild vil jeg ikke ha.
+Nei, jeg vil heller, ja mye heller
+ha Coca Cola og is.
+
|
tormaroe/barnesang.com
|
ebcd65b9f49f34bac386f83970e1f4b69fbfafb6
|
Fixed bug in sitemap
|
diff --git a/sitemap.xml b/sitemap.xml
index 98867d3..b18fb36 100644
--- a/sitemap.xml
+++ b/sitemap.xml
@@ -1,21 +1,21 @@
---
rooturi: http://barnesang.com
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://barnesang.com/</loc>
<lastmod>{{ site.time | date: '%Y-%m-%d' }}</lastmod>
<changefreq>weekly</changefreq>
<priority>1</priority>
</url>
{% for post in site.posts %}
<url>
- <loc>{{ page.rooturl }}{{ post.url }}</loc>
+ <loc>{{ page.rooturi }}{{ post.url }}</loc>
<lastmod>{{ site.time | date: '%Y-%m-%d' }}</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
{% endfor %}
</urlset>
|
tormaroe/barnesang.com
|
1168f32f91a283ed0932f79baa40fe007ef7b680
|
Added sitemap
|
diff --git a/sitemap.xml b/sitemap.xml
new file mode 100644
index 0000000..98867d3
--- /dev/null
+++ b/sitemap.xml
@@ -0,0 +1,21 @@
+---
+rooturi: http://barnesang.com
+---
+<?xml version="1.0" encoding="UTF-8"?>
+<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
+ <url>
+ <loc>http://barnesang.com/</loc>
+ <lastmod>{{ site.time | date: '%Y-%m-%d' }}</lastmod>
+ <changefreq>weekly</changefreq>
+ <priority>1</priority>
+ </url>
+{% for post in site.posts %}
+ <url>
+ <loc>{{ page.rooturl }}{{ post.url }}</loc>
+ <lastmod>{{ site.time | date: '%Y-%m-%d' }}</lastmod>
+ <changefreq>weekly</changefreq>
+ <priority>0.8</priority>
+ </url>
+{% endfor %}
+</urlset>
+
|
tormaroe/barnesang.com
|
fdd2394aad545f940b0f4eee0a83844beb067f12
|
Added three more songs
|
diff --git a/_posts/2010-02-11-aftensang-om-varen.textile b/_posts/2010-02-11-aftensang-om-varen.textile
new file mode 100644
index 0000000..51d07ca
--- /dev/null
+++ b/_posts/2010-02-11-aftensang-om-varen.textile
@@ -0,0 +1,30 @@
+---
+layout: song
+title: Aftensang om våren
+---
+Det var en deilig, deilig dag,
+men tenk nå er den over,
+og alle som er riktig snill`,
+de ligger nå og sover.
+Og himlen som var blid og
+blå med mange tusen smil i,
+begynner først å le igjen
+en gang i morgen tidlig.
+
+Og ingen knopper gresser mer
+på luftens solblå enge,
+de ble så trette stakkars små,
+nå skal de sove lenge.
+Og alle hvite, søte lam,
+de ligger på en låve
+og slikker på en liten bror.
+Og hyss, nå skal de sove.
+
+Det var en deilig, deilig dag,
+men tenk nå er den over,
+og alle som er riktig snill`,
+de ligger nå og sover.
+Og alle stjerner blir så glad`,
+for alle stjerner liker
+en knopp i blund, et lam i ro
+og sovende småpiker!
diff --git a/_posts/2010-02-11-bro-bro-brille.textile b/_posts/2010-02-11-bro-bro-brille.textile
new file mode 100644
index 0000000..47724e1
--- /dev/null
+++ b/_posts/2010-02-11-bro-bro-brille.textile
@@ -0,0 +1,13 @@
+---
+layout: song
+title: Bro, bro, brille
+---
+Bro, bro, brille!
+Klokken ringer elve!
+Keiseren står på sitt høyeste slott,
+så hvit som en and,
+så sort som en brann.
+Fare, fare krigsmann!
+Døden skal du lide.
+Den som kommer aller sist,
+skal i den sorte gryte.
diff --git a/_posts/2010-02-11-trollmors-voggesang.textile b/_posts/2010-02-11-trollmors-voggesang.textile
new file mode 100644
index 0000000..05b9ed3
--- /dev/null
+++ b/_posts/2010-02-11-trollmors-voggesang.textile
@@ -0,0 +1,12 @@
+---
+layout: song
+title: Trollmors voggesang
+---
+Når trollmor har lagt sine elleve små troll
+og bundet dem fast i halen,
+da synger hun stille for elleve små troll
+de vakreste ord hun kjenner.
+Ho aj aj aj aj buff,
+ho aj aj aj aj buff,
+ho aj aj aj aj buff buff!
+Ho aj aj aj aj buff.
|
tormaroe/barnesang.com
|
fe136158904d95a7c9f714232e7da454117db7b1
|
Added left side adsense skyscraper to song layout. Made h1 for song name smaller. Fixed small utf8 problem in "snømannen kalle".
|
diff --git a/_includes/adsense_160_300.html b/_includes/adsense_160_300.html
new file mode 100644
index 0000000..fec0888
--- /dev/null
+++ b/_includes/adsense_160_300.html
@@ -0,0 +1,11 @@
+<script type="text/javascript"><!--
+google_ad_client = "pub-6812526941304237";
+/* 160x600, barnesang.com */
+google_ad_slot = "5426786901";
+google_ad_width = 160;
+google_ad_height = 600;
+//-->
+</script>
+<script type="text/javascript"
+src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
+</script>
diff --git a/_layouts/song.html b/_layouts/song.html
index aeede28..aa7c546 100644
--- a/_layouts/song.html
+++ b/_layouts/song.html
@@ -1,7 +1,14 @@
---
layout: default
---
-<h1 class="title">{{page.title}}</h1>
+<table border="0" width="100%">
+ <tr>
+ <td valign="top" style="width:200px;">{% include adsense_160_300.html %}</td>
+ <td valign="top">
+ <h1 class="title">{{page.title}}</h1>
<div class="entry">
- <div style="padding-left:25px;">{{ content }}</div>
+ {{ content }}
</div>
+ </td>
+ </tr>
+</table>
diff --git a/_posts/2010-02-09-snomannen-kalle.textile b/_posts/2010-02-09-snomannen-kalle.textile
index 7ba7930..a0351a2 100644
--- a/_posts/2010-02-09-snomannen-kalle.textile
+++ b/_posts/2010-02-09-snomannen-kalle.textile
@@ -1,51 +1,51 @@
---
layout: song
title: Snømannen Kalle
---
Snømannen Kalle
var så grei og god som gull.
Tenk at nesen hans var en gulerot,
begge øynene av kull.
Snømannen Kalle
var av is og sne og vann.
Men det sies at en vinternatt
ble det liv i Kallemann.
Det må ha vært litt trolldom
i den flosshatten han fikk,
for tidlig neste morgen
så var Kalle ute og gikk.
Snømannen Kalle
var det liv i, kan du tro.
Alle barna så at han kunne gå
og han vinket litt og lo.
Snømannen Kalle,
kjente solen som en brann.
Og han sa som så:
"La oss leke nå
før jeg smelter bort som vann"
Ute i gaten med et kosteskaft i hand
løp han ut og inn
som en virvelvind,
ropte "Ta meg om du kan"
-Så fôr han rundt omkring i byn
+Så fôr han rundt omkring i by'n
og stanset aldri opp.
Han bare sto et øyeblikk
da konstabelen ropte: Stopp!
For snømannen Kalle
måtte skynde seg avsted,
så han sa: "Farvel,
jeg må dra i kveld,
jeg må fly som bare det."
Dumpedi-dump-dump
Dumpedi-dump-dump
Kalle går og går
Dumpedi-dump-dump
Dumpedi-dump-dump
Velkommen neste år!
diff --git a/default.css b/default.css
index 07d5aba..85039ec 100644
--- a/default.css
+++ b/default.css
@@ -1,350 +1,350 @@
/*
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
*/
body {
margin: 100px 0 0 0;
padding: 0;
background: #FFFFFF url(images/img01.gif) repeat-x;
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
color: #333333;
}
h1, h2, h3 {
margin: 0;
text-transform: lowercase;
font-weight: normal;
color: #3E3E3E;
}
h1 {
- font-size: 32px;
+ font-size: 23px;
}
h2 {
font-size: 23px;
}
p, ul, ol {
margin: 0 0 2em 0;
text-align: justify;
line-height: 26px;
}
a:link {
color: #7BAA0F;
}
a:hover, a:active {
text-decoration: none;
color: #003448;
}
a:visited {
color: #333333;
}
img {
border: none;
}
img.left {
float: left;
margin-right: 15px;
}
img.right {
float: right;
margin-left: 15px;
}
/* Form */
form {
margin: 0;
padding: 0;
}
fieldset {
margin: 0;
padding: 0;
border: none;
}
legend {
display: none;
}
input, textarea, select {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 13px;
color: #333333;
}
/* Header */
#header {
width: 850px;
height: 82px;
margin: 0 auto 40px auto;
background: url(images/img03.gif) repeat-x left bottom;
}
#logo {
float: left;
height:50px;
background: url(images/bearbox.png) no-repeat;
padding-left:60px;
}
#logo h1 {
font-size: 38px;
color: #494949;
}
#logo h1 sup {
vertical-align: text-top;
font-size: 24px;
}
#logo h1 a {
color: #494949;
}
#logo h2 {
margin-top: -10px;
font-size: 12px;
color: #A0A0A0;
}
#logo a {
text-decoration: none;
}
/* Menu */
#menu {
float: right;
}
#menu ul {
margin: 0;
padding: 15px 0 0 0;
list-style: none;
}
#menu li {
display: inline;
}
#menu a {
display: block;
float: left;
margin-left: 30px;
padding: 7px;
text-decoration: none;
font-size: 13px;
color: #000000;
}
#menu a:hover {
text-decoration: underline;
}
#menu .active a {
background: url(images/img02.gif) repeat-x left bottom;
}
/* Page */
#page {
width: 850px;
margin: 0 auto;
}
/* Content */
#content {
float: left;
width: 575px;
}
/* Post */
.post {
}
.post .title {
margin-bottom: 20px;
padding-bottom: 5px;
background: url(images/img03.gif) repeat-x left bottom;
}
.post .entry {
}
.post .meta {
padding: 15px 0 60px 0;
background: url(images/img03.gif) repeat-x;
}
.post .meta p {
margin: 0;
line-height: normal;
color: #999999;
}
.post .meta .byline {
float: left;
}
.post .meta .links {
float: right;
}
.post .meta .more {
padding: 0 20px 0 18px;
background: url(images/img06.gif) no-repeat left center;
}
.post .meta .comments {
padding-left: 22px;
background: url(images/img07.gif) no-repeat left center;
}
.post .meta b {
display: none;
}
/* Sidebar */
#sidebar {
float: right;
width: 195px;
}
#sidebar ul {
margin: 0;
padding: 0;
list-style: none;
}
#sidebar li {
margin-bottom: 40px;
}
#sidebar li ul {
}
#sidebar li li {
margin: 0;
}
#sidebar h2 {
margin-bottom: 10px;
background: url(images/img03.gif) repeat-x left bottom;
font-size: 16px;
}
/* Search */
#search {
}
#search h2 {
margin-bottom: 20px;
}
#s {
width: 120px;
margin-right: 5px;
padding: 3px;
border: 1px solid #F0F0F0;
}
#x {
padding: 3px;
background: #ECECEC url(images/img08.gif) repeat-x left bottom;
border: none;
text-transform: lowercase;
font-size: 11px;
color: #4F4F4F;
}
/* Boxes */
.box1 {
padding: 20px;
background: url(images/img05.gif) no-repeat;
}
.box2 {
color: #BABABA;
}
.box2 h2 {
margin-bottom: 15px;
background: url(images/img10.gif) repeat-x left bottom;
font-size: 16px;
color: #FFFFFF;
}
.box2 ul {
margin: 0;
padding: 0;
list-style: none;
}
.box2 a:link, .box2 a:hover, .box2 a:active, .box2 a:visited {
color: #EDEDED;
}
/* Footer */
#footer {
height: 400px;
min-height: 400px;
padding: 130px 0 0 0;
background: #003448 url(images/img09.gif) repeat-x;
}
html>body #footer {
height: auto;
}
#footer .wrap {
width: 850px;
margin: 0 auto;
}
#legal {
clear: both;
padding-top: 20px;
text-align: center;
color: #375C69;
}
#legal a {
color: #476B77;
}
#fbox1, #fbox2, #fbox3 {
float: left;
}
#fbox1 {
width: 310px;
}
#fbox2 {
width: 200px;
padding-left: 70px;
}
#fbox3 {
width: 200px;
padding-left: 70px;
}
|
tormaroe/barnesang.com
|
b9fbe6172a7a3961d3f7e3743b86077fad1a96d2
|
Added google site verification meta tag
|
diff --git a/_layouts/default.html b/_layouts/default.html
index edf6a09..f07b8d5 100644
--- a/_layouts/default.html
+++ b/_layouts/default.html
@@ -1,102 +1,103 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>{{page.title}}</title>
<meta name="keywords" content="barnesanger, text" />
<meta name="description" content="Teksten til alle barnesangene du har lyst til å synge for barna dine finner du på barnesang.com" />
+<meta name="google-site-verification" content="dOKE_95xElTnoc_oI0xiTqm9eWlSi7Em-73EdmCQJyI" />
<link href="default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!-- start header -->
<div id="header">
<div id="logo">
<h1><a href="http://barnesang.com/">Barnesang.com</a></h1>
<h2>Sanger som gjør barn glade</h2>
</div>
<div id="menu">
<ul>
<li class="active"><a href="index.html">alle sangene</a></li>
<!--li><a href="#">alle sanger</a></li>
<li><a href="#">Om barnesang.com</a></li>
<li><a href="#">lenker</a></li-->
</ul>
</div>
</div>
<!-- end header -->
<!-- start page -->
<div id="page">
<!-- start content -->
<div id="content">
<div class="post">
{{ content }}
</div>
</div>
<!-- end content -->
<!-- start sidebar -->
<div id="sidebar">
<ul>
<li id="search">
<h2><b>Søk</b> etter en sang</h2>
<!--form method="get" action="http://www.google.no/search?">
<fieldset>
<input type="text" id="as_q" name="as_q" value="" />
<input type="hidden" id="as_sitesearch" name="as_sitesearch" value="barnesang.com" />
<input type="submit" id="x" value="Søk" />
</fieldset>
</form-->
{% include searchbox.html %}
</li>
</ul>
<ul>
<li>{% include adsense_180_150.html %}</li>
</ul>
</div>
<!-- end sidebar -->
<div style="clear: both;"> </div>
</div>
<!-- end page -->
<!-- start footer -->
<div id="footer">
<div class="wrap">
<div id="fbox1" class="box2">
<h2><b>Om</b> barnesang.com</h2>
<p>Barnesang.com gir deg teksten på tradisjonelle barnesanger som du selv vokste opp med, og som du ønsker å videreføre til dine barn. Spørsmål og andre henvendelser kan rettes til <a href="mailto:[email protected]">[email protected]</a>.</p>
</div>
<div id="fbox2" class="box2">
<h2><b>Utvalgte</b> sanger</h2>
<ul>
{% unless site.related_posts %}
{% for post in site.posts limit:5 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
{% endunless %}
{% for post in site.related_posts limit:5 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
</div>
<div id="fbox3" class="box2">
<h2><b>Mest</b> populære</h2>
<ul>
{% unless site.related_posts %}
{% for post in site.posts limit:5 offset:5 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
{% endunless %}
{% for post in site.related_posts limit:5 offset:5 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
</div>
</div>
<p id="legal">(c) 2010 Barnesang.com. Design by <a href="http://www.nodethirtythree.com/">NodeThirtyThree</a> and <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p>
</div>
<!-- end footer -->
{% include analytics.html %}
</body>
</html>
|
tormaroe/barnesang.com
|
e656fb4600c4441df2c508bd58c6dca97364735a
|
Added google search box for site search. Now google only need to re-crawl the site....
|
diff --git a/_includes/searchbox.html b/_includes/searchbox.html
new file mode 100644
index 0000000..c35eaaa
--- /dev/null
+++ b/_includes/searchbox.html
@@ -0,0 +1,21 @@
+<style type="text/css">
+@import url(http://www.google.com/cse/api/branding.css);
+</style>
+<div class="cse-branding-bottom" style="background-color:#FFFFFF;color:#000000">
+ <div class="cse-branding-form">
+ <form action="http://www.google.no/cse" id="cse-search-box">
+ <div>
+ <input type="hidden" name="cx" value="partner-pub-6812526941304237:w0o2lo-qpot" />
+ <input type="hidden" name="ie" value="ISO-8859-1" />
+ <input type="text" name="q" size="20" />
+ <input type="submit" name="sa" value="Søk" />
+ </div>
+ </form>
+ </div>
+ <div class="cse-branding-logo">
+ <img src="http://www.google.com/images/poweredby_transparent/poweredby_FFFFFF.gif" alt="Google" />
+ </div>
+ <div class="cse-branding-text">
+ Tilpasset søk
+ </div>
+</div>
diff --git a/_layouts/default.html b/_layouts/default.html
index 2a479c6..edf6a09 100644
--- a/_layouts/default.html
+++ b/_layouts/default.html
@@ -1,101 +1,102 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>{{page.title}}</title>
<meta name="keywords" content="barnesanger, text" />
<meta name="description" content="Teksten til alle barnesangene du har lyst til å synge for barna dine finner du på barnesang.com" />
<link href="default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!-- start header -->
<div id="header">
<div id="logo">
<h1><a href="http://barnesang.com/">Barnesang.com</a></h1>
<h2>Sanger som gjør barn glade</h2>
</div>
<div id="menu">
<ul>
<li class="active"><a href="index.html">alle sangene</a></li>
<!--li><a href="#">alle sanger</a></li>
<li><a href="#">Om barnesang.com</a></li>
<li><a href="#">lenker</a></li-->
</ul>
</div>
</div>
<!-- end header -->
<!-- start page -->
<div id="page">
<!-- start content -->
<div id="content">
<div class="post">
{{ content }}
</div>
</div>
<!-- end content -->
<!-- start sidebar -->
<div id="sidebar">
<ul>
<li id="search">
<h2><b>Søk</b> etter en sang</h2>
- <form method="get" action="http://www.google.no/search?">
+ <!--form method="get" action="http://www.google.no/search?">
<fieldset>
<input type="text" id="as_q" name="as_q" value="" />
<input type="hidden" id="as_sitesearch" name="as_sitesearch" value="barnesang.com" />
<input type="submit" id="x" value="Søk" />
</fieldset>
- </form>
+ </form-->
+ {% include searchbox.html %}
</li>
</ul>
<ul>
<li>{% include adsense_180_150.html %}</li>
</ul>
</div>
<!-- end sidebar -->
<div style="clear: both;"> </div>
</div>
<!-- end page -->
<!-- start footer -->
<div id="footer">
<div class="wrap">
<div id="fbox1" class="box2">
<h2><b>Om</b> barnesang.com</h2>
<p>Barnesang.com gir deg teksten på tradisjonelle barnesanger som du selv vokste opp med, og som du ønsker å videreføre til dine barn. Spørsmål og andre henvendelser kan rettes til <a href="mailto:[email protected]">[email protected]</a>.</p>
</div>
<div id="fbox2" class="box2">
<h2><b>Utvalgte</b> sanger</h2>
<ul>
{% unless site.related_posts %}
{% for post in site.posts limit:5 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
{% endunless %}
{% for post in site.related_posts limit:5 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
</div>
<div id="fbox3" class="box2">
<h2><b>Mest</b> populære</h2>
<ul>
{% unless site.related_posts %}
{% for post in site.posts limit:5 offset:5 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
{% endunless %}
{% for post in site.related_posts limit:5 offset:5 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
</div>
</div>
<p id="legal">(c) 2010 Barnesang.com. Design by <a href="http://www.nodethirtythree.com/">NodeThirtyThree</a> and <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p>
</div>
<!-- end footer -->
{% include analytics.html %}
</body>
</html>
|
tormaroe/barnesang.com
|
af5d11637566377acaff6c8d4b8dad29a7f4de96
|
Added box from design to index ingress
|
diff --git a/index.html b/index.html
index da09744..8f6b25c 100644
--- a/index.html
+++ b/index.html
@@ -1,12 +1,15 @@
---
layout: default
title: barnesang.com
---
+<div class="box1">
+ <p>
Her finner du tekstene til barnesangene vi alle er så glad i. Vi har begynt i det små, men flere tekster kommer snart.
-
+</p>
+</div>
<div style="margin-top:20px;">
{% for post in site.posts %}
<a href="{{ post.url }}">{{ post.title }}</a> |
{% endfor %}
</div>
|
tormaroe/barnesang.com
|
a2c3226b4e06f8a8569eaaaadc9c93f67b0335b7
|
Added AdSense box (right side). Also added statis keywords and description (meta).
|
diff --git a/_includes/adsense_180_150.html b/_includes/adsense_180_150.html
new file mode 100644
index 0000000..bbd3c1f
--- /dev/null
+++ b/_includes/adsense_180_150.html
@@ -0,0 +1,12 @@
+<script type="text/javascript"><!--
+google_ad_client = "pub-6812526941304237";
+/* 180x150, barnesang.com */
+google_ad_slot = "7493612318";
+google_ad_width = 180;
+google_ad_height = 150;
+//-->
+</script>
+<script type="text/javascript"
+src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
+</script>
+
diff --git a/_layouts/default.html b/_layouts/default.html
index 8c9dd9b..2a479c6 100644
--- a/_layouts/default.html
+++ b/_layouts/default.html
@@ -1,98 +1,101 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>{{page.title}}</title>
-<meta name="keywords" content="" />
-<meta name="description" content="" />
+<meta name="keywords" content="barnesanger, text" />
+<meta name="description" content="Teksten til alle barnesangene du har lyst til å synge for barna dine finner du på barnesang.com" />
<link href="default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!-- start header -->
<div id="header">
<div id="logo">
<h1><a href="http://barnesang.com/">Barnesang.com</a></h1>
<h2>Sanger som gjør barn glade</h2>
</div>
<div id="menu">
<ul>
<li class="active"><a href="index.html">alle sangene</a></li>
<!--li><a href="#">alle sanger</a></li>
<li><a href="#">Om barnesang.com</a></li>
<li><a href="#">lenker</a></li-->
</ul>
</div>
</div>
<!-- end header -->
<!-- start page -->
<div id="page">
<!-- start content -->
<div id="content">
<div class="post">
{{ content }}
</div>
</div>
<!-- end content -->
<!-- start sidebar -->
<div id="sidebar">
<ul>
<li id="search">
<h2><b>Søk</b> etter en sang</h2>
<form method="get" action="http://www.google.no/search?">
<fieldset>
<input type="text" id="as_q" name="as_q" value="" />
<input type="hidden" id="as_sitesearch" name="as_sitesearch" value="barnesang.com" />
<input type="submit" id="x" value="Søk" />
</fieldset>
</form>
</li>
</ul>
+ <ul>
+ <li>{% include adsense_180_150.html %}</li>
+ </ul>
</div>
<!-- end sidebar -->
<div style="clear: both;"> </div>
</div>
<!-- end page -->
<!-- start footer -->
<div id="footer">
<div class="wrap">
<div id="fbox1" class="box2">
<h2><b>Om</b> barnesang.com</h2>
<p>Barnesang.com gir deg teksten på tradisjonelle barnesanger som du selv vokste opp med, og som du ønsker å videreføre til dine barn. Spørsmål og andre henvendelser kan rettes til <a href="mailto:[email protected]">[email protected]</a>.</p>
</div>
<div id="fbox2" class="box2">
<h2><b>Utvalgte</b> sanger</h2>
<ul>
{% unless site.related_posts %}
{% for post in site.posts limit:5 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
{% endunless %}
{% for post in site.related_posts limit:5 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
</div>
<div id="fbox3" class="box2">
<h2><b>Mest</b> populære</h2>
<ul>
{% unless site.related_posts %}
{% for post in site.posts limit:5 offset:5 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
{% endunless %}
{% for post in site.related_posts limit:5 offset:5 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
</div>
</div>
<p id="legal">(c) 2010 Barnesang.com. Design by <a href="http://www.nodethirtythree.com/">NodeThirtyThree</a> and <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p>
</div>
<!-- end footer -->
{% include analytics.html %}
</body>
</html>
|
tormaroe/barnesang.com
|
ea27df31c60d52c191c9a644e37544c7e9018918
|
Added google analytics script
|
diff --git a/_includes/analytics.html b/_includes/analytics.html
index e69de29..b142f29 100644
--- a/_includes/analytics.html
+++ b/_includes/analytics.html
@@ -0,0 +1,14 @@
+<script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-8131610-3']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script');
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ ga.setAttribute('async', 'true');
+ document.documentElement.firstChild.appendChild(ga);
+ })();
+
+</script>
diff --git a/_layouts/default.html b/_layouts/default.html
index 47c1645..8c9dd9b 100644
--- a/_layouts/default.html
+++ b/_layouts/default.html
@@ -1,97 +1,98 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>{{page.title}}</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!-- start header -->
<div id="header">
<div id="logo">
<h1><a href="http://barnesang.com/">Barnesang.com</a></h1>
<h2>Sanger som gjør barn glade</h2>
</div>
<div id="menu">
<ul>
<li class="active"><a href="index.html">alle sangene</a></li>
<!--li><a href="#">alle sanger</a></li>
<li><a href="#">Om barnesang.com</a></li>
<li><a href="#">lenker</a></li-->
</ul>
</div>
</div>
<!-- end header -->
<!-- start page -->
<div id="page">
<!-- start content -->
<div id="content">
<div class="post">
{{ content }}
</div>
</div>
<!-- end content -->
<!-- start sidebar -->
<div id="sidebar">
<ul>
<li id="search">
<h2><b>Søk</b> etter en sang</h2>
<form method="get" action="http://www.google.no/search?">
<fieldset>
<input type="text" id="as_q" name="as_q" value="" />
<input type="hidden" id="as_sitesearch" name="as_sitesearch" value="barnesang.com" />
<input type="submit" id="x" value="Søk" />
</fieldset>
</form>
</li>
</ul>
</div>
<!-- end sidebar -->
<div style="clear: both;"> </div>
</div>
<!-- end page -->
<!-- start footer -->
<div id="footer">
<div class="wrap">
<div id="fbox1" class="box2">
<h2><b>Om</b> barnesang.com</h2>
<p>Barnesang.com gir deg teksten på tradisjonelle barnesanger som du selv vokste opp med, og som du ønsker å videreføre til dine barn. Spørsmål og andre henvendelser kan rettes til <a href="mailto:[email protected]">[email protected]</a>.</p>
</div>
<div id="fbox2" class="box2">
<h2><b>Utvalgte</b> sanger</h2>
<ul>
{% unless site.related_posts %}
{% for post in site.posts limit:5 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
{% endunless %}
{% for post in site.related_posts limit:5 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
</div>
<div id="fbox3" class="box2">
<h2><b>Mest</b> populære</h2>
<ul>
{% unless site.related_posts %}
{% for post in site.posts limit:5 offset:5 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
{% endunless %}
{% for post in site.related_posts limit:5 offset:5 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
</div>
</div>
<p id="legal">(c) 2010 Barnesang.com. Design by <a href="http://www.nodethirtythree.com/">NodeThirtyThree</a> and <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p>
</div>
<!-- end footer -->
+{% include analytics.html %}
</body>
</html>
|
tormaroe/barnesang.com
|
5229f0c0ba5595ca8393a6f8d2bed1a1a0815711
|
Layout etc.
|
diff --git a/_layouts/default.html b/_layouts/default.html
index 2fbd282..47c1645 100644
--- a/_layouts/default.html
+++ b/_layouts/default.html
@@ -1,88 +1,97 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>{{page.title}}</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!-- start header -->
<div id="header">
<div id="logo">
<h1><a href="http://barnesang.com/">Barnesang.com</a></h1>
<h2>Sanger som gjør barn glade</h2>
</div>
<div id="menu">
<ul>
- <li class="active"><a href="index.html">hjem</a></li>
+ <li class="active"><a href="index.html">alle sangene</a></li>
<!--li><a href="#">alle sanger</a></li>
<li><a href="#">Om barnesang.com</a></li>
<li><a href="#">lenker</a></li-->
</ul>
</div>
</div>
<!-- end header -->
<!-- start page -->
<div id="page">
<!-- start content -->
<div id="content">
<div class="post">
{{ content }}
</div>
</div>
<!-- end content -->
<!-- start sidebar -->
<div id="sidebar">
<ul>
<li id="search">
<h2><b>Søk</b> etter en sang</h2>
- <form method="get" action="">
+ <form method="get" action="http://www.google.no/search?">
<fieldset>
- <input type="text" id="s" name="s" value="" />
+ <input type="text" id="as_q" name="as_q" value="" />
+ <input type="hidden" id="as_sitesearch" name="as_sitesearch" value="barnesang.com" />
<input type="submit" id="x" value="Søk" />
</fieldset>
</form>
</li>
</ul>
</div>
<!-- end sidebar -->
<div style="clear: both;"> </div>
</div>
<!-- end page -->
<!-- start footer -->
<div id="footer">
<div class="wrap">
<div id="fbox1" class="box2">
- <h2><b>Lorem</b> Ipsum</h2>
- <p>Curabitur tellus. Phasellus tellus <a href="#">turpis iaculis</a> in, faucibus lobortis, posuere in, lorem. Donec a ante. Donec neque purus, adipiscing id <a href="#">eleifend a cursus</a> vel odio. Vivamus varius justo amet porttitor iaculis, ipsum massa aliquet nulla, non elementum mi elit a mauris. In hac habitasse platea.</p>
+ <h2><b>Om</b> barnesang.com</h2>
+ <p>Barnesang.com gir deg teksten på tradisjonelle barnesanger som du selv vokste opp med, og som du ønsker å videreføre til dine barn. Spørsmål og andre henvendelser kan rettes til <a href="mailto:[email protected]">[email protected]</a>.</p>
</div>
<div id="fbox2" class="box2">
- <h2><b>Metus</b> Nonummy</h2>
+ <h2><b>Utvalgte</b> sanger</h2>
<ul>
- <li><a href="#">Magna lacus bibendum mauris</a></li>
- <li><a href="#">Nec metus sed donec</a></li>
- <li><a href="#">Velit semper nisi molestie</a></li>
- <li><a href="#">Consequat sed cursus</a></li>
- <li><a href="#">Eget tempor eget nonummy</a></li>
+ {% unless site.related_posts %}
+ {% for post in site.posts limit:5 %}
+ <li><a href="{{ post.url }}">{{ post.title }}</a></li>
+ {% endfor %}
+ {% endunless %}
+
+ {% for post in site.related_posts limit:5 %}
+ <li><a href="{{ post.url }}">{{ post.title }}</a></li>
+ {% endfor %}
</ul>
</div>
<div id="fbox3" class="box2">
- <h2><b>Metus</b> Nonummy</h2>
+ <h2><b>Mest</b> populære</h2>
<ul>
- <li><a href="#">Magna lacus bibendum mauris</a></li>
- <li><a href="#">Nec metus sed donec</a></li>
- <li><a href="#">Velit semper nisi molestie</a></li>
- <li><a href="#">Consequat sed cursus</a></li>
- <li><a href="#">Eget tempor eget nonummy</a></li>
+ {% unless site.related_posts %}
+ {% for post in site.posts limit:5 offset:5 %}
+ <li><a href="{{ post.url }}">{{ post.title }}</a></li>
+ {% endfor %}
+ {% endunless %}
+
+ {% for post in site.related_posts limit:5 offset:5 %}
+ <li><a href="{{ post.url }}">{{ post.title }}</a></li>
+ {% endfor %}
</ul>
</div>
</div>
<p id="legal">(c) 2010 Barnesang.com. Design by <a href="http://www.nodethirtythree.com/">NodeThirtyThree</a> and <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p>
</div>
<!-- end footer -->
</body>
</html>
diff --git a/_posts/2010-02-09-det-bor-en-baker.textile b/_posts/2010-02-09-det-bor-en-baker.textile
index 7fcee55..5572948 100644
--- a/_posts/2010-02-09-det-bor-en-baker.textile
+++ b/_posts/2010-02-09-det-bor-en-baker.textile
@@ -1,12 +1,12 @@
---
layout: song
title: Det bor en baker
---
-Der bor en baker i Østre Aker
+Der bor en baker i Østre Aker
han baker kringler og julekaker.
Han baker store, han baker små,
han baker noen med sukker på.
Og i hans vindu står rare saker,
tenk, hester, griser og pepperkaker.
Og har du penger, så kan du få,
og har du ikke, så kan du gå.
diff --git a/_posts/2010-02-09-kveldssang-for-blakken.textile b/_posts/2010-02-09-kveldssang-for-blakken.textile
index 859a88f..e76cb4f 100644
--- a/_posts/2010-02-09-kveldssang-for-blakken.textile
+++ b/_posts/2010-02-09-kveldssang-for-blakken.textile
@@ -1,38 +1,38 @@
---
layout: song
title: Kveldssang for Blakken
---
Fola fola Blakken
Nå er Blakken god og trett
Blakken skal bli god og mett
-Å fola fola Blakken
+Å fola fola Blakken
Huff, den leie bakken
Og den lange stygge hei
Den var riktig dryg for deg
Du gamle gamle Blakken
Far han kastet frakken
Blakken kan ei kaste sin
Svetter i det gamle skinn
Den snille snille Blakken
Snart skal Blakken sove
Ikke mer slit i dag
Ikke mer sele-gnag
Og ikke mer tråve
Fola fola Blakken
Går du inn i stallen din
Kommer vesle gutten inn
Og klapper deg på nakken
Ser du gutten smile
Hører du det bud har har
Han skal hilse dig fra far
I morgen skal du hvile
Drøm om det du Blakken
Bare ete bare stå
Kanskje rundt på tunet gå
Med vesle gutt på nakken
diff --git a/default.css b/default.css
index 9811b8c..07d5aba 100644
--- a/default.css
+++ b/default.css
@@ -1,347 +1,350 @@
/*
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
*/
body {
margin: 100px 0 0 0;
padding: 0;
background: #FFFFFF url(images/img01.gif) repeat-x;
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
color: #333333;
}
h1, h2, h3 {
margin: 0;
text-transform: lowercase;
font-weight: normal;
color: #3E3E3E;
}
h1 {
font-size: 32px;
}
h2 {
font-size: 23px;
}
p, ul, ol {
margin: 0 0 2em 0;
text-align: justify;
line-height: 26px;
}
a:link {
color: #7BAA0F;
}
a:hover, a:active {
text-decoration: none;
color: #003448;
}
a:visited {
color: #333333;
}
img {
border: none;
}
img.left {
float: left;
margin-right: 15px;
}
img.right {
float: right;
margin-left: 15px;
}
/* Form */
form {
margin: 0;
padding: 0;
}
fieldset {
margin: 0;
padding: 0;
border: none;
}
legend {
display: none;
}
input, textarea, select {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 13px;
color: #333333;
}
/* Header */
#header {
width: 850px;
height: 82px;
margin: 0 auto 40px auto;
background: url(images/img03.gif) repeat-x left bottom;
}
#logo {
float: left;
+ height:50px;
+ background: url(images/bearbox.png) no-repeat;
+ padding-left:60px;
}
#logo h1 {
font-size: 38px;
color: #494949;
}
#logo h1 sup {
vertical-align: text-top;
font-size: 24px;
}
#logo h1 a {
color: #494949;
}
#logo h2 {
margin-top: -10px;
font-size: 12px;
color: #A0A0A0;
}
#logo a {
text-decoration: none;
}
/* Menu */
#menu {
float: right;
}
#menu ul {
margin: 0;
padding: 15px 0 0 0;
list-style: none;
}
#menu li {
display: inline;
}
#menu a {
display: block;
float: left;
margin-left: 30px;
padding: 7px;
text-decoration: none;
font-size: 13px;
color: #000000;
}
#menu a:hover {
text-decoration: underline;
}
#menu .active a {
background: url(images/img02.gif) repeat-x left bottom;
}
/* Page */
#page {
width: 850px;
margin: 0 auto;
}
/* Content */
#content {
float: left;
width: 575px;
}
/* Post */
.post {
}
.post .title {
margin-bottom: 20px;
padding-bottom: 5px;
background: url(images/img03.gif) repeat-x left bottom;
}
.post .entry {
}
.post .meta {
padding: 15px 0 60px 0;
background: url(images/img03.gif) repeat-x;
}
.post .meta p {
margin: 0;
line-height: normal;
color: #999999;
}
.post .meta .byline {
float: left;
}
.post .meta .links {
float: right;
}
.post .meta .more {
padding: 0 20px 0 18px;
background: url(images/img06.gif) no-repeat left center;
}
.post .meta .comments {
padding-left: 22px;
background: url(images/img07.gif) no-repeat left center;
}
.post .meta b {
display: none;
}
/* Sidebar */
#sidebar {
float: right;
width: 195px;
}
#sidebar ul {
margin: 0;
padding: 0;
list-style: none;
}
#sidebar li {
margin-bottom: 40px;
}
#sidebar li ul {
}
#sidebar li li {
margin: 0;
}
#sidebar h2 {
margin-bottom: 10px;
background: url(images/img03.gif) repeat-x left bottom;
font-size: 16px;
}
/* Search */
#search {
}
#search h2 {
margin-bottom: 20px;
}
#s {
width: 120px;
margin-right: 5px;
padding: 3px;
border: 1px solid #F0F0F0;
}
#x {
padding: 3px;
background: #ECECEC url(images/img08.gif) repeat-x left bottom;
border: none;
text-transform: lowercase;
font-size: 11px;
color: #4F4F4F;
}
/* Boxes */
.box1 {
padding: 20px;
background: url(images/img05.gif) no-repeat;
}
.box2 {
color: #BABABA;
}
.box2 h2 {
margin-bottom: 15px;
background: url(images/img10.gif) repeat-x left bottom;
font-size: 16px;
color: #FFFFFF;
}
.box2 ul {
margin: 0;
padding: 0;
list-style: none;
}
.box2 a:link, .box2 a:hover, .box2 a:active, .box2 a:visited {
color: #EDEDED;
}
/* Footer */
#footer {
height: 400px;
min-height: 400px;
padding: 130px 0 0 0;
background: #003448 url(images/img09.gif) repeat-x;
}
html>body #footer {
height: auto;
}
#footer .wrap {
width: 850px;
margin: 0 auto;
}
#legal {
clear: both;
padding-top: 20px;
text-align: center;
color: #375C69;
}
#legal a {
color: #476B77;
}
#fbox1, #fbox2, #fbox3 {
float: left;
}
#fbox1 {
width: 310px;
}
#fbox2 {
width: 200px;
padding-left: 70px;
}
#fbox3 {
width: 200px;
padding-left: 70px;
}
diff --git a/images/bearbox.png b/images/bearbox.png
new file mode 100644
index 0000000..973b512
Binary files /dev/null and b/images/bearbox.png differ
diff --git a/index.html b/index.html
index 9fbe0b1..da09744 100644
--- a/index.html
+++ b/index.html
@@ -1,9 +1,12 @@
---
layout: default
title: barnesang.com
---
+Her finner du tekstene til barnesangene vi alle er så glad i. Vi har begynt i det små, men flere tekster kommer snart.
+
+<div style="margin-top:20px;">
{% for post in site.posts %}
<a href="{{ post.url }}">{{ post.title }}</a> |
{% endfor %}
-
+</div>
diff --git a/rakefile b/rakefile
index 9cc0834..242f90f 100644
--- a/rakefile
+++ b/rakefile
@@ -1,14 +1,14 @@
task :default => [
:clean,
:generate
] do
end
task :generate do
- sh "jekyll"
+ sh "jekyll --auto --server"
end
task :clean do
sh 'del /S /Q _site\*'
end
|
tormaroe/barnesang.com
|
82e3f5041672b665cc2ad9b9e861716896bc6d6c
|
Added a bunch of songs. Some layout changes.
|
diff --git a/_layouts/default.html b/_layouts/default.html
index bb91f1e..2fbd282 100644
--- a/_layouts/default.html
+++ b/_layouts/default.html
@@ -1,91 +1,88 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>{{page.title}}</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!-- start header -->
<div id="header">
<div id="logo">
<h1><a href="http://barnesang.com/">Barnesang.com</a></h1>
<h2>Sanger som gjør barn glade</h2>
</div>
<div id="menu">
<ul>
- <li class="active"><a href="#">hjem</a></li>
- <li><a href="#">alle sanger</a></li>
+ <li class="active"><a href="index.html">hjem</a></li>
+ <!--li><a href="#">alle sanger</a></li>
<li><a href="#">Om barnesang.com</a></li>
- <li><a href="#">lenker</a></li>
+ <li><a href="#">lenker</a></li-->
</ul>
</div>
</div>
<!-- end header -->
<!-- start page -->
<div id="page">
<!-- start content -->
<div id="content">
<div class="post">
- <h1 class="title">{{page.title}}</h1>
- <div class="entry">
- {{ content }}
- </div>
+ {{ content }}
</div>
</div>
<!-- end content -->
<!-- start sidebar -->
<div id="sidebar">
<ul>
<li id="search">
<h2><b>Søk</b> etter en sang</h2>
<form method="get" action="">
<fieldset>
<input type="text" id="s" name="s" value="" />
<input type="submit" id="x" value="Søk" />
</fieldset>
</form>
</li>
</ul>
</div>
<!-- end sidebar -->
<div style="clear: both;"> </div>
</div>
<!-- end page -->
<!-- start footer -->
<div id="footer">
<div class="wrap">
<div id="fbox1" class="box2">
<h2><b>Lorem</b> Ipsum</h2>
<p>Curabitur tellus. Phasellus tellus <a href="#">turpis iaculis</a> in, faucibus lobortis, posuere in, lorem. Donec a ante. Donec neque purus, adipiscing id <a href="#">eleifend a cursus</a> vel odio. Vivamus varius justo amet porttitor iaculis, ipsum massa aliquet nulla, non elementum mi elit a mauris. In hac habitasse platea.</p>
</div>
<div id="fbox2" class="box2">
<h2><b>Metus</b> Nonummy</h2>
<ul>
<li><a href="#">Magna lacus bibendum mauris</a></li>
<li><a href="#">Nec metus sed donec</a></li>
<li><a href="#">Velit semper nisi molestie</a></li>
<li><a href="#">Consequat sed cursus</a></li>
<li><a href="#">Eget tempor eget nonummy</a></li>
</ul>
</div>
<div id="fbox3" class="box2">
<h2><b>Metus</b> Nonummy</h2>
<ul>
<li><a href="#">Magna lacus bibendum mauris</a></li>
<li><a href="#">Nec metus sed donec</a></li>
<li><a href="#">Velit semper nisi molestie</a></li>
<li><a href="#">Consequat sed cursus</a></li>
<li><a href="#">Eget tempor eget nonummy</a></li>
</ul>
</div>
</div>
- <p id="legal">(c) 2009 Barnesang.com. Design by <a href="http://www.nodethirtythree.com/">NodeThirtyThree</a> and <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p>
+ <p id="legal">(c) 2010 Barnesang.com. Design by <a href="http://www.nodethirtythree.com/">NodeThirtyThree</a> and <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p>
</div>
<!-- end footer -->
</body>
</html>
diff --git a/_layouts/song.html b/_layouts/song.html
index 73dae17..aeede28 100644
--- a/_layouts/song.html
+++ b/_layouts/song.html
@@ -1,4 +1,7 @@
---
layout: default
---
-{{ content }}
+<h1 class="title">{{page.title}}</h1>
+ <div class="entry">
+ <div style="padding-left:25px;">{{ content }}</div>
+ </div>
diff --git a/_posts/2010-02-09-alle-fugler.textile b/_posts/2010-02-09-alle-fugler.textile
new file mode 100644
index 0000000..f36a478
--- /dev/null
+++ b/_posts/2010-02-09-alle-fugler.textile
@@ -0,0 +1,30 @@
+---
+layout: song
+title: Alle fugler
+---
+Alle fugler små de er
+kommet nå tilbake!
+Gjøk og sisik, trost og stær
+synger alle dage.
+Lerker jubler høyt i sky,
+ringer våren inn på ny.
+Frost og snø de måtte fly.
+Her er sol og glede!
+
+Blomster hvite, gule, blå
+titter opp av uren,
+nikker nå så blidt, de små,
+etter vinterluren.
+Skog og mark i grønne skrud
+kler seg nå på Herrens bud.
+Knopper små de springer ut.
+Her er sol og glede!
+
+Lille søster! Lille bror!
+Kom, så skal vi danse!
+Plukke blomster så til mor,
+Mange, mange kranse!
+Synge, tralle dagen lang!
+Kråkestup og bukkesprang! -
+Takk, o Gud, som enn en gang
+gav oss sol og glede!
diff --git a/_posts/2010-02-09-da-lykkeliten-kom-til-verden.textile b/_posts/2010-02-09-da-lykkeliten-kom-til-verden.textile
new file mode 100644
index 0000000..9973314
--- /dev/null
+++ b/_posts/2010-02-09-da-lykkeliten-kom-til-verden.textile
@@ -0,0 +1,48 @@
+---
+layout: song
+title: Da lykkeliten kom til verden
+---
+Da lykkeliten kom til verden,
+var alle himlens stjerner tent.
+De blinket "lykke til på ferden",
+som til en gammel, god bekjent!
+Og sommernatten var så stille,
+men både trær og blomster små,
+de stod og hvisket om den lille,
+som i sin lyse vugge lå.
+
+Slik kom da lille Lykkeliten
+til et av verdens minste land.
+Og skjønte han va'kke store biten,
+så var han dog en liten mann!
+Han hadde mørke, brune øyne
+og håret var så svart som kull.
+Han lå og skrek det første døgnet,
+men han har store smilehull.
+
+Han har så sterke, faste never,
+og slike silkebløte kinn,
+og i en silkeseng han lever,
+der har han også ranglen sin!
+Det er hans verden nå så lenge,
+det aller første år han har,
+og han vil ingen større trenge
+før han det første skrittet tar!
+
+Til livets ære skjer et under
+i alle land hver dag som går,
+ja, i et hvert av de sekund,
+som men'skehetens klokker slår!
+Men ingen vet og ingen kjenner
+den vei ditt lille barn skal gå,
+og ingen vet hva skjebnen sender
+av lyse dager og av grå.
+
+Men Lykkeliten kom til verden,
+og da var alle stjerner tent.
+Det lovet godt for fremtidsferden,
+det var et tegn av skjebnen sendt!
+Og sommernatten var så stille,
+men både trær og blomster små
+de stod og hvisket om den lille,
+som i sin lyse vugge lå.
diff --git a/_posts/2010-02-09-den-fyrste-song.textile b/_posts/2010-02-09-den-fyrste-song.textile
new file mode 100644
index 0000000..a43077e
--- /dev/null
+++ b/_posts/2010-02-09-den-fyrste-song.textile
@@ -0,0 +1,22 @@
+---
+layout: song
+title: Den fyrste song
+---
+Den fyrste song eg høyra fekk,
+var mor sin song ved vogga,
+dei mjuke ord til hjarta gjekk,
+dei kunne gråten stogga.
+Dei sulla meg så underleg,
+så stilt og mjukt te sova,
+dei synte meg ein fager veg
+opp frå vår vesle stova.
+
+Den vegen ser eg enno tidt
+når eg fær auga kvila;
+der stend ein engel, smile blidt,
+som berre ei kan smila.
+
+Og når eg sliten trøynar av
+i strid mot alt som veilar,
+eg høyrer stilt frå mor sin grav
+den song som all ting heilar.
diff --git a/_posts/2010-02-09-det-bor-en-baker.textile b/_posts/2010-02-09-det-bor-en-baker.textile
new file mode 100644
index 0000000..7fcee55
--- /dev/null
+++ b/_posts/2010-02-09-det-bor-en-baker.textile
@@ -0,0 +1,12 @@
+---
+layout: song
+title: Det bor en baker
+---
+Der bor en baker i Østre Aker
+han baker kringler og julekaker.
+Han baker store, han baker små,
+han baker noen med sukker på.
+Og i hans vindu står rare saker,
+tenk, hester, griser og pepperkaker.
+Og har du penger, så kan du få,
+og har du ikke, så kan du gå.
diff --git a/_posts/2010-02-09-floy-en-liten-blafugl.textile b/_posts/2010-02-09-floy-en-liten-blafugl.textile
new file mode 100644
index 0000000..bb8cace
--- /dev/null
+++ b/_posts/2010-02-09-floy-en-liten-blafugl.textile
@@ -0,0 +1,13 @@
+---
+layout: song
+title: Fløy en liten blåfugl
+---
+Fløy en liten blåfugl gjennom vindu
+gjennom vindu, gjennom vindu
+Fløy en liten blåfugl gjennom vindu
+en dag i mai
+
+Tok en liten gullklump, skip skip skare
+skip skip skare, skip skip skare
+Tok en liten gullklump, skip skip skare
+en dag i mai
diff --git a/_posts/2010-02-09-fodselsdag.textile b/_posts/2010-02-09-fodselsdag.textile
new file mode 100644
index 0000000..f9cac10
--- /dev/null
+++ b/_posts/2010-02-09-fodselsdag.textile
@@ -0,0 +1,93 @@
+---
+layout: song
+title: Fødselsdag
+---
+I skogen skulle være fest
+hos Bamsefar i lia,
+for Bamse fyller femti år
+omtrent på denne tia.
+Gamle snille bamsen vår
+fyller femti år i år.
+Hei hurra for Bamsefar,
+som er så snill og rar!
+
+Og ugla fløy fra tre til tre
+og ropte hele natten:
+I morgen skal det være fest
+hos bjørnen klokken atten.
+Bamse bamse bamse bra!
+Fødselsdag skal bamse ha!
+Hei hurra for Bamsefar,
+som er så snill og rar!
+
+Og reven skulle skaffe kjøtt
+og være kokemester
+og bake brød og lage mat
+til femogtjue gjester.
+Det skal nok bli bamselag
+på den store bamsedag!
+Hei hurra for Bamsefar,
+som er så snill og rar!
+
+Og reven dro til bondens gård
+på sine raske føtter
+og hentet åtte høner og
+en sekk med gulerøtter.
+Bamse bamse bamse grå,
+stekemat skal Bamse få.
+Hei hurra for Bamsefar,
+som er så snill og rar!
+
+Og dagen kom med fuglesang,
+det var et helt orkester.
+Og Bamse gikk og hilste pent
+på alle sine gjester.
+Bamsefar, god dag, god dag,
+det er Bamses dag i dag.
+Hei hurra for Bamsefar,
+som er så snill og rar!
+
+Og harepus og frua
+hadde med seg fire krukker,
+og det var blåbærsyltetøy
+med mye deilig sukker.
+Bamse bamse bamse har
+alltid vært en kjernekar.
+Hei hurra for Bamsefar,
+som er så snill og rar!
+
+Av musene fikk Bamsefar
+en kjærlighet på pinne.
+"Den kan du slikke på til vintern
+mens du ligger inne."
+Den skal onkel Bamse ha,
+den vil smake veldig bra.
+Hei hurra for Bamsefar,
+som er så snill og rar!
+
+Den store elgen reiste seg
+og ristet litt på hamsen
+og holdt en vakker tale for
+den snille gamle bamsen:
+"Kjære gamle bamsen vår,
+du er femti år i år.
+Hei hurra for Bamsefar,
+som er så snill og rar!
+
+Og alle dyra klappet for
+den veldig fine talen.
+Og reven gråt en tåre som
+han tørket bort med halen.
+Bamse bamse bamse har
+alltid vært en kjernekar!
+Hei hurra for Bamsefar,
+som er så snill og rar!
+
+Men så sa vesle harepus:
+"Se bamsen våres sover."
+Da skjønte alle dyrene
+at nå var festen over.
+Bamse bamse bamse grå,
+tusen tusen takk for nå!
+Hei hurra for Bamsefar,
+som er så snill og rar!
diff --git a/_posts/2010-02-09-jeg-gikk-en-tur-pa-stien.textile b/_posts/2010-02-09-jeg-gikk-en-tur-pa-stien.textile
new file mode 100644
index 0000000..fa85cbc
--- /dev/null
+++ b/_posts/2010-02-09-jeg-gikk-en-tur-pa-stien.textile
@@ -0,0 +1,35 @@
+---
+layout: song
+title: Jeg gikk en tur på stien
+---
+Jeg gikk en tur på stien
+og søkte skogens ro.
+Da hørte jeg fra lien
+en gjøk som gol koko.
+
+Koko, koko, kokokorokoko
+Koko, koko, kokokorokoko
+
+Jeg spurte den hvor mange,
+hvor mange år ennu.
+Den svarte meg med lange
+og klagende koko.
+
+Koko, koko, kokokorokoko
+Koko, koko, kokokorokoko
+
+Jeg spurte om dens make
+og om dens eget bo.
+Den satt der oppå grenen
+og kikket ned og lo.
+
+Koko, koko, kokokorokoko
+Koko, koko, kokokorokoko
+
+Vi bygger ikke rede,
+vi har hjem, vi to.
+Fru Spurv er mor til barna
+vi galer kun koko
+
+Koko, koko, kokokorokoko
+Koko, koko, kokokorokoko
diff --git a/_posts/2010-02-09-kveldssang-for-blakken.textile b/_posts/2010-02-09-kveldssang-for-blakken.textile
new file mode 100644
index 0000000..859a88f
--- /dev/null
+++ b/_posts/2010-02-09-kveldssang-for-blakken.textile
@@ -0,0 +1,38 @@
+---
+layout: song
+title: Kveldssang for Blakken
+---
+Fola fola Blakken
+Nå er Blakken god og trett
+Blakken skal bli god og mett
+Å fola fola Blakken
+
+Huff, den leie bakken
+Og den lange stygge hei
+Den var riktig dryg for deg
+Du gamle gamle Blakken
+
+Far han kastet frakken
+Blakken kan ei kaste sin
+Svetter i det gamle skinn
+Den snille snille Blakken
+
+Snart skal Blakken sove
+Ikke mer slit i dag
+Ikke mer sele-gnag
+Og ikke mer tråve
+
+Fola fola Blakken
+Går du inn i stallen din
+Kommer vesle gutten inn
+Og klapper deg på nakken
+
+Ser du gutten smile
+Hører du det bud har har
+Han skal hilse dig fra far
+I morgen skal du hvile
+
+Drøm om det du Blakken
+Bare ete bare stå
+Kanskje rundt på tunet gå
+Med vesle gutt på nakken
diff --git a/_posts/2010-02-09-lille-lotte.textile b/_posts/2010-02-09-lille-lotte.textile
index 07cd68c..c9d0369 100644
--- a/_posts/2010-02-09-lille-lotte.textile
+++ b/_posts/2010-02-09-lille-lotte.textile
@@ -1,21 +1,21 @@
---
layout: song
title: Lille Lotte
---
Lille Lotte er så pen
når hun går til skolen.
Hånden den er ganske ren,
ansiktet som solen.
Hun kan si så pent "Goddag"
Neie, det er ingen sak
-Så gjør lille Lotte,
-Så gjør lille Lotte
+Så gjør lille Lotte,
+Så gjør lille Lotte
Lille Hermann er så pen
når han går til skolen.
Hånden den er ganske ren,
ansiktet som solen.
Han kan si så pent "Goddag"
Bukke, det er ingen sak.
-Så gjør lille Hermann,
-Så gjør lille Hermann.
+Så gjør lille Hermann,
+Så gjør lille Hermann.
diff --git a/_posts/2010-02-09-mikkel-rev.textile b/_posts/2010-02-09-mikkel-rev.textile
new file mode 100644
index 0000000..47781a9
--- /dev/null
+++ b/_posts/2010-02-09-mikkel-rev.textile
@@ -0,0 +1,18 @@
+---
+layout: song
+title: Mikkel Rev
+---
+Mikkel Rev, satt og skrev,
+på ei lita tavle
+Tavla sprakk, Mikkel skvatt,
+oppi pappas flosshatt.
+
+Mikkel Rev, skrev et brev
+sendte det til månen
+Månen sa: "Hipp hurra"
+Sendte det til Afrika
+
+Afrika, Afrika
+ville ikke ha det
+Afrika, Afrika
+sendte den tilbake.
diff --git a/_posts/2010-02-09-noen-sover-inne.textile b/_posts/2010-02-09-noen-sover-inne.textile
new file mode 100644
index 0000000..218efe0
--- /dev/null
+++ b/_posts/2010-02-09-noen-sover-inne.textile
@@ -0,0 +1,12 @@
+---
+layout: song
+title: Noen sover inne
+---
+Noen sover inne,
+og noen sover ute,
+høna på en pinne,
+og gutten på en pute,
+fattigmann på låve,
+og kongen i et slott.
+Nå må alle sove,
+og sove riktig godt.
diff --git a/_posts/2010-02-09-ride-ride-ranke.textile b/_posts/2010-02-09-ride-ride-ranke.textile
new file mode 100644
index 0000000..06c8eb7
--- /dev/null
+++ b/_posts/2010-02-09-ride-ride-ranke.textile
@@ -0,0 +1,28 @@
+---
+layout: song
+title: Ride, ride ranke
+---
+Ride, ride ranke!
+Si meg hvor skal veien gå?
+Bestefar besøk skal få.
+Ride, ride ranke!
+
+Ride, ride ranke!
+Og når så vi stiger av,
+sier vi: "Goddag, goddag!"
+Ride, ride ranke!
+
+Ride, ride ranke!
+Bestemor, hun er så snill.
+Vi får leke som vi vil.
+Ride, ride ranke!
+
+Ride, ride ranke!
+Nå til onkel i galopp.
+"Er han hjemme?" Ja! Så stopp!
+Ride, ride ranke!
+
+Ride, ride ranke!
+Nå er hesten ornt`lig trett.
+Rytteren er god og mett.
+Ride, ride ranke!
diff --git a/_posts/2010-02-09-ro-ro-til-fiskeskjaer.textile b/_posts/2010-02-09-ro-ro-til-fiskeskjaer.textile
new file mode 100644
index 0000000..57642b0
--- /dev/null
+++ b/_posts/2010-02-09-ro-ro-til-fiskeskjaer.textile
@@ -0,0 +1,17 @@
+---
+layout: song
+title: Ro, ro til fiskeskjær
+---
+Ro, ro til fiskeskjær
+mange fisker får vi der:
+En til far og en til mor
+en til søster og en til bror
+Og to til den som fisken dro
+og det var vesle ..........
+
+Ro, ro til fiskeskjær
+hva slags fisker får vi der?
+Laksen feit og flyndra brei
+torsken grå og silda små
+og ålen stor og lang som så
+og ålen stor og lang som så
diff --git a/_posts/2010-02-09-se-min-kjole.textile b/_posts/2010-02-09-se-min-kjole.textile
new file mode 100644
index 0000000..695de10
--- /dev/null
+++ b/_posts/2010-02-09-se-min-kjole.textile
@@ -0,0 +1,33 @@
+---
+layout: song
+title: Se min kjole
+---
+Våre kjoler er i alle farger
+Grønn, blå, rød, hvit, sort og mange flere
+Men hør nå bare, hva jeg vil fortelle,
+grønn, blå, rød, hvit, sort og mange flere.
+
+Se min kjole, den er grønn som gresset,
+alt hva jeg eier, det er grønt som den.
+Det er fordi jeg elsker alt det grønne,
+og fordi en jeger er min venn.
+
+Se min kjole, den er blå som havet,
+alt hva jeg eier, det er blått som den.
+Det er fordi jeg elsker alt det blå,
+og fordi en sjømann er min venn.
+
+Se min kjole, den er hvit som sneen,
+alt hva jeg eier, det er hvitt som den.
+Det er fordi jeg elsker at det hvite,
+og fordi en møller er min venn.
+
+Se min kjole, den er rød som rosen,
+alt hva jeg eier, det er rødt som den.
+Det er fordi jeg elsker alt det røde,
+og fordi et postbud er min venn.
+
+Se min kjole, den er sort som kullet,
+alt hva jeg eier, det er sort som den.
+Det er fordi jeg elsker alt det sorte,
+og fordi en feier er min venn.
diff --git a/_posts/2010-02-09-snomannen-kalle.textile b/_posts/2010-02-09-snomannen-kalle.textile
new file mode 100644
index 0000000..7ba7930
--- /dev/null
+++ b/_posts/2010-02-09-snomannen-kalle.textile
@@ -0,0 +1,51 @@
+---
+layout: song
+title: Snømannen Kalle
+---
+Snømannen Kalle
+var så grei og god som gull.
+Tenk at nesen hans var en gulerot,
+begge øynene av kull.
+
+Snømannen Kalle
+var av is og sne og vann.
+Men det sies at en vinternatt
+ble det liv i Kallemann.
+
+Det må ha vært litt trolldom
+i den flosshatten han fikk,
+for tidlig neste morgen
+så var Kalle ute og gikk.
+Snømannen Kalle
+var det liv i, kan du tro.
+Alle barna så at han kunne gå
+og han vinket litt og lo.
+
+Snømannen Kalle,
+kjente solen som en brann.
+Og han sa som så:
+"La oss leke nå
+før jeg smelter bort som vann"
+
+Ute i gaten med et kosteskaft i hand
+løp han ut og inn
+som en virvelvind,
+ropte "Ta meg om du kan"
+
+Så fôr han rundt omkring i byn
+og stanset aldri opp.
+Han bare sto et øyeblikk
+da konstabelen ropte: Stopp!
+
+For snømannen Kalle
+måtte skynde seg avsted,
+så han sa: "Farvel,
+jeg må dra i kveld,
+jeg må fly som bare det."
+
+Dumpedi-dump-dump
+Dumpedi-dump-dump
+Kalle går og går
+Dumpedi-dump-dump
+Dumpedi-dump-dump
+Velkommen neste år!
diff --git a/_posts/2010-02-09-so-ro-liten-tull.textile b/_posts/2010-02-09-so-ro-liten-tull.textile
new file mode 100644
index 0000000..b2d94e0
--- /dev/null
+++ b/_posts/2010-02-09-so-ro-liten-tull.textile
@@ -0,0 +1,10 @@
+---
+layout: song
+title: So ro liten tull
+---
+So ro liten tull,
+gid vi hadde stua full
+ut av slike små unger.
+Stua og koven
+lyua og låven
+og en liten haug utpå gården.
diff --git a/_posts/2010-02-09-tornerose.textile b/_posts/2010-02-09-tornerose.textile
new file mode 100644
index 0000000..0796d3a
--- /dev/null
+++ b/_posts/2010-02-09-tornerose.textile
@@ -0,0 +1,48 @@
+---
+layout: song
+title: Tornerose
+---
+Tornerose var et vakkert barn
+Vakkert barn, vakkert barn
+Tornerose var et vakkert barn,
+vakkert barn
+
+Hun bodde i det høye slott
+Høye slott, høye slott
+Hun bodde i det høye slott,
+høye slott
+
+Så kom den onde fe der inn
+Fe der inn, fe der inn
+Så kom den onde fe der inn,
+fe der inn
+
+Tornerose sov i hundre år
+Hundre år, hundre år
+Tornerose sov i hundre år,
+hundre år
+
+Og hekken vokste kjempehøy
+Kjempehøy, kjempehøy
+Og hekken vokste kjempehøy,
+kjempehøy
+
+Så kom den vakre prins der inn
+Prins der inn, prins der inn
+Så kom den vakre prins der inn,
+prins der inn
+
+Tornerose må ei sove mer
+Ei sove mer, sove mer
+Tornerose må ei sove mer,
+sove mer
+
+Og prinsen danser med sin brud
+Med sin brud med sin brud
+Og prinsen danser med sin brud,
+med sin brud
+
+Og all hjerter gleder seg
+Gleder seg, gleder seg
+Og alle hjerter gleder seg,
+gleder seg
diff --git a/default.css b/default.css
index 6906516..9811b8c 100644
--- a/default.css
+++ b/default.css
@@ -1,347 +1,347 @@
/*
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
*/
body {
margin: 100px 0 0 0;
padding: 0;
background: #FFFFFF url(images/img01.gif) repeat-x;
- font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
+ font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
color: #333333;
}
h1, h2, h3 {
margin: 0;
text-transform: lowercase;
font-weight: normal;
color: #3E3E3E;
}
h1 {
font-size: 32px;
}
h2 {
font-size: 23px;
}
p, ul, ol {
margin: 0 0 2em 0;
text-align: justify;
line-height: 26px;
}
a:link {
color: #7BAA0F;
}
a:hover, a:active {
text-decoration: none;
color: #003448;
}
a:visited {
color: #333333;
}
img {
border: none;
}
img.left {
float: left;
margin-right: 15px;
}
img.right {
float: right;
margin-left: 15px;
}
/* Form */
form {
margin: 0;
padding: 0;
}
fieldset {
margin: 0;
padding: 0;
border: none;
}
legend {
display: none;
}
input, textarea, select {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 13px;
color: #333333;
}
/* Header */
#header {
width: 850px;
height: 82px;
margin: 0 auto 40px auto;
background: url(images/img03.gif) repeat-x left bottom;
}
#logo {
float: left;
}
#logo h1 {
font-size: 38px;
color: #494949;
}
#logo h1 sup {
vertical-align: text-top;
font-size: 24px;
}
#logo h1 a {
color: #494949;
}
#logo h2 {
margin-top: -10px;
font-size: 12px;
color: #A0A0A0;
}
#logo a {
text-decoration: none;
}
/* Menu */
#menu {
float: right;
}
#menu ul {
margin: 0;
padding: 15px 0 0 0;
list-style: none;
}
#menu li {
display: inline;
}
#menu a {
display: block;
float: left;
margin-left: 30px;
padding: 7px;
text-decoration: none;
font-size: 13px;
color: #000000;
}
#menu a:hover {
text-decoration: underline;
}
#menu .active a {
background: url(images/img02.gif) repeat-x left bottom;
}
/* Page */
#page {
width: 850px;
margin: 0 auto;
}
/* Content */
#content {
float: left;
width: 575px;
}
/* Post */
.post {
}
.post .title {
margin-bottom: 20px;
padding-bottom: 5px;
background: url(images/img03.gif) repeat-x left bottom;
}
.post .entry {
}
.post .meta {
padding: 15px 0 60px 0;
background: url(images/img03.gif) repeat-x;
}
.post .meta p {
margin: 0;
line-height: normal;
color: #999999;
}
.post .meta .byline {
float: left;
}
.post .meta .links {
float: right;
}
.post .meta .more {
padding: 0 20px 0 18px;
background: url(images/img06.gif) no-repeat left center;
}
.post .meta .comments {
padding-left: 22px;
background: url(images/img07.gif) no-repeat left center;
}
.post .meta b {
display: none;
}
/* Sidebar */
#sidebar {
float: right;
width: 195px;
}
#sidebar ul {
margin: 0;
padding: 0;
list-style: none;
}
#sidebar li {
margin-bottom: 40px;
}
#sidebar li ul {
}
#sidebar li li {
margin: 0;
}
#sidebar h2 {
margin-bottom: 10px;
background: url(images/img03.gif) repeat-x left bottom;
font-size: 16px;
}
/* Search */
#search {
}
#search h2 {
margin-bottom: 20px;
}
#s {
width: 120px;
margin-right: 5px;
padding: 3px;
border: 1px solid #F0F0F0;
}
#x {
padding: 3px;
background: #ECECEC url(images/img08.gif) repeat-x left bottom;
border: none;
text-transform: lowercase;
font-size: 11px;
color: #4F4F4F;
}
/* Boxes */
.box1 {
padding: 20px;
background: url(images/img05.gif) no-repeat;
}
.box2 {
color: #BABABA;
}
.box2 h2 {
margin-bottom: 15px;
background: url(images/img10.gif) repeat-x left bottom;
font-size: 16px;
color: #FFFFFF;
}
.box2 ul {
margin: 0;
padding: 0;
list-style: none;
}
.box2 a:link, .box2 a:hover, .box2 a:active, .box2 a:visited {
color: #EDEDED;
}
/* Footer */
#footer {
height: 400px;
min-height: 400px;
padding: 130px 0 0 0;
background: #003448 url(images/img09.gif) repeat-x;
}
html>body #footer {
height: auto;
}
#footer .wrap {
width: 850px;
margin: 0 auto;
}
#legal {
clear: both;
padding-top: 20px;
text-align: center;
color: #375C69;
}
#legal a {
color: #476B77;
}
#fbox1, #fbox2, #fbox3 {
float: left;
}
#fbox1 {
width: 310px;
}
#fbox2 {
width: 200px;
padding-left: 70px;
}
#fbox3 {
width: 200px;
padding-left: 70px;
}
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..9fbe0b1
--- /dev/null
+++ b/index.html
@@ -0,0 +1,9 @@
+---
+layout: default
+title: barnesang.com
+---
+
+{% for post in site.posts %}
+ <a href="{{ post.url }}">{{ post.title }}</a> |
+{% endfor %}
+
|
tormaroe/barnesang.com
|
10de7bbbbfd310c5846d1c499eda1a2c8d1082b8
|
Implemented template, and added images and CSS. Fixed permalink config. Added the first few songs.
|
diff --git a/_config.yml b/_config.yml
index 1ff62f5..3875afd 100644
--- a/_config.yml
+++ b/_config.yml
@@ -1,4 +1,4 @@
auto: false
server: false
-permalink: :title.html
+permalink: /:title.html
exclude: README.markdown, rakefile
diff --git a/_layouts/default.html b/_layouts/default.html
index 6555456..bb91f1e 100644
--- a/_layouts/default.html
+++ b/_layouts/default.html
@@ -1,9 +1,91 @@
-<html>
- <head>
- <title>{{page.title}}</title>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<title>{{page.title}}</title>
+<meta name="keywords" content="" />
+<meta name="description" content="" />
+<link href="default.css" rel="stylesheet" type="text/css" />
</head>
<body>
- <h1>{{page.title}}</h1>
- {{ content }}
- </body>
+<!-- start header -->
+<div id="header">
+ <div id="logo">
+ <h1><a href="http://barnesang.com/">Barnesang.com</a></h1>
+ <h2>Sanger som gjør barn glade</h2>
+ </div>
+ <div id="menu">
+ <ul>
+ <li class="active"><a href="#">hjem</a></li>
+ <li><a href="#">alle sanger</a></li>
+ <li><a href="#">Om barnesang.com</a></li>
+ <li><a href="#">lenker</a></li>
+ </ul>
+ </div>
+</div>
+<!-- end header -->
+
+<!-- start page -->
+<div id="page">
+ <!-- start content -->
+ <div id="content">
+ <div class="post">
+ <h1 class="title">{{page.title}}</h1>
+ <div class="entry">
+ {{ content }}
+ </div>
+ </div>
+ </div>
+ <!-- end content -->
+
+ <!-- start sidebar -->
+ <div id="sidebar">
+ <ul>
+ <li id="search">
+ <h2><b>Søk</b> etter en sang</h2>
+ <form method="get" action="">
+ <fieldset>
+ <input type="text" id="s" name="s" value="" />
+ <input type="submit" id="x" value="Søk" />
+ </fieldset>
+ </form>
+ </li>
+ </ul>
+ </div>
+ <!-- end sidebar -->
+ <div style="clear: both;"> </div>
+</div>
+<!-- end page -->
+<!-- start footer -->
+<div id="footer">
+ <div class="wrap">
+ <div id="fbox1" class="box2">
+ <h2><b>Lorem</b> Ipsum</h2>
+ <p>Curabitur tellus. Phasellus tellus <a href="#">turpis iaculis</a> in, faucibus lobortis, posuere in, lorem. Donec a ante. Donec neque purus, adipiscing id <a href="#">eleifend a cursus</a> vel odio. Vivamus varius justo amet porttitor iaculis, ipsum massa aliquet nulla, non elementum mi elit a mauris. In hac habitasse platea.</p>
+ </div>
+ <div id="fbox2" class="box2">
+ <h2><b>Metus</b> Nonummy</h2>
+ <ul>
+ <li><a href="#">Magna lacus bibendum mauris</a></li>
+ <li><a href="#">Nec metus sed donec</a></li>
+ <li><a href="#">Velit semper nisi molestie</a></li>
+ <li><a href="#">Consequat sed cursus</a></li>
+ <li><a href="#">Eget tempor eget nonummy</a></li>
+ </ul>
+ </div>
+ <div id="fbox3" class="box2">
+ <h2><b>Metus</b> Nonummy</h2>
+ <ul>
+ <li><a href="#">Magna lacus bibendum mauris</a></li>
+ <li><a href="#">Nec metus sed donec</a></li>
+ <li><a href="#">Velit semper nisi molestie</a></li>
+ <li><a href="#">Consequat sed cursus</a></li>
+ <li><a href="#">Eget tempor eget nonummy</a></li>
+ </ul>
+ </div>
+ </div>
+ <p id="legal">(c) 2009 Barnesang.com. Design by <a href="http://www.nodethirtythree.com/">NodeThirtyThree</a> and <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p>
+</div>
+<!-- end footer -->
+</body>
</html>
diff --git a/_layouts/song.html b/_layouts/song.html
index 304d34f..73dae17 100644
--- a/_layouts/song.html
+++ b/_layouts/song.html
@@ -1,4 +1,4 @@
---
layout: default
---
-<div>{{ content }}</div>
+{{ content }}
diff --git a/_posts/2010-02-08-lofottorsken.textile b/_posts/2010-02-08-lofottorsken.textile
new file mode 100644
index 0000000..d2a1674
--- /dev/null
+++ b/_posts/2010-02-08-lofottorsken.textile
@@ -0,0 +1,49 @@
+---
+layout: song
+title: Lofottorsken
+text: Thorbjørn Egner
+---
+En ekte Lofottorsk jeg er,
+for jeg er født i Henningsvær.
+Fadderullan dei, fadderullan dei,
+fadderullandullan dei.
+
+Den gang var jeg et torske-egg,
+nå er jeg voksen torsk med skjegg.
+Fadderullan dei, fadderullan dei,
+fadderullandullan dei.
+
+Nå er jeg selv blitt torskefar,
+og hundre tusen barn jeg har.
+Fadderullan dei, fadderullan dei,
+fadderullandullan dei.
+
+Da jeg var lite torskebarn,
+jeg passet meg for krok og garn.
+Fadderullan dei, fadderullan dei,
+fadderullandullan dei.
+
+Jeg gjemte meg for sild og sei.
+for alle ville spise meg.
+Fadderullan dei, fadderullan dei,
+fadderullandullan dei.
+
+Men nå er jeg blitt stor og slem,
+nå er det jeg som spiser dem,
+Fadderullan dei, fadderullan dei,
+fadderullandullan dei.
+
+Men når jeg ser en fiskemann,
+da rømmer jeg så fort jeg kan.
+Fadderullan dei, fadderullan dei,
+fadderullandullan dei.
+
+Men det fins garn av alle slag,
+jeg blir nok tatt en vakker dag.
+Fadderullan dei, fadderullan dei,
+fadderullandullan dei.
+
+Hvis én til slutt skal spise meg,
+så håper jeg at det blir deg!
+Fadderullan dei, fadderullan dei,
+fadderullandullan dei.
diff --git a/_posts/2010-02-09-lille-lotte.textile b/_posts/2010-02-09-lille-lotte.textile
new file mode 100644
index 0000000..07cd68c
--- /dev/null
+++ b/_posts/2010-02-09-lille-lotte.textile
@@ -0,0 +1,21 @@
+---
+layout: song
+title: Lille Lotte
+---
+Lille Lotte er så pen
+når hun går til skolen.
+Hånden den er ganske ren,
+ansiktet som solen.
+Hun kan si så pent "Goddag"
+Neie, det er ingen sak
+Så gjør lille Lotte,
+Så gjør lille Lotte
+
+Lille Hermann er så pen
+når han går til skolen.
+Hånden den er ganske ren,
+ansiktet som solen.
+Han kan si så pent "Goddag"
+Bukke, det er ingen sak.
+Så gjør lille Hermann,
+Så gjør lille Hermann.
diff --git a/_posts/2010-02-09-lille-petter-edderkopp.textile b/_posts/2010-02-09-lille-petter-edderkopp.textile
new file mode 100644
index 0000000..8aa146b
--- /dev/null
+++ b/_posts/2010-02-09-lille-petter-edderkopp.textile
@@ -0,0 +1,13 @@
+---
+layout: song
+title: Lille Petter Edderkopp
+---
+Lille Petter Eddekopp
+klatret på min hatt,
+så begynte det og regne
+og Petter ned han datt.
+
+Så kom solen
+og skinte på min hatt.
+Da ble der liv i Petter-kopp
+som klatret på min hatt.
diff --git a/_posts/2010-02-09-lille-pusekatt.textile b/_posts/2010-02-09-lille-pusekatt.textile
new file mode 100644
index 0000000..21c64cf
--- /dev/null
+++ b/_posts/2010-02-09-lille-pusekatt.textile
@@ -0,0 +1,14 @@
+---
+layout: song
+title: Lille pusekatt
+---
+Lille pusekatt hvor har du vært?
+Jeg har vært hos mamma'n min.
+Lille pusekatt hva gjorde du der?
+Jeg stjal melk fra mamma'n min.
+
+Lille pusekatt hva fikk du da?
+Jeg fikk ris på halen min.
+
+Lille pusekatt hva sa du da?
+Mjau, mjau, halen min!
diff --git a/_posts/2010-02-09-test.textile b/_posts/2010-02-09-test.textile
deleted file mode 100644
index 36cf85b..0000000
--- a/_posts/2010-02-09-test.textile
+++ /dev/null
@@ -1,8 +0,0 @@
----
-layout: song
-title: This is the post title
----
-
-Dette er et avsnitt
-
-Dette er et annet avsnitt
diff --git a/default.css b/default.css
new file mode 100644
index 0000000..6906516
--- /dev/null
+++ b/default.css
@@ -0,0 +1,347 @@
+/*
+Design by Free CSS Templates
+http://www.freecsstemplates.org
+Released for free under a Creative Commons Attribution 2.5 License
+*/
+
+body {
+ margin: 100px 0 0 0;
+ padding: 0;
+ background: #FFFFFF url(images/img01.gif) repeat-x;
+ font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
+ font-size: 13px;
+ color: #333333;
+}
+
+h1, h2, h3 {
+ margin: 0;
+ text-transform: lowercase;
+ font-weight: normal;
+ color: #3E3E3E;
+}
+
+h1 {
+ font-size: 32px;
+}
+
+h2 {
+ font-size: 23px;
+}
+
+p, ul, ol {
+ margin: 0 0 2em 0;
+ text-align: justify;
+ line-height: 26px;
+}
+
+a:link {
+ color: #7BAA0F;
+}
+
+a:hover, a:active {
+ text-decoration: none;
+ color: #003448;
+}
+
+a:visited {
+ color: #333333;
+}
+
+img {
+ border: none;
+}
+
+img.left {
+ float: left;
+ margin-right: 15px;
+}
+
+img.right {
+ float: right;
+ margin-left: 15px;
+}
+
+/* Form */
+
+form {
+ margin: 0;
+ padding: 0;
+}
+
+fieldset {
+ margin: 0;
+ padding: 0;
+ border: none;
+}
+
+legend {
+ display: none;
+}
+
+input, textarea, select {
+ font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
+ font-size: 13px;
+ color: #333333;
+}
+
+/* Header */
+
+#header {
+ width: 850px;
+ height: 82px;
+ margin: 0 auto 40px auto;
+ background: url(images/img03.gif) repeat-x left bottom;
+}
+
+#logo {
+ float: left;
+}
+
+#logo h1 {
+ font-size: 38px;
+ color: #494949;
+}
+
+#logo h1 sup {
+ vertical-align: text-top;
+ font-size: 24px;
+}
+
+#logo h1 a {
+ color: #494949;
+}
+
+#logo h2 {
+ margin-top: -10px;
+ font-size: 12px;
+ color: #A0A0A0;
+}
+
+#logo a {
+ text-decoration: none;
+}
+
+/* Menu */
+
+#menu {
+ float: right;
+}
+
+#menu ul {
+ margin: 0;
+ padding: 15px 0 0 0;
+ list-style: none;
+}
+
+#menu li {
+ display: inline;
+}
+
+#menu a {
+ display: block;
+ float: left;
+ margin-left: 30px;
+ padding: 7px;
+ text-decoration: none;
+ font-size: 13px;
+ color: #000000;
+}
+
+#menu a:hover {
+ text-decoration: underline;
+}
+
+#menu .active a {
+ background: url(images/img02.gif) repeat-x left bottom;
+}
+
+/* Page */
+
+#page {
+ width: 850px;
+ margin: 0 auto;
+}
+
+/* Content */
+
+#content {
+ float: left;
+ width: 575px;
+}
+
+/* Post */
+
+.post {
+}
+
+.post .title {
+ margin-bottom: 20px;
+ padding-bottom: 5px;
+ background: url(images/img03.gif) repeat-x left bottom;
+}
+
+.post .entry {
+}
+
+.post .meta {
+ padding: 15px 0 60px 0;
+ background: url(images/img03.gif) repeat-x;
+}
+
+.post .meta p {
+ margin: 0;
+ line-height: normal;
+ color: #999999;
+}
+
+.post .meta .byline {
+ float: left;
+}
+
+.post .meta .links {
+ float: right;
+}
+
+.post .meta .more {
+ padding: 0 20px 0 18px;
+ background: url(images/img06.gif) no-repeat left center;
+}
+
+.post .meta .comments {
+ padding-left: 22px;
+ background: url(images/img07.gif) no-repeat left center;
+}
+
+.post .meta b {
+ display: none;
+}
+
+/* Sidebar */
+
+#sidebar {
+ float: right;
+ width: 195px;
+}
+
+#sidebar ul {
+ margin: 0;
+ padding: 0;
+ list-style: none;
+}
+
+#sidebar li {
+ margin-bottom: 40px;
+}
+
+#sidebar li ul {
+}
+
+#sidebar li li {
+ margin: 0;
+}
+
+#sidebar h2 {
+ margin-bottom: 10px;
+ background: url(images/img03.gif) repeat-x left bottom;
+ font-size: 16px;
+}
+
+/* Search */
+
+#search {
+}
+
+#search h2 {
+ margin-bottom: 20px;
+}
+
+#s {
+ width: 120px;
+ margin-right: 5px;
+ padding: 3px;
+ border: 1px solid #F0F0F0;
+}
+
+#x {
+ padding: 3px;
+ background: #ECECEC url(images/img08.gif) repeat-x left bottom;
+ border: none;
+ text-transform: lowercase;
+ font-size: 11px;
+ color: #4F4F4F;
+}
+
+/* Boxes */
+
+.box1 {
+ padding: 20px;
+ background: url(images/img05.gif) no-repeat;
+}
+
+.box2 {
+ color: #BABABA;
+}
+
+.box2 h2 {
+ margin-bottom: 15px;
+ background: url(images/img10.gif) repeat-x left bottom;
+ font-size: 16px;
+ color: #FFFFFF;
+}
+
+.box2 ul {
+ margin: 0;
+ padding: 0;
+ list-style: none;
+}
+
+.box2 a:link, .box2 a:hover, .box2 a:active, .box2 a:visited {
+ color: #EDEDED;
+}
+
+/* Footer */
+
+#footer {
+ height: 400px;
+ min-height: 400px;
+ padding: 130px 0 0 0;
+ background: #003448 url(images/img09.gif) repeat-x;
+}
+
+html>body #footer {
+ height: auto;
+}
+
+#footer .wrap {
+ width: 850px;
+ margin: 0 auto;
+}
+
+#legal {
+ clear: both;
+ padding-top: 20px;
+ text-align: center;
+ color: #375C69;
+}
+
+#legal a {
+ color: #476B77;
+}
+
+#fbox1, #fbox2, #fbox3 {
+ float: left;
+}
+
+#fbox1 {
+ width: 310px;
+}
+
+#fbox2 {
+ width: 200px;
+ padding-left: 70px;
+}
+
+#fbox3 {
+ width: 200px;
+ padding-left: 70px;
+}
diff --git a/images/img01.gif b/images/img01.gif
new file mode 100644
index 0000000..43f1ed6
Binary files /dev/null and b/images/img01.gif differ
diff --git a/images/img02.gif b/images/img02.gif
new file mode 100644
index 0000000..7ed5fab
Binary files /dev/null and b/images/img02.gif differ
diff --git a/images/img03.gif b/images/img03.gif
new file mode 100644
index 0000000..51c0ef8
Binary files /dev/null and b/images/img03.gif differ
diff --git a/images/img04.jpg b/images/img04.jpg
new file mode 100644
index 0000000..3624407
Binary files /dev/null and b/images/img04.jpg differ
diff --git a/images/img05.gif b/images/img05.gif
new file mode 100644
index 0000000..c77a8c5
Binary files /dev/null and b/images/img05.gif differ
diff --git a/images/img06.gif b/images/img06.gif
new file mode 100644
index 0000000..0ec6170
Binary files /dev/null and b/images/img06.gif differ
diff --git a/images/img07.gif b/images/img07.gif
new file mode 100644
index 0000000..62f0c27
Binary files /dev/null and b/images/img07.gif differ
diff --git a/images/img08.gif b/images/img08.gif
new file mode 100644
index 0000000..d375543
Binary files /dev/null and b/images/img08.gif differ
diff --git a/images/img09.gif b/images/img09.gif
new file mode 100644
index 0000000..c1227a2
Binary files /dev/null and b/images/img09.gif differ
diff --git a/images/img10.gif b/images/img10.gif
new file mode 100644
index 0000000..89a8976
Binary files /dev/null and b/images/img10.gif differ
diff --git a/images/spacer.gif b/images/spacer.gif
new file mode 100644
index 0000000..5bfd67a
Binary files /dev/null and b/images/spacer.gif differ
|
tormaroe/barnesang.com
|
33ef77edef6f7a0bf663a7c5c4da6b69cd5bb5a3
|
Added rake file, and some other, tiny preparations
|
diff --git a/_config.yml b/_config.yml
index f3f21de..1ff62f5 100644
--- a/_config.yml
+++ b/_config.yml
@@ -1,3 +1,4 @@
auto: false
-server: true
+server: false
permalink: :title.html
+exclude: README.markdown, rakefile
diff --git a/_includes/analytics.html b/_includes/analytics.html
new file mode 100644
index 0000000..e69de29
diff --git a/_layouts/default.html b/_layouts/default.html
index 3682c11..6555456 100644
--- a/_layouts/default.html
+++ b/_layouts/default.html
@@ -1,9 +1,9 @@
<html>
<head>
- <title>My site</title>
+ <title>{{page.title}}</title>
</head>
<body>
- <h1>Title</h1>
+ <h1>{{page.title}}</h1>
{{ content }}
</body>
</html>
diff --git a/_layouts/song.html b/_layouts/song.html
index 8d926d5..304d34f 100644
--- a/_layouts/song.html
+++ b/_layouts/song.html
@@ -1,11 +1,4 @@
-<html>
- <head>
- <title>{{ page.title }}</title>
- </head>
- <body>
- <h1>{{ page.title }}</h1>
-
- <div>{{ content }}</div>
-
- </body>
-</html>
+---
+layout: default
+---
+<div>{{ content }}</div>
diff --git a/rakefile b/rakefile
new file mode 100644
index 0000000..9cc0834
--- /dev/null
+++ b/rakefile
@@ -0,0 +1,14 @@
+
+task :default => [
+ :clean,
+ :generate
+] do
+end
+
+task :generate do
+ sh "jekyll"
+end
+
+task :clean do
+ sh 'del /S /Q _site\*'
+end
|
tormaroe/barnesang.com
|
60aa0a012d60f7f49c6956c167de675d79f2efe0
|
Adding readme
|
diff --git a/README.markdown b/README.markdown
new file mode 100644
index 0000000..592d343
--- /dev/null
+++ b/README.markdown
@@ -0,0 +1 @@
+A site I'm making with lyrics of songs for children. Using Jekyll to generate it..
|
agnathan/bollint
|
73f5a63759cc6d17581296a70e144f5ac0ff1d72
|
Ticket 316
|
diff --git a/bollint.pl b/bollint.pl
index ea70173..764fbd2 100644
--- a/bollint.pl
+++ b/bollint.pl
@@ -1,177 +1,177 @@
#/usr/bin/perl -w
use strict;
use warnings;
# Input files are assumed to be in the UTF-8 strict character encoding.
use utf8;
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");
binmode(STDERR, ":utf8");
use Getopt::Long;
use Data::Dumper;
# Globals
#
use vars qw/ %opt /;
#
# Command line options processing
#
my ($help) = '';
sub usage()
{
print "
Equilibre et nettoye les styles de caractère à la Bible Online
Balance and clean character styles for the Bible Online
Utilisation: $0 [-hvd] livre [livres ...]
-h : s'affiche cette message
exemple: $0 -h;
exemple: $0 - fichier1 fichier2";
exit;
}
################################################################################
# Main Program
################################################################################
GetOptions (
'help' => \$help,
);
usage() if $help;
{
local $/ = '';
# Input and Output is encoded in the UTF-8 strict character encoding.
open(INPUT, "<:encoding(UTF-8)", shift) or die "Couldn't open for reading: $!\n";
}
my $tr = qr/\s*(?:\\\\|\\\@)\s*/;
while (<INPUT>) {
unless (m/^\$\$\$/) {
s/:[ Â ]*/:Â /ig;
#s/\\\\Quand \\\\Paul\@\\\\eut\@\\\\\\\\dit cela, il\\\\\@ \\\\s\@\\\\\@ \\\\'\@\\\\\@ \\\\éleva\@\\\\\\\\/&matching($&)/g;
#s/\\Quand \\Paul\@\\eut\@\\\\dit cela, il\\\@ \\s\@\\\@ \\'\@\\\@ \\éleva\@\\\\//g;
# s/\\\\\\@ \\\\s\\@\\\\\\@ \\\\'\\@\\\\\\@ \\\\(\w+)\\@\\\\\\\\/\\\\\\\@s'$1\\\@\\\\/g;
# s/\\\\\\@ \\\\s\\@\\\\\\@ \\\\'\\@\\\\\\@ \\\\(\w+)\\@\\\\\\\\/@{[\&matching($&)]}/g;
# $_ = &matching($_);
s/\\\\\\@ \\\\(\w+)\\@\\\\\\\\/\\\\\\@ $1\\@\\\\/g;
s/\[\s*\\\\\s*\â¦\s*\\\\\s*\]/.../g;
s/\[\s*\â¦\s*\]/.../g;
s/\[\s*\.\.\.\s*\]/.../g;
s/\(\s*\.\.\.\s*\)/.../g;
s/\(\\\\/\\\\(/g;
s/\\\\\)/\)\\\\/g;
- s/[  ]*(?:â¦|\.\.\.)[  ]*/ ... /g;
+ s/([  ]*)(?:â¦|\.\.\.)([  ]*)/$1...$2/g;
# BOL problem: quand un chiffre est suivi par un espace unsecable la lettre suivante est toujours en minuscules
s/(\d)Â ([A-Z])/$1 $2/g;
s/Å/o/g;
s/Å/O/g;
s/Ä«/i/g;
s/Ī/I/g;
s/â/'/g;
s/â/-/g;
s/â/-/g;
s/\\\\\[/\[\\\\/g;
s/\\\\\]/\]\\\\/g;
# Il faut supprimer l'espace insécable après le caractère °
s/°[ ]*/°/g;
s/â/"/g;
s/â/"/g;
s/,#/, #/g;
s/[ Â ]*;[ Â ]+/Â ; /g;
s/[ Â ]*:[ Â ]+/Â : /g;
s/[ Â ]*,/,/g;
s/«[  ]*/« /g;
s/[  ]*»/ »/g;
s/. " »/." »/g;
- s/« \.\.\. /« ... /g;
+ s/«[  ]*\.\.\./« .../g;
s/\.\.\.[ Â ]*\?/.../g;
s/\.\.\.[ Â ]*\./.../g;
s/\.\.\.[ Â ]*\!/.../g;
s/\\\@(-|â|â)/\\\@ -/g;
s/\\\\\\\\//g;
# Verses should not have spaces before and after the ':'
s/(\d)[ Â ]*:[ Â ]+(\d)/$1:$2/g;
# http: should not have ':' surrounded by spaces
s/http : /http:/g;
# BOL must not have a non-breakable space before '«'
# s/ « / « /g;
s/([,:%\.]) « /$1 « /g; # Unless proceeded by one of the following: ':' ',' '%'
# Space before an '{'
s/\s?\{/ \{/g;
# BOL formatting
# If a single ',' or ' ' is surrounded by italics then remove the italics
s/\\\@([ Â ]*[, \.][ Â ]*)\\\@/$1/g;
s/\\\@\.\.\. /\\\@ ... /g;
# Move the ':' to the outside
s/Â :\\\\ /\\\\Â :/g;
# Formatting that contains nothing but spaces ... can disappear.
s/\\!([ Â ]*)\\!/$1/g;
############################################################
# Removing spaces
# Remove the space before a '...' if it is followed by a '»'
s/ \.\.\. » /... » /g;
- s/[ Â ]*\.\.\./.../g;
+ #s/[ Â ]*\.\.\./.../g;
# Remove spaces between formatting a '«'
s/\![  ]*«/\! «/g;
# Strange cases
# s/ : \\% « / :\\% « /g;
s/Â : \\%/Â :\\%/g;
# s/ :\\% « / :\\% « /g;
# Suspected of being unimportant
s/Â :[ Â ]*$/Â :/g;
# Not Generalized
s/être « La primauté de Christ » ou « /être « La primauté de Christ » ou « /g;
s/Thème :\\% « Ãtre en Christ/Thème :\\% « Ãtre en Christ/g;
# s/[  ]*«[  ]*/ « /g;
-
+
# Transform the figures and legend
s/figure="i(\d+)\.jpg"\s+légende="([^"]*)"\s+crédit="([^"]*)"/\\\@$2\\\@\\\\ ==> figure $1\\\\/g;
}
my @p = split /($tr)/;
my %state;
foreach my $part (@p) {
if ($part =~ m/($tr)/) {
my $key = $part;
$key =~ s/\s*//g;
my $unesckey = $key;
$key =~ s/./\\$&/g;
if (defined($state{$key})) {
$part =~ s/([\s ]+)$key/$unesckey$1/g;
$state{$key} = undef;
} else {
$part =~ s/$key([\s ]+)/$1$unesckey/g;
$state{$key} = 1;
}
}
print $part;
}
}
close(INPUT);
|
agnathan/bollint
|
bdf06d3d7c34fcef6f8b3835ee2c64de7d15b200
|
Include the most recent updates
|
diff --git a/bollint.pl b/bollint.pl
index 17d8ec3..ea70173 100644
--- a/bollint.pl
+++ b/bollint.pl
@@ -1,127 +1,177 @@
#/usr/bin/perl -w
use strict;
use warnings;
# Input files are assumed to be in the UTF-8 strict character encoding.
use utf8;
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");
binmode(STDERR, ":utf8");
use Getopt::Long;
use Data::Dumper;
# Globals
#
use vars qw/ %opt /;
#
# Command line options processing
#
my ($help) = '';
sub usage()
{
print "
Equilibre et nettoye les styles de caractère à la Bible Online
Balance and clean character styles for the Bible Online
Utilisation: $0 [-hvd] livre [livres ...]
-h : s'affiche cette message
exemple: $0 -h;
exemple: $0 - fichier1 fichier2";
exit;
}
################################################################################
# Main Program
################################################################################
GetOptions (
'help' => \$help,
);
usage() if $help;
{
local $/ = '';
# Input and Output is encoded in the UTF-8 strict character encoding.
open(INPUT, "<:encoding(UTF-8)", shift) or die "Couldn't open for reading: $!\n";
}
my $tr = qr/\s*(?:\\\\|\\\@)\s*/;
while (<INPUT>) {
unless (m/^\$\$\$/) {
s/:[ Â ]*/:Â /ig;
#s/\\\\Quand \\\\Paul\@\\\\eut\@\\\\\\\\dit cela, il\\\\\@ \\\\s\@\\\\\@ \\\\'\@\\\\\@ \\\\éleva\@\\\\\\\\/&matching($&)/g;
#s/\\Quand \\Paul\@\\eut\@\\\\dit cela, il\\\@ \\s\@\\\@ \\'\@\\\@ \\éleva\@\\\\//g;
# s/\\\\\\@ \\\\s\\@\\\\\\@ \\\\'\\@\\\\\\@ \\\\(\w+)\\@\\\\\\\\/\\\\\\\@s'$1\\\@\\\\/g;
# s/\\\\\\@ \\\\s\\@\\\\\\@ \\\\'\\@\\\\\\@ \\\\(\w+)\\@\\\\\\\\/@{[\&matching($&)]}/g;
# $_ = &matching($_);
s/\\\\\\@ \\\\(\w+)\\@\\\\\\\\/\\\\\\@ $1\\@\\\\/g;
s/\[\s*\\\\\s*\â¦\s*\\\\\s*\]/.../g;
s/\[\s*\â¦\s*\]/.../g;
s/\[\s*\.\.\.\s*\]/.../g;
s/\(\s*\.\.\.\s*\)/.../g;
s/\(\\\\/\\\\(/g;
s/\\\\\)/\)\\\\/g;
s/[  ]*(?:â¦|\.\.\.)[  ]*/ ... /g;
# BOL problem: quand un chiffre est suivi par un espace unsecable la lettre suivante est toujours en minuscules
s/(\d)Â ([A-Z])/$1 $2/g;
s/Å/o/g;
s/Å/O/g;
s/Ä«/i/g;
s/Ī/I/g;
s/â/'/g;
s/â/-/g;
s/â/-/g;
- s/\\\\\[/\[\\\\/g;
- s/\\\\\]/\]\\\\/g;
+ s/\\\\\[/\[\\\\/g;
+ s/\\\\\]/\]\\\\/g;
+
+ # Il faut supprimer l'espace insécable après le caractère °
+ s/°[ ]*/°/g;
s/â/"/g;
s/â/"/g;
s/,#/, #/g;
s/[ Â ]*;[ Â ]+/Â ; /g;
s/[ Â ]*:[ Â ]+/Â : /g;
- s/http : /http:/g;
s/[ Â ]*,/,/g;
s/«[  ]*/« /g;
s/[  ]*»/ »/g;
s/. " »/." »/g;
s/« \.\.\. /« ... /g;
s/\.\.\.[ Â ]*\?/.../g;
s/\.\.\.[ Â ]*\./.../g;
s/\.\.\.[ Â ]*\!/.../g;
s/\\\@(-|â|â)/\\\@ -/g;
s/\\\\\\\\//g;
- # s/\\\\\\@\\\\/\\\\ \\@ \\\\/g
+
+ # Verses should not have spaces before and after the ':'
+ s/(\d)[ Â ]*:[ Â ]+(\d)/$1:$2/g;
+
+ # http: should not have ':' surrounded by spaces
+ s/http : /http:/g;
+
+ # BOL must not have a non-breakable space before '«'
+ # s/ « / « /g;
+ s/([,:%\.]) « /$1 « /g; # Unless proceeded by one of the following: ':' ',' '%'
+
+ # Space before an '{'
+ s/\s?\{/ \{/g;
+ # BOL formatting
+ # If a single ',' or ' ' is surrounded by italics then remove the italics
+ s/\\\@([ Â ]*[, \.][ Â ]*)\\\@/$1/g;
+ s/\\\@\.\.\. /\\\@ ... /g;
+
+ # Move the ':' to the outside
+ s/Â :\\\\ /\\\\Â :/g;
+
+ # Formatting that contains nothing but spaces ... can disappear.
+ s/\\!([ Â ]*)\\!/$1/g;
+
+ ############################################################
+ # Removing spaces
+ # Remove the space before a '...' if it is followed by a '»'
+ s/ \.\.\. » /... » /g;
+ s/[ Â ]*\.\.\./.../g;
+
+ # Remove spaces between formatting a '«'
+ s/\![  ]*«/\! «/g;
+
+ # Strange cases
+ # s/ : \\% « / :\\% « /g;
+ s/Â : \\%/Â :\\%/g;
+ # s/ :\\% « / :\\% « /g;
+
+ # Suspected of being unimportant
+ s/Â :[ Â ]*$/Â :/g;
+
+ # Not Generalized
+ s/être « La primauté de Christ » ou « /être « La primauté de Christ » ou « /g;
+ s/Thème :\\% « Ãtre en Christ/Thème :\\% « Ãtre en Christ/g;
+ # s/[  ]*«[  ]*/ « /g;
+
+
+ # Transform the figures and legend
+ s/figure="i(\d+)\.jpg"\s+légende="([^"]*)"\s+crédit="([^"]*)"/\\\@$2\\\@\\\\ ==> figure $1\\\\/g;
}
my @p = split /($tr)/;
-
+
my %state;
foreach my $part (@p) {
if ($part =~ m/($tr)/) {
my $key = $part;
$key =~ s/\s*//g;
my $unesckey = $key;
$key =~ s/./\\$&/g;
if (defined($state{$key})) {
$part =~ s/([\s ]+)$key/$unesckey$1/g;
$state{$key} = undef;
} else {
$part =~ s/$key([\s ]+)/$1$unesckey/g;
$state{$key} = 1;
}
}
print $part;
}
}
close(INPUT);
|
agnathan/bollint
|
35f32515c2c1a1e857e8fb5d670e30c3765a475f
|
Adding in other BOL change and replace statements
|
diff --git a/balance.pl b/balance.pl
index 1ef5aea..17d8ec3 100644
--- a/balance.pl
+++ b/balance.pl
@@ -1,98 +1,127 @@
#/usr/bin/perl -w
use strict;
use warnings;
# Input files are assumed to be in the UTF-8 strict character encoding.
use utf8;
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");
binmode(STDERR, ":utf8");
use Getopt::Long;
use Data::Dumper;
# Globals
#
use vars qw/ %opt /;
#
# Command line options processing
#
my ($help) = '';
sub usage()
{
print "
Equilibre et nettoye les styles de caractère à la Bible Online
Balance and clean character styles for the Bible Online
Utilisation: $0 [-hvd] livre [livres ...]
-h : s'affiche cette message
exemple: $0 -h;
exemple: $0 - fichier1 fichier2";
exit;
}
################################################################################
# Main Program
################################################################################
GetOptions (
'help' => \$help,
);
usage() if $help;
{
local $/ = '';
# Input and Output is encoded in the UTF-8 strict character encoding.
- my $input = shift;
- if (defined($input) && -e $input) {
- open(INPUT, "<:encoding(UTF-8)", $input);
- } else {
- *INPUT = *STDIN;
- }
+ open(INPUT, "<:encoding(UTF-8)", shift) or die "Couldn't open for reading: $!\n";
}
my $tr = qr/\s*(?:\\\\|\\\@)\s*/;
while (<INPUT>) {
- # my $d = &isbalanced($_);
+ unless (m/^\$\$\$/) {
+ s/:[ Â ]*/:Â /ig;
+ #s/\\\\Quand \\\\Paul\@\\\\eut\@\\\\\\\\dit cela, il\\\\\@ \\\\s\@\\\\\@ \\\\'\@\\\\\@ \\\\éleva\@\\\\\\\\/&matching($&)/g;
+ #s/\\Quand \\Paul\@\\eut\@\\\\dit cela, il\\\@ \\s\@\\\@ \\'\@\\\@ \\éleva\@\\\\//g;
+ # s/\\\\\\@ \\\\s\\@\\\\\\@ \\\\'\\@\\\\\\@ \\\\(\w+)\\@\\\\\\\\/\\\\\\\@s'$1\\\@\\\\/g;
+ # s/\\\\\\@ \\\\s\\@\\\\\\@ \\\\'\\@\\\\\\@ \\\\(\w+)\\@\\\\\\\\/@{[\&matching($&)]}/g;
+ # $_ = &matching($_);
+ s/\\\\\\@ \\\\(\w+)\\@\\\\\\\\/\\\\\\@ $1\\@\\\\/g;
+ s/\[\s*\\\\\s*\â¦\s*\\\\\s*\]/.../g;
+ s/\[\s*\â¦\s*\]/.../g;
+ s/\[\s*\.\.\.\s*\]/.../g;
+ s/\(\s*\.\.\.\s*\)/.../g;
+ s/\(\\\\/\\\\(/g;
+ s/\\\\\)/\)\\\\/g;
+ s/[  ]*(?:â¦|\.\.\.)[  ]*/ ... /g;
+
+ # BOL problem: quand un chiffre est suivi par un espace unsecable la lettre suivante est toujours en minuscules
+ s/(\d)Â ([A-Z])/$1 $2/g;
+ s/Å/o/g;
+ s/Å/O/g;
+ s/Ä«/i/g;
+ s/Ī/I/g;
+ s/â/'/g;
+ s/â/-/g;
+ s/â/-/g;
+ s/\\\\\[/\[\\\\/g;
+ s/\\\\\]/\]\\\\/g;
+ s/â/"/g;
+ s/â/"/g;
+ s/,#/, #/g;
+ s/[ Â ]*;[ Â ]+/Â ; /g;
+ s/[ Â ]*:[ Â ]+/Â : /g;
+ s/http : /http:/g;
+ s/[ Â ]*,/,/g;
+ s/«[  ]*/« /g;
+ s/[  ]*»/ »/g;
+ s/. " »/." »/g;
+ s/« \.\.\. /« ... /g;
+ s/\.\.\.[ Â ]*\?/.../g;
+ s/\.\.\.[ Â ]*\./.../g;
+ s/\.\.\.[ Â ]*\!/.../g;
+ s/\\\@(-|â|â)/\\\@ -/g;
+ s/\\\\\\\\//g;
+ # s/\\\\\\@\\\\/\\\\ \\@ \\\\/g
+ }
my @p = split /($tr)/;
my %state;
foreach my $part (@p) {
if ($part =~ m/($tr)/) {
my $key = $part;
$key =~ s/\s*//g;
my $unesckey = $key;
$key =~ s/./\\$&/g;
if (defined($state{$key})) {
$part =~ s/([\s ]+)$key/$unesckey$1/g;
$state{$key} = undef;
} else {
$part =~ s/$key([\s ]+)/$1$unesckey/g;
$state{$key} = 1;
}
}
print $part;
}
}
-# while ($subject =~ m/\d{1,3}/sxg) {
-# # matched text = $&
-# }
-
-
-# sub isbalanced {
-# my $count = split(/$tr/, shift);
-# return ($count > 1 && $count % 2 == 1);
-# }
-
close(INPUT);
|
agnathan/bollint
|
9093495de8f3c7d8e89b7ceb1423579f053ba391
|
Initially this is a just a small script to remove unwanted space from BOL styled text
|
diff --git a/README b/README
new file mode 100644
index 0000000..e69de29
|
poshboytl/Terry-Tai-Blog
|
063707bee72afcb27cc82cdfcb89294699bc3e8a
|
New blog post, added capfile and h2 in base css
|
diff --git a/Capfile b/Capfile
new file mode 100644
index 0000000..323ea31
--- /dev/null
+++ b/Capfile
@@ -0,0 +1,36 @@
+load 'deploy' if respond_to?(:namespace) # cap2 differentiator
+
+set :application, "Terry-Tai-Blog"
+set :scm, :git
+set :repository, "[email protected]:poshboytl/Terry-Tai-Blog.git"
+set :domain, "terrytai.com"
+set :use_sudo, false
+set :user, "blog"
+set :deploy_to, "/home/blog/#{application}"
+
+role :app, domain
+role :web, domain
+
+# set :deploy_via, :remote_cache
+
+
+namespace :deploy do
+ task :restart, :roles => :app do
+ run "rm #{current_path}/README"
+ run "cd #{current_path} && jekyll"
+ end
+
+ task :start, :roles => :app do
+ # do nothing
+ end
+
+ task :stop, :roles => :app do
+ # do nothing
+ end
+
+ task :finalize_update do
+ # do nothing
+ end
+end
+
+
diff --git a/_posts/2010-04-12-how-i-deploy-my-jekyll-blog.textile b/_posts/2010-04-12-how-i-deploy-my-jekyll-blog.textile
new file mode 100644
index 0000000..a3126cf
--- /dev/null
+++ b/_posts/2010-04-12-how-i-deploy-my-jekyll-blog.textile
@@ -0,0 +1,70 @@
+---
+layout: post
+title: How I deploy my jekyll blog
+---
+
+h1. {{page.title}}
+
+h2. What is jekyll?
+
+ In my opinion "jekyll":http://jekyllrb.com/ is a pretty simple blog system, technically we can also treat it as a static site generator. The philosophy behind jekyll is simple and static.
+
+ Simple: There is no admin page, no DB, even no comments support... But i's very very flexible, at least it's more flexible than any other blog system I've ever met.
+ Static: Every page you visit in my blog is static, you can just run it only by Nginx or what ever you want.
+
+h2. How to deploy jekyll project?
+
+ Make the jekyll project run on a server may not be difficult. But if you want to make the process for publishing your blog post smarter, you may need some time to think over.
+ There are still some existing ways on the "jekyll wiki":http://wiki.github.com/mojombo/jekyll/, you'd better take a look firstly.
+ I'm very interesting in the way of "Rake-Jekyll":http://github.com/bry4n/rack-jekyll/ which transform jekyll app into Rack app. Though it's cool, not suitable for me, at least for this blog currently.
+ If some day I need integrate my jekyll app with some dynamic content or with Rails, I will consider Rake-Jekyll at first.
+
+h2. How I deploy this blog.
+
+Let me describe the process I want for publishing my blog.
+ First of all, I write my blog content in the "WriteRoom":http://www.hogbaysoftware.com/products/writeroom.
+ After that, I need add some links, pics and adjust the layout by "Textile":http://en.wikipedia.org/wiki/Textile_(markup_language) or "markdown":http://daringfireball.net/projects/markdown/ tags in my "Textmate":http://macromates.com/.
+ When post is finished, I commit my jekyll blog to github.
+ At last, I just wanna run 'cap deploy' to finish the publishing.
+
+*What I do to support my publishing process and requirement:*
+
+ To keep things simpe, I just wanna run my blog by Ngnix without running the jekyll process backend. On the other hand, I havn't added the _site folder to my VCS. So the static content need to be generated on the server side.
+Unfortunately, in current version of jekyll, when you run the jekyll command to generate the static content, the jekyll process will keep running after the generation done. Originally, I use a very ugly way to kill the jekyll process which run "killall jekyll". Finally, I find a "fork":http://github.com/mattmatt/jekyll from mattmatt support this function for me. It can only generate the static content and close the jekyll process automatically.
+
+Here is my Capfile:
+
+{% highlight ruby %}
+load 'deploy' if respond_to?(:namespace) # cap2 differentiator
+set :application, "Terry-Tai-Blog"
+set :scm, :git
+set :repository, "[email protected]:poshboytl/Terry-Tai-Blog.git"
+set :domain, "terrytai.com"
+set :use_sudo, false
+set :user, "blog"
+set :deploy_to, "/home/blog/#{application}"
+
+role :app, domain
+role :web, domain
+
+namespace :deploy do
+ task :restart, :roles => :app do
+ run "rm #{current_path}/README"
+ run "cd #{current_path} && jekyll"
+ end
+
+ task :start, :roles => :app do
+ # do nothing
+ end
+
+ task :stop, :roles => :app do
+ # do nothing
+ end
+
+ task :finalize_update do
+ # do nothing
+ end
+end
+{% endhighlight %}
+
+So, after finishing my blog, I just need commit the post to the github, and run 'cap deploy'. That's all.
\ No newline at end of file
diff --git a/stylesheets/base.css b/stylesheets/base.css
index 2c0abc1..4e5d37b 100755
--- a/stylesheets/base.css
+++ b/stylesheets/base.css
@@ -1,226 +1,229 @@
*{
margin:0;
padding:0;
}
body{
width:auto;
font-family:Arial,Sans-serif;
font-size:13px;
}
ul{
list-style:none;
}
a{
text-decoration:none;
}
img{
border:0;
}
#wrapper{
width:575px;
margin:0 auto;
}
/*header begin*/
#header{
width:100%;
height:268px;
float:left;
margin-top:20px;
position:relative;
border:1px solid #CFCFCF;
}
/*header end*/
/*content begin*/
#content{
width:100%;
float:left;
position:relative;
border:1px solid #CFCFCF;
}
.intro{
width:570px;
height:90px;
float:left;
margin:3px 2px 8px;
line-height:22px;
font-family:Verdana;
border-bottom:1px solid #efefef;
}
.leftbar{
width:340px;
float:left;
margin-left:2px;
border-right:1px solid #efefef;
}
.panel{
width:340px;
float:left;
margin-bottom:9px;
padding-bottom:5px;
border-bottom:1px solid #efefef;
}
.title{
width:340px;
line-height:22px;
float:left;
}
.title a{
font-size:16px;
color:#000;
}
.name,.time{
width:100px;
height:20px;
line-height:20px;
margin:3px 0;
font-size:12px;
color:#6F6F6F;
}
.time{
margin-left:4px;
}
.page{
width:340px;
float:left;
margin-top:7px;
}
.page a{
color:#393534;
font-size:12px;
}
.rightbar{
width:230px;
height:280px;
float:left;
margin-left:2px;
position:absulte;
}
.r_title{
width:35px;
float:left;
position:relative;
left:10px;
z-index:999;
font-size:18px;
text-align:center;
background:#fff;
border-top:1px solid #AEAEAE;
border-left:1px solid #AEAEAE;
border-bottom:1px solid #AEAEAE;
}
.rightbar ul{
width:130px;
float:left;
padding-top:4px;
position:absolute;
margin-left:45px;
z-index:99;
border:1px solid #AEAEAE;
}
.rightbar ul li{
display:inline;
margin:5px;
float:left;
}
/*-------------------------*/
#post h1{
- font-size:18px;
+ font-size: 25px;
}
+#post h2{
+ font-size: 15px;
+}
#post .meta{
font-size:12px;
color:grey;
}
#post pre {
border: 1px solid #ddd;
background-color: #eef;
padding: 0 .4em;
}
#post ul,
#post ol {
margin-left: 1.25em;
}
#post code {
border: 1px solid #ddd;
background-color: #eef;
font-size: 95%;
padding: 0 .2em;
}
#post pre code {
border: none;
}
/* terminal */
#post pre.terminal {
border: 1px solid black;
background-color: #333;
color: white;
}
#post pre.terminal code {
background-color: #333;
}
#post p{
margin: 5px 0;
line-height: 22px;
}
#post a{
background:#efefef;
color:grey;
}
/*content end*/
/*footer begin*/
#footer{
width:100%;
float:left;
position:relative;
}
/*footer end*/
\ No newline at end of file
|
poshboytl/Terry-Tai-Blog
|
f10a397b49a3f8b5e5aba569d4594f4e803f1b76
|
Made the logo as a link to back to index.
|
diff --git a/_layouts/default.html b/_layouts/default.html
index e02bca9..a7d9a5d 100644
--- a/_layouts/default.html
+++ b/_layouts/default.html
@@ -1,26 +1,26 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en-us" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Terry Tai's blog. {{page.title}}</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Terry Tai's blog, talking about Ruby, Rails, Mac, iPhone." />
<meta name="author" content="Terry Tai"/>
<meta name="su" content="terry's blog" />
<link rel="stylesheet" href="/stylesheets/syntax.css" type="text/css" />
<link rel="stylesheet" href="/stylesheets/base.css" type="text/css" />
<script language="javascript" type="text/javascript" src="http://quickribbon.com/ribbon/2010/03/0160489bb8f0bbe36ae39e7d7b0e5f6b.js"></script><noscript><a href="http://quickribbon.com/">Quickribbon</a></noscript>
</head>
<body>
<div id="wrapper">
<div id="header">
- <img src="/images/terry's-studio.png" alt="terry's blog" />
+ <a href="/"><img src="/images/terry's-studio.png" alt="terry's blog" /></a>
</div>
{{content}}
<div id="footer"></div>
</div>
</body>
diff --git a/_site/2010/03/31/hello-world.html b/_site/2010/03/31/hello-world.html
index c3157cf..ecdefeb 100644
--- a/_site/2010/03/31/hello-world.html
+++ b/_site/2010/03/31/hello-world.html
@@ -1,48 +1,48 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en-us" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Terry Tai's blog. Hello World</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Terry Tai's blog, talking about Ruby, Rails, Mac, iPhone." />
<meta name="author" content="Terry Tai"/>
<meta name="su" content="terry's blog" />
<link rel="stylesheet" href="/stylesheets/syntax.css" type="text/css" />
<link rel="stylesheet" href="/stylesheets/base.css" type="text/css" />
<script language="javascript" type="text/javascript" src="http://quickribbon.com/ribbon/2010/03/0160489bb8f0bbe36ae39e7d7b0e5f6b.js"></script><noscript><a href="http://quickribbon.com/">Quickribbon</a></noscript>
</head>
<body>
<div id="wrapper">
<div id="header">
- <img src="/images/terry's-studio.png" alt="terry's blog" />
+ <a href="/"><img src="/images/terry's-studio.png" alt="terry's blog" /></a>
</div>
<div id="post">
<h1>Hello World</h1>
<p class="meta">18 Oct 2008 – San Francisco</p>
<div class="highlight"><pre><code class="ruby"><span class="nb">puts</span> <span class="s2">"Hello World!"</span>
</code></pre>
</div>
</div>
<hr />
<div id="disqus_thread"></div>
<script type="text/javascript">
/**
* var disqus_identifier; [Optional but recommended: Define a unique identifier (e.g. post id or slug) for this thread]
*/
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://terrytaiblog.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript=terrytaiblog">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
<div id="footer"></div>
</div>
</body>
diff --git a/_site/atom.xml b/_site/atom.xml
index 7bfbc2e..bc227c0 100644
--- a/_site/atom.xml
+++ b/_site/atom.xml
@@ -1,28 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Terry Tai's blog'</title>
<link href="http://terrytai.com/atom.xml" rel="self"/>
<link href="http://terrytai.com/"/>
- <updated>2010-03-31T23:07:28+08:00</updated>
+ <updated>2010-03-31T23:40:06+08:00</updated>
<id>http://terrytai.com/</id>
<author>
<name>Terry Tai's blog</name>
<email>[email protected]</email>
</author>
<entry>
<title>Hello World</title>
<link href="http://terrytai.com/2010/03/31/hello-world.html"/>
<updated>2010-03-31T00:00:00+08:00</updated>
<id>http://terrytai.com/2010/03/31/hello-world</id>
<content type="html"><h1>Hello World</h1>
<p class="meta">18 Oct 2008 &#8211; San Francisco</p>
<div class="highlight"><pre><code class="ruby"><span class="nb">puts</span> <span class="s2">&quot;Hello World!&quot;</span>
</code></pre>
</div></content>
</entry>
</feed>
\ No newline at end of file
diff --git a/_site/index.html b/_site/index.html
index 8be4f41..a6ac5ee 100644
--- a/_site/index.html
+++ b/_site/index.html
@@ -1,64 +1,64 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en-us" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Terry Tai's blog. Tom Preston-Werner</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Terry Tai's blog, talking about Ruby, Rails, Mac, iPhone." />
<meta name="author" content="Terry Tai"/>
<meta name="su" content="terry's blog" />
<link rel="stylesheet" href="/stylesheets/syntax.css" type="text/css" />
<link rel="stylesheet" href="/stylesheets/base.css" type="text/css" />
<script language="javascript" type="text/javascript" src="http://quickribbon.com/ribbon/2010/03/0160489bb8f0bbe36ae39e7d7b0e5f6b.js"></script><noscript><a href="http://quickribbon.com/">Quickribbon</a></noscript>
</head>
<body>
<div id="wrapper">
<div id="header">
- <img src="/images/terry's-studio.png" alt="terry's blog" />
+ <a href="/"><img src="/images/terry's-studio.png" alt="terry's blog" /></a>
</div>
<div id="content">
<div class="intro">
I'm <b>Terry Tai</b>, a Rails developer in Chengdu, China.
I began using Rails to create nice projects about three years ago.
I love the philosophy behind the Ruby and the Rails, which really change my life. In my spare time,
I'd like to taking photograph, reading book, listening to music, watching movie. BTW, I'm a big fans of Apple.
</div>
<div class="leftbar">
<div class="panel">
<span class="title"><a href="/2010/03/31/hello-world.html">Hello World</a></span>
<span class="name">Terry</span> posted on <span class="time">31 Mar 2010</span>
</div>
</div>
<div class="rightbar">
<span class="r_title">My</span>
<ul>
- <li><a href="http://twitter.com/poshboytl"><img src="/images/twitter.png" alt="twitter" /></a></li>
- <li><a href="http://github.com/poshboytl"><img src="/images/github.png" alt="github" /></a></li>
- <li><a href="http://poshboytl.tumblr.com/"><img src="/images/tumblr.png" alt="tumblr" /></a></li>
+ <li><a href="http://twitter.com/poshboytl" target="_blank"><img src="/images/twitter.png" alt="twitter" /></a></li>
+ <li><a href="http://github.com/poshboytl" target="_blank"><img src="/images/github.png" alt="github" /></a></li>
+ <li><a href="http://poshboytl.tumblr.com/" target="_blank"><img src="/images/tumblr.png" alt="tumblr" /></a></li>
<li><a href=""><img src="/images/flickr.png" alt="flickr" /></a></li>
- <li><a href="http://foursquare.com/user/poshboytl"><img src="/images/foursquare.png" alt="foursquare" /></a></li>
- <li><a href="http://www.facebook.com/profile.php?id=810380586"><img src="/images/facebook.png" alt="facebook" /></a></li>
- <li><a href="http://cn.linkedin.com/pub/terry-tai/10/627/50a"><img src="/images/linkdin.png" alt="linkedin" /></a></li>
+ <li><a href="http://foursquare.com/user/poshboytl" target="_blank"><img src="/images/foursquare.png" alt="foursquare" /></a></li>
+ <li><a href="http://www.facebook.com/profile.php?id=810380586" target="_blank"><img src="/images/facebook.png" alt="facebook" /></a></li>
+ <li><a href="http://cn.linkedin.com/pub/terry-tai/10/627/50a" target="_blank"><img src="/images/linkdin.png" alt="linkedin" /></a></li>
<li><a href=""><img src="/images/vimeo.png" alt="vimeo" /></a></li>
</ul>
</div>
</div>
<div id="footer"></div>
</div>
</body>
|
poshboytl/Terry-Tai-Blog
|
8d1d36c49a8ea23dbbac3804560edf094b60fea2
|
Delete the _site folder and add them to .gitignore. Add the target for the icons link in index
|
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4a03582
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+.DS_Store
+_site/
\ No newline at end of file
diff --git a/index.html b/index.html
index fe0db61..26f4cfd 100644
--- a/index.html
+++ b/index.html
@@ -1,43 +1,43 @@
---
layout: default
title: Tom Preston-Werner
---
<div id="content">
<div class="intro">
I'm <b>Terry Tai</b>, a Rails developer in Chengdu, China.
I began using Rails to create nice projects about three years ago.
I love the philosophy behind the Ruby and the Rails, which really change my life. In my spare time,
I'd like to taking photograph, reading book, listening to music, watching movie. BTW, I'm a big fans of Apple.
</div>
<div class="leftbar">
{% for post in site.posts%}
<div class="panel">
<span class="title"><a href="{{post.url}}">{{post.title}}</a></span>
<span class="name">Terry</span> posted on <span class="time">{{ post.date | date_to_string}}</span>
</div>
{%endfor%}
</div>
<div class="rightbar">
<span class="r_title">My</span>
<ul>
- <li><a href="http://twitter.com/poshboytl"><img src="/images/twitter.png" alt="twitter" /></a></li>
- <li><a href="http://github.com/poshboytl"><img src="/images/github.png" alt="github" /></a></li>
- <li><a href="http://poshboytl.tumblr.com/"><img src="/images/tumblr.png" alt="tumblr" /></a></li>
+ <li><a href="http://twitter.com/poshboytl" target="_blank"><img src="/images/twitter.png" alt="twitter" /></a></li>
+ <li><a href="http://github.com/poshboytl" target="_blank"><img src="/images/github.png" alt="github" /></a></li>
+ <li><a href="http://poshboytl.tumblr.com/" target="_blank"><img src="/images/tumblr.png" alt="tumblr" /></a></li>
<li><a href=""><img src="/images/flickr.png" alt="flickr" /></a></li>
- <li><a href="http://foursquare.com/user/poshboytl"><img src="/images/foursquare.png" alt="foursquare" /></a></li>
- <li><a href="http://www.facebook.com/profile.php?id=810380586"><img src="/images/facebook.png" alt="facebook" /></a></li>
- <li><a href="http://cn.linkedin.com/pub/terry-tai/10/627/50a"><img src="/images/linkdin.png" alt="linkedin" /></a></li>
+ <li><a href="http://foursquare.com/user/poshboytl" target="_blank"><img src="/images/foursquare.png" alt="foursquare" /></a></li>
+ <li><a href="http://www.facebook.com/profile.php?id=810380586" target="_blank"><img src="/images/facebook.png" alt="facebook" /></a></li>
+ <li><a href="http://cn.linkedin.com/pub/terry-tai/10/627/50a" target="_blank"><img src="/images/linkdin.png" alt="linkedin" /></a></li>
<li><a href=""><img src="/images/vimeo.png" alt="vimeo" /></a></li>
</ul>
</div>
</div>
\ No newline at end of file
|
poshboytl/Terry-Tai-Blog
|
e328dc5fd8503e8e53e56f9fb25b91e1d7929b97
|
Add the 'subscribe' robbin
|
diff --git a/_layouts/default.html b/_layouts/default.html
index bedc6cc..e02bca9 100644
--- a/_layouts/default.html
+++ b/_layouts/default.html
@@ -1,25 +1,26 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en-us" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Terry Tai's blog. {{page.title}}</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Terry Tai's blog, talking about Ruby, Rails, Mac, iPhone." />
<meta name="author" content="Terry Tai"/>
<meta name="su" content="terry's blog" />
<link rel="stylesheet" href="/stylesheets/syntax.css" type="text/css" />
<link rel="stylesheet" href="/stylesheets/base.css" type="text/css" />
+ <script language="javascript" type="text/javascript" src="http://quickribbon.com/ribbon/2010/03/0160489bb8f0bbe36ae39e7d7b0e5f6b.js"></script><noscript><a href="http://quickribbon.com/">Quickribbon</a></noscript>
</head>
<body>
<div id="wrapper">
<div id="header">
<img src="/images/terry's-studio.png" alt="terry's blog" />
</div>
{{content}}
<div id="footer"></div>
</div>
</body>
diff --git a/_site/2010/03/31/hello-world.html b/_site/2010/03/31/hello-world.html
index ae5d11c..c3157cf 100644
--- a/_site/2010/03/31/hello-world.html
+++ b/_site/2010/03/31/hello-world.html
@@ -1,47 +1,48 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en-us" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Terry Tai's blog. Hello World</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Terry Tai's blog, talking about Ruby, Rails, Mac, iPhone." />
<meta name="author" content="Terry Tai"/>
<meta name="su" content="terry's blog" />
<link rel="stylesheet" href="/stylesheets/syntax.css" type="text/css" />
<link rel="stylesheet" href="/stylesheets/base.css" type="text/css" />
+ <script language="javascript" type="text/javascript" src="http://quickribbon.com/ribbon/2010/03/0160489bb8f0bbe36ae39e7d7b0e5f6b.js"></script><noscript><a href="http://quickribbon.com/">Quickribbon</a></noscript>
</head>
<body>
<div id="wrapper">
<div id="header">
<img src="/images/terry's-studio.png" alt="terry's blog" />
</div>
<div id="post">
<h1>Hello World</h1>
<p class="meta">18 Oct 2008 – San Francisco</p>
<div class="highlight"><pre><code class="ruby"><span class="nb">puts</span> <span class="s2">"Hello World!"</span>
</code></pre>
</div>
</div>
<hr />
<div id="disqus_thread"></div>
<script type="text/javascript">
/**
* var disqus_identifier; [Optional but recommended: Define a unique identifier (e.g. post id or slug) for this thread]
*/
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://terrytaiblog.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript=terrytaiblog">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
<div id="footer"></div>
</div>
</body>
diff --git a/_site/atom.xml b/_site/atom.xml
index a7f1103..7bfbc2e 100644
--- a/_site/atom.xml
+++ b/_site/atom.xml
@@ -1,28 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Terry Tai's blog'</title>
<link href="http://terrytai.com/atom.xml" rel="self"/>
<link href="http://terrytai.com/"/>
- <updated>2010-03-31T22:36:14+08:00</updated>
+ <updated>2010-03-31T23:07:28+08:00</updated>
<id>http://terrytai.com/</id>
<author>
<name>Terry Tai's blog</name>
<email>[email protected]</email>
</author>
<entry>
<title>Hello World</title>
<link href="http://terrytai.com/2010/03/31/hello-world.html"/>
<updated>2010-03-31T00:00:00+08:00</updated>
<id>http://terrytai.com/2010/03/31/hello-world</id>
<content type="html"><h1>Hello World</h1>
<p class="meta">18 Oct 2008 &#8211; San Francisco</p>
<div class="highlight"><pre><code class="ruby"><span class="nb">puts</span> <span class="s2">&quot;Hello World!&quot;</span>
</code></pre>
</div></content>
</entry>
</feed>
\ No newline at end of file
diff --git a/_site/index.html b/_site/index.html
index 47abe99..8be4f41 100644
--- a/_site/index.html
+++ b/_site/index.html
@@ -1,63 +1,64 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en-us" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Terry Tai's blog. Tom Preston-Werner</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Terry Tai's blog, talking about Ruby, Rails, Mac, iPhone." />
<meta name="author" content="Terry Tai"/>
<meta name="su" content="terry's blog" />
<link rel="stylesheet" href="/stylesheets/syntax.css" type="text/css" />
<link rel="stylesheet" href="/stylesheets/base.css" type="text/css" />
+ <script language="javascript" type="text/javascript" src="http://quickribbon.com/ribbon/2010/03/0160489bb8f0bbe36ae39e7d7b0e5f6b.js"></script><noscript><a href="http://quickribbon.com/">Quickribbon</a></noscript>
</head>
<body>
<div id="wrapper">
<div id="header">
<img src="/images/terry's-studio.png" alt="terry's blog" />
</div>
<div id="content">
<div class="intro">
I'm <b>Terry Tai</b>, a Rails developer in Chengdu, China.
I began using Rails to create nice projects about three years ago.
I love the philosophy behind the Ruby and the Rails, which really change my life. In my spare time,
I'd like to taking photograph, reading book, listening to music, watching movie. BTW, I'm a big fans of Apple.
</div>
<div class="leftbar">
<div class="panel">
<span class="title"><a href="/2010/03/31/hello-world.html">Hello World</a></span>
<span class="name">Terry</span> posted on <span class="time">31 Mar 2010</span>
</div>
</div>
<div class="rightbar">
<span class="r_title">My</span>
<ul>
<li><a href="http://twitter.com/poshboytl"><img src="/images/twitter.png" alt="twitter" /></a></li>
<li><a href="http://github.com/poshboytl"><img src="/images/github.png" alt="github" /></a></li>
<li><a href="http://poshboytl.tumblr.com/"><img src="/images/tumblr.png" alt="tumblr" /></a></li>
<li><a href=""><img src="/images/flickr.png" alt="flickr" /></a></li>
<li><a href="http://foursquare.com/user/poshboytl"><img src="/images/foursquare.png" alt="foursquare" /></a></li>
<li><a href="http://www.facebook.com/profile.php?id=810380586"><img src="/images/facebook.png" alt="facebook" /></a></li>
<li><a href="http://cn.linkedin.com/pub/terry-tai/10/627/50a"><img src="/images/linkdin.png" alt="linkedin" /></a></li>
<li><a href=""><img src="/images/vimeo.png" alt="vimeo" /></a></li>
</ul>
</div>
</div>
<div id="footer"></div>
</div>
</body>
|
poshboytl/Terry-Tai-Blog
|
4b705240b249dce58060fca2b2303c43e1b5b301
|
recommit the atom.xml in the _site
|
diff --git a/_site/atom.xml b/_site/atom.xml
index a9827d3..a7f1103 100644
--- a/_site/atom.xml
+++ b/_site/atom.xml
@@ -1,28 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Terry Tai's blog'</title>
- <link href="http://terrytai/atom.xml" rel="self"/>
+ <link href="http://terrytai.com/atom.xml" rel="self"/>
<link href="http://terrytai.com/"/>
- <updated>2010-03-31T21:32:57+08:00</updated>
+ <updated>2010-03-31T22:36:14+08:00</updated>
<id>http://terrytai.com/</id>
<author>
<name>Terry Tai's blog</name>
<email>[email protected]</email>
</author>
<entry>
<title>Hello World</title>
<link href="http://terrytai.com/2010/03/31/hello-world.html"/>
<updated>2010-03-31T00:00:00+08:00</updated>
<id>http://terrytai.com/2010/03/31/hello-world</id>
<content type="html"><h1>Hello World</h1>
<p class="meta">18 Oct 2008 &#8211; San Francisco</p>
<div class="highlight"><pre><code class="ruby"><span class="nb">puts</span> <span class="s2">&quot;Hello World!&quot;</span>
</code></pre>
</div></content>
</entry>
</feed>
\ No newline at end of file
|
poshboytl/Terry-Tai-Blog
|
fa90499f87e6f61ffb5c871d316c0c6f7dfdbc45
|
Ooops, miss the '.com' in the atom.xml file
|
diff --git a/atom.xml b/atom.xml
index 2fb9fc3..06b9857 100644
--- a/atom.xml
+++ b/atom.xml
@@ -1,27 +1,27 @@
---
layout: nil
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Terry Tai's blog'</title>
- <link href="http://terrytai/atom.xml" rel="self"/>
+ <link href="http://terrytai.com/atom.xml" rel="self"/>
<link href="http://terrytai.com/"/>
<updated>{{ site.time | date_to_xmlschema }}</updated>
<id>http://terrytai.com/</id>
<author>
<name>Terry Tai's blog</name>
<email>[email protected]</email>
</author>
{% for post in site.posts %}
<entry>
<title>{{ post.title }}</title>
<link href="http://terrytai.com{{ post.url }}"/>
<updated>{{ post.date | date_to_xmlschema }}</updated>
<id>http://terrytai.com{{ post.id }}</id>
<content type="html">{{ post.content | xml_escape }}</content>
</entry>
{% endfor %}
</feed>
\ No newline at end of file
|
poshboytl/Terry-Tai-Blog
|
bcc386b481de15918f86b9ffa2a8977fb4ffd7af
|
Add the atom.xml
|
diff --git a/_site/README b/_site/README
new file mode 100644
index 0000000..e69de29
diff --git a/_site/atom.xml b/_site/atom.xml
new file mode 100644
index 0000000..a9827d3
--- /dev/null
+++ b/_site/atom.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+
+ <title>Terry Tai's blog'</title>
+ <link href="http://terrytai/atom.xml" rel="self"/>
+ <link href="http://terrytai.com/"/>
+ <updated>2010-03-31T21:32:57+08:00</updated>
+ <id>http://terrytai.com/</id>
+ <author>
+ <name>Terry Tai's blog</name>
+ <email>[email protected]</email>
+ </author>
+
+
+ <entry>
+ <title>Hello World</title>
+ <link href="http://terrytai.com/2010/03/31/hello-world.html"/>
+ <updated>2010-03-31T00:00:00+08:00</updated>
+ <id>http://terrytai.com/2010/03/31/hello-world</id>
+ <content type="html"><h1>Hello World</h1>
+<p class="meta">18 Oct 2008 &#8211; San Francisco</p>
+<div class="highlight"><pre><code class="ruby"><span class="nb">puts</span> <span class="s2">&quot;Hello World!&quot;</span>
+</code></pre>
+</div></content>
+ </entry>
+
+
+</feed>
\ No newline at end of file
diff --git a/_site/index.html b/_site/index.html
index 01fb9ce..47abe99 100644
--- a/_site/index.html
+++ b/_site/index.html
@@ -1,63 +1,63 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en-us" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Terry Tai's blog. Tom Preston-Werner</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Terry Tai's blog, talking about Ruby, Rails, Mac, iPhone." />
<meta name="author" content="Terry Tai"/>
<meta name="su" content="terry's blog" />
<link rel="stylesheet" href="/stylesheets/syntax.css" type="text/css" />
<link rel="stylesheet" href="/stylesheets/base.css" type="text/css" />
</head>
<body>
<div id="wrapper">
<div id="header">
<img src="/images/terry's-studio.png" alt="terry's blog" />
</div>
<div id="content">
<div class="intro">
I'm <b>Terry Tai</b>, a Rails developer in Chengdu, China.
I began using Rails to create nice projects about three years ago.
I love the philosophy behind the Ruby and the Rails, which really change my life. In my spare time,
I'd like to taking photograph, reading book, listening to music, watching movie. BTW, I'm a big fans of Apple.
</div>
<div class="leftbar">
<div class="panel">
<span class="title"><a href="/2010/03/31/hello-world.html">Hello World</a></span>
<span class="name">Terry</span> posted on <span class="time">31 Mar 2010</span>
</div>
</div>
<div class="rightbar">
<span class="r_title">My</span>
<ul>
- <li><a href=""><img src="/images/twitter.png" alt="twitter" /></a></li>
- <li><a href=""><img src="/images/github.png" alt="github" /></a></li>
- <li><a href=""><img src="/images/tumblr.png" alt="tumblr" /></a></li>
+ <li><a href="http://twitter.com/poshboytl"><img src="/images/twitter.png" alt="twitter" /></a></li>
+ <li><a href="http://github.com/poshboytl"><img src="/images/github.png" alt="github" /></a></li>
+ <li><a href="http://poshboytl.tumblr.com/"><img src="/images/tumblr.png" alt="tumblr" /></a></li>
<li><a href=""><img src="/images/flickr.png" alt="flickr" /></a></li>
- <li><a href=""><img src="/images/foursquare.png" alt="foursquare" /></a></li>
- <li><a href=""><img src="/images/facebook.png" alt="facebook" /></a></li>
- <li><a href=""><img src="/images/linkdin.png" alt="linkdin" /></a></li>
+ <li><a href="http://foursquare.com/user/poshboytl"><img src="/images/foursquare.png" alt="foursquare" /></a></li>
+ <li><a href="http://www.facebook.com/profile.php?id=810380586"><img src="/images/facebook.png" alt="facebook" /></a></li>
+ <li><a href="http://cn.linkedin.com/pub/terry-tai/10/627/50a"><img src="/images/linkdin.png" alt="linkedin" /></a></li>
<li><a href=""><img src="/images/vimeo.png" alt="vimeo" /></a></li>
</ul>
</div>
</div>
<div id="footer"></div>
</div>
</body>
diff --git a/atom.xml b/atom.xml
new file mode 100644
index 0000000..2fb9fc3
--- /dev/null
+++ b/atom.xml
@@ -0,0 +1,27 @@
+---
+layout: nil
+---
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+
+ <title>Terry Tai's blog'</title>
+ <link href="http://terrytai/atom.xml" rel="self"/>
+ <link href="http://terrytai.com/"/>
+ <updated>{{ site.time | date_to_xmlschema }}</updated>
+ <id>http://terrytai.com/</id>
+ <author>
+ <name>Terry Tai's blog</name>
+ <email>[email protected]</email>
+ </author>
+
+ {% for post in site.posts %}
+ <entry>
+ <title>{{ post.title }}</title>
+ <link href="http://terrytai.com{{ post.url }}"/>
+ <updated>{{ post.date | date_to_xmlschema }}</updated>
+ <id>http://terrytai.com{{ post.id }}</id>
+ <content type="html">{{ post.content | xml_escape }}</content>
+ </entry>
+ {% endfor %}
+
+</feed>
\ No newline at end of file
|
poshboytl/Terry-Tai-Blog
|
e643d4b7c8470547fdd06e464212158a1e0b2c9f
|
Add the links for the pics in the index
|
diff --git a/index.html b/index.html
index 547c9cd..fe0db61 100644
--- a/index.html
+++ b/index.html
@@ -1,43 +1,43 @@
---
layout: default
title: Tom Preston-Werner
---
<div id="content">
<div class="intro">
I'm <b>Terry Tai</b>, a Rails developer in Chengdu, China.
I began using Rails to create nice projects about three years ago.
I love the philosophy behind the Ruby and the Rails, which really change my life. In my spare time,
I'd like to taking photograph, reading book, listening to music, watching movie. BTW, I'm a big fans of Apple.
</div>
<div class="leftbar">
{% for post in site.posts%}
<div class="panel">
<span class="title"><a href="{{post.url}}">{{post.title}}</a></span>
<span class="name">Terry</span> posted on <span class="time">{{ post.date | date_to_string}}</span>
</div>
{%endfor%}
</div>
<div class="rightbar">
<span class="r_title">My</span>
<ul>
- <li><a href=""><img src="/images/twitter.png" alt="twitter" /></a></li>
- <li><a href=""><img src="/images/github.png" alt="github" /></a></li>
- <li><a href=""><img src="/images/tumblr.png" alt="tumblr" /></a></li>
+ <li><a href="http://twitter.com/poshboytl"><img src="/images/twitter.png" alt="twitter" /></a></li>
+ <li><a href="http://github.com/poshboytl"><img src="/images/github.png" alt="github" /></a></li>
+ <li><a href="http://poshboytl.tumblr.com/"><img src="/images/tumblr.png" alt="tumblr" /></a></li>
<li><a href=""><img src="/images/flickr.png" alt="flickr" /></a></li>
- <li><a href=""><img src="/images/foursquare.png" alt="foursquare" /></a></li>
- <li><a href=""><img src="/images/facebook.png" alt="facebook" /></a></li>
- <li><a href=""><img src="/images/linkdin.png" alt="linkdin" /></a></li>
+ <li><a href="http://foursquare.com/user/poshboytl"><img src="/images/foursquare.png" alt="foursquare" /></a></li>
+ <li><a href="http://www.facebook.com/profile.php?id=810380586"><img src="/images/facebook.png" alt="facebook" /></a></li>
+ <li><a href="http://cn.linkedin.com/pub/terry-tai/10/627/50a"><img src="/images/linkdin.png" alt="linkedin" /></a></li>
<li><a href=""><img src="/images/vimeo.png" alt="vimeo" /></a></li>
</ul>
</div>
</div>
\ No newline at end of file
|
gawen947/pidgin-pbar
|
d9ee4d90f784b5130b758162fe024dc687be1095
|
Change default compiler to cc.
|
diff --git a/commands.mk b/commands.mk
index f20758a..4127de4 100644
--- a/commands.mk
+++ b/commands.mk
@@ -1,13 +1,13 @@
# defaults commands
-CC=gcc
+CC=cc
RM=rm -f
INSTALL=install
INSTALL_PROGRAM=$(INSTALL) -s -m 555
INSTALL_DIR=$(INSTALL) -d
INSTALL_LIB=$(INSTALL) -s -m 444
INSTALL_DATA=$(INSTALL) -m 444
INSTALL_SCRIPT=$(INSTALL_PROGRAM)
XGETTEXT=xgettext
MSGFMT=msgfmt
MKDIR=mkdir
CP=cp
|
gawen947/pidgin-pbar
|
cd75287ef15854838c5bd632a56eb0441c5e74ac
|
Take care of purpleremote changing the current tune.
|
diff --git a/common.h b/common.h
index 5eca8b3..b722de2 100644
--- a/common.h
+++ b/common.h
@@ -1,52 +1,52 @@
/* File: common.h
- Time-stamp: <2010-10-05 01:14:39 gawen>
+ Time-stamp: <2012-04-05 13:00:29 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _COMMON_H_
#define _COMMON_H_
/* define for NLS */
#define GETTEXT_PACKAGE "pidgin-pbar"
/* common include for pidgin and gtk */
#include <string.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include "pidginstock.h"
#include "plugin.h"
#include "signals.h"
#include "gtkblist.h"
#include "gtkstatusbox.h"
#include "gtkprefs.h"
#include "prpl.h"
#include "request.h"
#include "debug.h"
#include "gtkutils.h"
#include "buddyicon.h"
#include "version.h"
#include "gtkplugin.h"
#ifdef _WIN32
# include "win32dep.h"
#endif /* _WIN32 */
#endif /* _COMMON_H_ */
diff --git a/purple.c b/purple.c
index 6878965..c9c43ec 100644
--- a/purple.c
+++ b/purple.c
@@ -1,401 +1,429 @@
/* File: purple.c
- Time-stamp: <2011-06-17 13:57:28 gawen>
+ Time-stamp: <2012-04-05 17:25:20 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* this file contains common functions for libpurple and pidgin */
#include "common.h"
#include "pbar.h"
#include "gtk.h"
+#include "preferences.h"
#include "purple.h"
/* callbacks */
static void cb_global_moods_for_each(gpointer key, gpointer value,
gpointer user_data);
static void cb_set_alias_failure(PurpleAccount *account, const char *error);
static void cb_dummy();
/* check if default gtk blist is created */
-gboolean is_gtk_blist_created()
+gboolean is_gtk_blist_created(void)
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
if(!blist ||
!blist->vbox ||
!gtk_widget_get_visible(blist->vbox))
return FALSE;
return TRUE;
}
+/* check wether two strings attributes are equals */
+static gboolean is_same_string_attr(const PurpleStatus *old,
+ const PurpleStatus *new,
+ const char *id)
+{
+ const gchar *new_value = purple_status_get_attr_string(new, id);
+ const gchar *old_value = purple_status_get_attr_string(old, id);
+
+ if(old_value == NULL && new_value)
+ return FALSE;
+ else if(new_value == NULL || !strcmp(new_value, old_value))
+ return TRUE;
+ return FALSE;
+}
+
+/* Check if the new song is different from the old one. */
+gboolean is_same_song(const PurpleStatus *old, const PurpleStatus *new)
+{
+ if(!is_same_string_attr(old, new, PURPLE_TUNE_TITLE))
+ return FALSE;
+ else if(!is_same_string_attr(old, new, PURPLE_TUNE_ALBUM))
+ return FALSE;
+ else if(!is_same_string_attr(old, new, PURPLE_TUNE_ARTIST))
+ return FALSE;
+ return TRUE;
+}
+
/* get buddy icon from statusbox widget */
-GdkPixbuf * get_buddy_icon()
+GdkPixbuf * get_buddy_icon(void)
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
const PidginStatusBox *statusbox = PIDGIN_STATUS_BOX(blist->statusbox);
return statusbox->buddy_icon;
}
/* get buddy icon hovered from statusbox widget */
-GdkPixbuf * get_buddy_icon_hover()
+GdkPixbuf * get_buddy_icon_hover(void)
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
const PidginStatusBox *statusbox = PIDGIN_STATUS_BOX(blist->statusbox);
return statusbox->buddy_icon_hover;
}
/* create purple protocol icon from protocol info */
GdkPixbuf * create_prpl_icon_from_info(PurplePluginProtocolInfo *prpl_info,
PidginPrplIconSize size)
{
const char *protoname = NULL;
char *tmp;
char *filename = NULL;
GdkPixbuf *pixbuf;
if (prpl_info->list_icon == NULL)
return NULL;
protoname = prpl_info->list_icon(NULL, NULL);
if (protoname == NULL)
return NULL;
/*
* Status icons will be themeable too, and then it will look up
* protoname from the theme
*/
tmp = g_strconcat(protoname, ".png", NULL);
filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols",
size == PIDGIN_PRPL_ICON_SMALL ? "16" :
size == PIDGIN_PRPL_ICON_MEDIUM ? "22" : "48",
tmp, NULL);
g_free(tmp);
pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
g_free(filename);
return pixbuf;
}
/* get current status stock id */
-const gchar * get_status_stock_id()
+const gchar * get_status_stock_id(void)
{
const PurpleSavedStatus *status = purple_savedstatus_get_current();
PurpleStatusPrimitive prim = purple_savedstatus_get_type(status);
return pidgin_stock_id_from_status_primitive(prim);
}
/* get mood icon path */
gchar * get_mood_icon_path(const gchar *mood)
{
gchar *path;
if(!mood || !strcmp(mood, ""))
path = g_build_filename(DATADIR, "pixmaps", "pidgin",
"toolbar", "16", "emote-select.png", NULL);
else if(!strcmp(mood, "busy"))
path = g_build_filename(DATADIR, "pixmaps", "pidgin",
"status", "16", "busy.png", NULL);
else if(!strcmp(mood, "hiptop"))
path = g_build_filename(DATADIR, "pixmaps", "pidgin",
"emblems", "16", "hiptop.png", NULL);
else {
gchar *filename = g_strdup_printf("%s.png", mood);
path = g_build_filename(DATADIR, "pixmaps", "pidgin",
"emotes", "small", filename, NULL);
g_free(filename);
}
return path;
}
/* get available attributes for a protocol
returned hashtable should be freed manually */
GHashTable * get_protocol_attrs(PurplePluginProtocolInfo *protocol)
{
if(!protocol->status_types)
return NULL;
GHashTable *attrs = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
GList *l = protocol->status_types(NULL);
for(; l ; l = l->next) {
PurpleStatusType *type = (PurpleStatusType *)l->data;
GList *k = purple_status_type_get_attrs(type);
for(; k ; k = k->next) {
struct _PurpleStatusAttr {
char *id;
char *name;
PurpleValue *value_type;
};
struct _PurpleStatusAttr *attr = (struct _PurpleStatusAttr *)k->data;
if(g_hash_table_lookup(attrs, attr->id))
continue;
else
g_hash_table_insert(attrs, (gpointer)attr->id,
GINT_TO_POINTER(TRUE));
}
}
return attrs;
}
/* get available attributes for an account
returned hashtable should be freed manally */
/* TODO: review this, now it does the same as get_protocol_attrs... */
GHashTable * get_account_attrs(PurpleAccount *account)
{
GHashTable *attrs = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
GList *l = purple_account_get_status_types(account);
for(; l ; l = l->next) {
PurpleStatusType *type = (PurpleStatusType *)l->data;
GList *k = purple_status_type_get_attrs(type);
for(; k ; k = k->next) {
struct _PurpleStatusAttr {
char *id;
char *name;
PurpleValue *value_type;
};
struct _PurpleStatusAttr *attr = (struct _PurpleStatusAttr *)k->data;
if(g_hash_table_lookup(attrs, attr->id))
continue;
else
g_hash_table_insert(attrs, (gpointer)attr->id,
GINT_TO_POINTER(TRUE));
}
}
return attrs;
}
/* get global moods */
-PurpleMood * get_global_moods()
+PurpleMood * get_global_moods(void)
{
GHashTable *global_moods = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
GHashTable *mood_counts = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
GList *accounts = purple_accounts_get_all_active();
PurpleMood *result = NULL;
GList *out_moods = NULL;
int i = 0;
int num_accounts = 0;
for(; accounts ; accounts = g_list_delete_link(accounts, accounts)) {
PurpleAccount *account = (PurpleAccount *)accounts->data;
if(purple_account_is_connected(account)) {
PurpleConnection *gc = purple_account_get_connection(account);
if(gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS) {
PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(
gc->prpl);
PurpleMood *mood = NULL;
for(mood = prpl_info->get_moods(account) ;
mood->mood ; mood++) {
int mood_count = GPOINTER_TO_INT(g_hash_table_lookup(mood_counts,
mood->mood));
if(!g_hash_table_lookup(global_moods, mood->mood))
g_hash_table_insert(global_moods, (gpointer)mood->mood, mood);
g_hash_table_insert(mood_counts, (gpointer)mood->mood,
GINT_TO_POINTER(mood_count + 1));
}
num_accounts++;
}
}
}
g_hash_table_foreach(global_moods, cb_global_moods_for_each, &out_moods);
result = g_new0(PurpleMood, g_hash_table_size(global_moods) + 1);
while(out_moods) {
PurpleMood *mood = (PurpleMood *)out_moods->data;
int in_num_accounts = GPOINTER_TO_INT(g_hash_table_lookup(mood_counts,
mood->mood));
if(in_num_accounts == num_accounts) {
/* mood is present in all accounts supporting moods */
result[i].mood = mood->mood;
result[i].description = mood->description;
i++;
}
out_moods = g_list_delete_link(out_moods, out_moods);
}
g_hash_table_destroy(global_moods);
g_hash_table_destroy(mood_counts);
return result;
}
/* set status to the specified mood */
void set_status_with_mood(PurpleAccount *account, const gchar *mood)
{
purple_account_set_status(account, "mood", TRUE, PURPLE_MOOD_NAME, mood,
NULL);
}
/* set status to the specified mood for all accounts */
void set_status_with_mood_all(const gchar *mood)
{
GList *accts = purple_accounts_get_all_active();
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = (PurpleAccount *)accts->data;
PurpleConnection *gc = purple_account_get_connection(account);
if(gc && gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS)
set_status_with_mood(account, mood);
}
}
/* set exclusive status for all accounts */
void set_status_all(const gchar *status_id, GList *attrs)
{
GList *accts = purple_accounts_get_all_active();
/* empty list means we have nothing to do */
if(!attrs)
return;
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = accts->data;
if(!purple_account_is_connected(account))
continue;
purple_account_set_status_list(account, status_id, TRUE, attrs);
}
}
/* set display name for account */
void set_display_name(PurpleAccount *account, const gchar *name)
{
const gchar *id = purple_account_get_protocol_id(account);
/* exception for set_public_alias */
if(!strcmp(id, "prpl-jabber")) {
PurpleConnection *gc = account->gc;
gchar *iq_id = g_strdup_printf("purple%x", g_random_int());
xmlnode *iq, *pubsub, *publish, *nicknode;
gc = account->gc;
iq_id = g_strdup_printf("purple%x", g_random_int());
iq = xmlnode_new("iq");
xmlnode_set_attrib(iq, "type", "set");
xmlnode_set_attrib(iq, "id", iq_id);
pubsub = xmlnode_new("pubsub");
xmlnode_set_attrib(pubsub, "xmlns", "http://jabber.org/protocol/pubsub");
publish = xmlnode_new("publish");
xmlnode_set_attrib(publish,"node","http://jabber.org/protocol/nick");
nicknode = xmlnode_new_child(xmlnode_new_child(publish, "item"), "nick");
xmlnode_set_namespace(nicknode, "http://jabber.org/protocol/nick");
xmlnode_insert_data(nicknode, name, -1);
xmlnode_insert_child(pubsub, publish);
xmlnode_insert_child(iq, pubsub);
purple_signal_emit(purple_connection_get_prpl(gc),
"jabber-sending-xmlnode", gc, &iq);
g_free(iq_id);
}
else
/* provide dummy callback since some
protocols don't check before calling */
purple_account_set_public_alias(account, name, cb_dummy,
cb_set_alias_failure);
}
/* set display name for all connected accounts */
void set_display_name_all(const char *name)
{
GList *accts = purple_accounts_get_all_active();
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = accts->data;
if(!purple_account_is_connected(account))
continue;
set_display_name(account, name);
}
}
/* set status message (personal message) */
void set_status_message(const gchar *pm)
{
PurpleSavedStatus *status = purple_savedstatus_get_current();
purple_savedstatus_set_message(status, pm);
purple_savedstatus_activate(status);
}
void prpl_connect_signals(struct pbar_widget *w,
const struct pbar_prpl_signal *sig_list,
gpointer data)
{
const struct pbar_prpl_signal *s = sig_list;
for(; s->signal ; s++)
purple_signal_connect(s->instance,
s->signal,
w,
PURPLE_CALLBACK(s->callback),
data);
}
void prpl_prefs_connect_signals(struct pbar_widget *w,
const struct pbar_prpl_signal *sig_list,
gpointer data)
{
const struct pbar_prpl_signal *s = sig_list;
for(; s->signal ; s++)
purple_prefs_connect_callback(s->instance,
s->signal,
PURPLE_PREFS_CALLBACK(s->callback),
data);
}
void prpl_disconnect_signals(struct pbar_widget *w)
{ purple_signals_disconnect_by_handle(w); }
void prpl_prefs_disconnect_signals(struct pbar_widget *w)
{ purple_prefs_disconnect_by_handle(w); }
static void cb_global_moods_for_each(gpointer key, gpointer value,
gpointer user_data)
{
GList **out_moods = (GList **)user_data;
PurpleMood *mood = (PurpleMood *)value;
*out_moods = g_list_append(*out_moods, mood);
}
static void cb_set_alias_failure(PurpleAccount *account, const char *error)
{
const gchar *id = purple_account_get_protocol_id(account);
purple_debug_info(NAME, "aliases not supported by \"%s\"\n", id);
}
-static void cb_dummy() {}
+static void cb_dummy(void) {}
diff --git a/purple.h b/purple.h
index 4613dda..428efab 100644
--- a/purple.h
+++ b/purple.h
@@ -1,65 +1,66 @@
/* File: purple.h
- Time-stamp: <2011-02-10 17:54:53 gawen>
+ Time-stamp: <2012-04-05 17:05:44 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _PURPLE_H_
#define _PURPLE_H_
#include "common.h"
#include "gtk.h"
struct pbar_prpl_signal {
void *instance;
const char *signal;
void *callback;
};
-/* not sure purple define that */
+/* not sure purple defines that */
#ifndef PURPLE_PREFS_CALLBACK
# define PURPLE_PREFS_CALLBACK(func) ((PurplePrefCallback)func)
#endif
-gboolean is_gtk_blist_created();
+gboolean is_same_song(const PurpleStatus *old, const PurpleStatus *new);
+gboolean is_gtk_blist_created(void);
GdkPixbuf * create_prpl_icon_from_info(PurplePluginProtocolInfo *prpl_info,
PidginPrplIconSize size);
-GdkPixbuf * get_buddy_icon();
-GdkPixbuf * get_buddy_icon_hover();
+GdkPixbuf * get_buddy_icon(void);
+GdkPixbuf * get_buddy_icon_hover(void);
GHashTable * get_protocol_attrs(PurplePluginProtocolInfo *protocol);
GHashTable * get_account_attrs(PurpleAccount *account);
-const gchar * get_status_stock_id();
-gchar * get_mood_icon_path();
-PurpleMood * get_global_moods();
+const gchar * get_status_stock_id(void);
+gchar * get_mood_icon_path(const gchar *mood);
+PurpleMood * get_global_moods(void);
void set_status_message(const gchar *pm);
void set_status_all(const gchar *status_id, GList *attrs);
void set_status_with_mood(PurpleAccount *account, const gchar *mood);
void set_status_with_mood_all(const gchar *mood);
void set_display_name(PurpleAccount *account, const gchar *name);
void set_display_name_all(const gchar *name);
void prpl_disconnect_signals(struct pbar_widget *w);
void prpl_prefs_disconnect_signals(struct pbar_widget *w);
void prpl_connect_signals(struct pbar_widget *w,
const struct pbar_prpl_signal *sig_list,
gpointer data);
void prpl_prefs_connect_signals(struct pbar_widget *w,
const struct pbar_prpl_signal *sig_list,
gpointer data);
#endif /* _PURPLE_H_ */
diff --git a/widget_prpl.c b/widget_prpl.c
index b98fe4d..0c45118 100644
--- a/widget_prpl.c
+++ b/widget_prpl.c
@@ -1,238 +1,265 @@
/* File: widget_prpl.c
- Time-stamp: <2011-06-17 14:42:59 gawen>
+ Time-stamp: <2012-04-05 17:22:08 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "preferences.h"
#include "widget.h"
#include "widget_prpl.h"
#include "purple.h"
+static GList * append_attr(GList *list, const gchar *id, const gchar *value)
+{
+ list = g_list_append(list, (gpointer)id);
+ return g_list_append(list, (gpointer)value);
+}
+
void cb_status(PurpleAccount *account, PurpleStatus *old, PurpleStatus *new)
{
g_return_if_fail(bar->installed);
PurpleStatusPrimitive prim;
const gchar *stock, *pm;
PurpleSavedStatus *status = purple_savedstatus_get_current();
if(purple_prefs_get_bool(PREF "/override-status")) {
pm = purple_prefs_get_string(PREF "/personal-message");
purple_savedstatus_set_message(status,pm);
purple_savedstatus_activate(status);
}
else {
const gchar *markup;
markup = purple_prefs_get_string(PREF "/personal-message-markup");
pm = purple_savedstatus_get_message(status);
if(!pm)
pm = "";
set_widget_pm(markup, pm);
purple_prefs_set_string(PREF "/personal-message", pm);
}
+ /* we should at least check for the current song,
+ if it's different we just apply the new one */
+ if(!is_same_song(old, new)) {
+ GList *a_tune = NULL;
+ const gchar *value;
+
+ value = purple_status_get_attr_string(new, PURPLE_TUNE_TITLE);
+ purple_prefs_set_string(PREF "/tune-title", value);
+ append_attr(a_tune, PURPLE_TUNE_TITLE, value);
+
+ value = purple_status_get_attr_string(new, PURPLE_TUNE_ALBUM);
+ purple_prefs_set_string(PREF "/tune-album", value);
+ append_attr(a_tune, PURPLE_TUNE_ALBUM, value);
+
+ value = purple_status_get_attr_string(new, PURPLE_TUNE_ARTIST);
+ purple_prefs_set_string(PREF "/tune-artist", value);
+ append_attr(a_tune, PURPLE_TUNE_ARTIST, value);
+
+ set_status_all("tune", a_tune);
+ g_list_free(a_tune);
+ }
+
prim = purple_savedstatus_get_type(status);
stock = pidgin_stock_id_from_status_primitive(prim);
set_widget_status(stock);
}
void cb_signed_off(PurpleConnection *gc)
{
PurpleAccount *acct = purple_connection_get_account(gc);
update_available_features(acct, FALSE);
update_available_widgets();
}
void cb_signed_on(PurpleConnection *gc)
{
const gchar *name = purple_prefs_get_string(PREF "/nickname");
PurpleAccount *account = purple_connection_get_account(gc);
set_display_name(account, name);
update_available_features(account, TRUE);
update_available_widgets();
purple_debug_info(NAME, "nickname changed to \"%s\" by signed-on account\n",
name);
if(gc && gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS) {
const gchar *mood = purple_prefs_get_string(PREF "/mood");
set_status_with_mood(account, mood);
purple_debug_info(NAME, "mood changed to \"%s\" by signed-on account\n",
mood);
}
/* load tune and stuff */
GList *a_tune = NULL;
GList *a_mood = NULL;
const struct attrs {
const gchar *pref;
const gchar *attr;
GList **list;
} attrs[] = {
{ PREF "/mood-message", PURPLE_MOOD_COMMENT, &a_mood },
{ PREF "/tune-title", PURPLE_TUNE_TITLE, &a_tune },
{ PREF "/tune-artist", PURPLE_TUNE_ARTIST, &a_tune },
{ PREF "/tune-album", PURPLE_TUNE_ALBUM, &a_tune },
{ PREF "/game-message", "game", &a_tune },
{ PREF "/office-message", "office", &a_tune },
{ NULL, NULL, NULL }
}; const register struct attrs *a = attrs;
for(; a->pref ; a++) {
const gchar *value;
if(purple_prefs_get_bool(PREF "/reset-attrs"))
value = NULL;
else
value = purple_prefs_get_string(a->pref);
if(value && !strcmp(value, ""))
value = NULL;
else
purple_debug_info(NAME, "%s message changed to \"%s\" by signed-on account\n",
a->attr, value);
*(a->list) = g_list_append(*(a->list), (gpointer)a->attr);
*(a->list) = g_list_append(*(a->list), (gpointer)value);
}
const struct status_list {
const gchar *status_id;
GList *list;
gboolean cont;
} status[] = {
{ "tune", a_tune, TRUE },
{ "mood", a_mood, TRUE },
{ NULL, NULL, FALSE}
}; register const struct status_list *s = status;
for(; s->cont ; s++) {
purple_account_set_status_list(account, s->status_id, TRUE, s->list);
g_list_free(s->list);
}
}
void cb_buddy_icon_update(const char *name, PurplePrefType type,
gconstpointer val, gpointer data)
{
g_return_if_fail(bar->installed);
GdkPixbuf *icon;
icon = get_buddy_icon();
set_widget_icon(icon);
}
void cb_name_apply(PurpleAccount *account, const char *user_info)
{
g_return_if_fail(bar->installed);
const gchar *markup, *name;
name = user_info;
markup = purple_prefs_get_string(PREF "/nickname-markup");
set_widget_name(markup, name);
purple_prefs_set_string(PREF "/nickname", name);
set_display_name_all(name);
bar->name_dialog = FALSE;
purple_debug_info(NAME, "nickname changed to \"%s\" by user\n", name);
}
void cb_name_cancel(PurpleAccount *account, const char *user_info)
{
g_return_if_fail(bar->installed);
bar->name_dialog = FALSE;
}
void cb_pm_apply(gpointer data, PurpleRequestFields *fields)
{
g_return_if_fail(bar->installed);
/* attrs */
GList *a_tune = NULL;
GList *a_mood = NULL;
/* just to update widget */
const gchar *pm = purple_request_fields_get_string(fields, PREF "/personal-message");
const gchar *markup = purple_prefs_get_string(PREF "/personal-message-markup");
set_status_message(pm);
set_widget_pm(markup, pm);
purple_debug_info(NAME, "personal message changed to \"%s\" by user\n", pm);
const struct r_field {
const gchar *id;
const gchar *attr;
GList **list;
} r_fields[] = {
{ PREF "/mood-message", PURPLE_MOOD_COMMENT, &a_mood },
{ PREF "/tune-title", PURPLE_TUNE_TITLE, &a_tune },
{ PREF "/tune-artist", PURPLE_TUNE_ARTIST, &a_tune },
{ PREF "/tune-album", PURPLE_TUNE_ALBUM, &a_tune },
{ PREF "/game-message", "game", &a_tune },
{ PREF "/office-message", "office", &a_tune },
{ NULL, NULL, NULL }
}; const register struct r_field *rf = r_fields;
for(; rf->id ; rf++) {
const gchar *value = purple_request_fields_get_string(fields, rf->id);
if(!purple_prefs_get_bool(PREF "/reset-attrs"))
purple_prefs_set_string(rf->id, value);
if(value && !strcmp(value, ""))
value = NULL;
else
purple_debug_info(NAME, "%s message changed to \"%s\" by user\n",
rf->attr, value);
- *(rf->list) = g_list_append(*(rf->list), (gpointer)rf->attr);
- *(rf->list) = g_list_append(*(rf->list), (gpointer)value);
+ *(rf->list) = append_attr(*(rf->list), rf->attr, value);
}
const struct status_list {
const gchar *status_id;
GList *list;
gboolean cont;
} status[] = {
{ "tune", a_tune, TRUE },
{ "mood", a_mood, TRUE },
{ NULL, NULL, FALSE}
}; register const struct status_list *s = status;
for(; s->cont ; s++) {
set_status_all(s->status_id, s->list);
g_list_free(s->list);
}
bar->pm_dialog = FALSE;
}
void cb_pm_cancel(gpointer data, PurpleRequestFields *fields)
{
g_return_if_fail(bar->installed);
bar->pm_dialog = FALSE;
}
|
gawen947/pidgin-pbar
|
d390d978249ca2299bc79302d4e96e739d43238e
|
Use install-dir instead of mkdir
|
diff --git a/commands.mk b/commands.mk
index 098cdee..f20758a 100644
--- a/commands.mk
+++ b/commands.mk
@@ -1,12 +1,13 @@
# defaults commands
CC=gcc
RM=rm -f
INSTALL=install
INSTALL_PROGRAM=$(INSTALL) -s -m 555
+INSTALL_DIR=$(INSTALL) -d
INSTALL_LIB=$(INSTALL) -s -m 444
INSTALL_DATA=$(INSTALL) -m 444
INSTALL_SCRIPT=$(INSTALL_PROGRAM)
XGETTEXT=xgettext
MSGFMT=msgfmt
MKDIR=mkdir
CP=cp
diff --git a/makefile b/makefile
index 4b53cb7..7cd40ce 100644
--- a/makefile
+++ b/makefile
@@ -1,84 +1,84 @@
include commands.mk
OPTS := -O2
CFLAGS := -std=c99 $(OPTS) $(shell pkg-config --cflags pidgin purple gtk+-2.0 gobject-2.0) -fPIC -Wall
LDFLAGS := $(shell pkg-config --libs pidgin purple gtk+-2.0 gobject-2.0)
SRC = $(wildcard *.c)
OBJ = $(foreach obj, $(SRC:.c=.o), $(notdir $(obj)))
DEP = $(SRC:.c=.d)
POFILES = $(wildcard *.po)
CATALOGS = $(foreach cat, $(POFILES:.po=.mo), $(notdir $(cat)))
PREFIX ?= /usr/local
LOCALEDIR ?= $(PREFIX)/share/locale
PLUGINDIR ?= $(shell pkg-config --variable=plugindir pidgin)
DATADIR ?= $(shell pkg-config --variable=datadir pidgin)
PBAR_VERSION := $(shell cat VERSION)
CFLAGS += -DVERSION="\"$(PBAR_VERSION)\""
ifndef DISABLE_DEBUG
CFLAGS += -ggdb
endif
commit = $(shell ./hash.sh)
ifneq ($(commit), UNKNOWN)
CFLAGS += -DCOMMIT="\"$(commit)\""
CFLAGS += -DPARTIAL_COMMIT="\"$(shell echo $(commit) | cut -c1-8)\""
endif
ifndef DISABLE_NLS
CFLAGS += -DENABLE_NLS=1 -DLOCALEDIR="\"$(LOCALEDIR)\""
locales := locales
install-locales := install-locales
uninstall-locales := uninstall-locales
endif
CFLAGS += -DDATADIR="\"$(DATADIR)\""
.PHONY: all clean
all: pbar.so $(locales)
pbar.so: $(OBJ)
$(CC) -shared -o $@ $^ $(LDFLAGS)
%.o: %.c
$(CC) -Wp,-MMD,$*.d -c $(CFLAGS) -o $@ $<
clean:
$(RM) $(DEP)
$(RM) $(OBJ)
$(RM) $(CATALOGS)
$(RM) messages.pot
$(RM) pbar.so
install: $(install-locales)
- $(MKDIR) -p $(DESTDIR)$(PLUGINDIR)
+ $(INSTALL_DIR) $(DESTDIR)$(PLUGINDIR)
$(INSTALL_LIB) pbar.so $(DESTDIR)$(PLUGINDIR)
uninstall: $(uninstall-locales)
$(RM) $(PLUGINDIR)/pbar.so
locales: $(CATALOGS)
CAT_INST_PATH = $(foreach lang, $(POFILES:.po=), $(DESTDIR)$(LOCALEDIR)/$(lang)/LC_MESSAGES/pidgin-pbar.mo)
install-locales: $(CAT_INST_PATH)
$(DESTDIR)$(LOCALEDIR)/%/LC_MESSAGES/pidgin-pbar.mo: %.mo
- $(MKDIR) -p $(DESTDIR)$(LOCALEDIR)/$(basename $<)/LC_MESSAGES
+ $(INSTALL_DIR) $(DESTDIR)$(LOCALEDIR)/$(basename $<)/LC_MESSAGES
$(INSTALL_DATA) $< $@
uninstall-locales:
$(RM) $(CAT_INST_PATH)
%.mo: %.po
$(MSGFMT) -c -o $@ $<
messages.pot: POTFILES.in
$(XGETTEXT) --no-wrap -m -c --files-from $< --keyword --keyword=_ --keyword=N_ -o $@
-include $(DEP)
|
gawen947/pidgin-pbar
|
daf63119c4da2590d766b765df613be9a6ce8a55
|
Fix typo in README
|
diff --git a/README b/README
index 71cec2a..f435f6e 100644
--- a/README
+++ b/README
@@ -1,32 +1,32 @@
Pidgin PBar
===========
This Pidgin plugin adds a toolbar to the buddy list to quickly update nickname,
personal message, icon, status and mood. It also allows updating the current
song and other parameters which are updated globally on all accounts that
support them.
INSTALLATION
============
-You will need a C compiler like gcc, make and the following depencies :
+You will need a C compiler like gcc, make and the following dependencies :
- pidgin-dev
- gtk2-dev
- pkg-config
On Debian use the following command as root to install the required packages :
# aptitude install pidgin-dev libgtk2.0-dev pkg-config make gcc libc6-dev
Then enter the following command :
$ make
$ sudo make install
This will install the plugin and locales.
The following flags are also available to enable/disable somes features :
- DISABLE_NLS (enabled by default)
- DISABLE_DEBUG (enabled by default)
Please take advice that BSD make probably won't work, you need to use gmake
instead.
|
gawen947/pidgin-pbar
|
87c3b1756f89b4dee6bed7220cc30e5d9039d945
|
Clean makefile
|
diff --git a/commands.mk b/commands.mk
index c8c22ff..098cdee 100644
--- a/commands.mk
+++ b/commands.mk
@@ -1,11 +1,12 @@
# defaults commands
CC=gcc
RM=rm -f
INSTALL=install
-INSTALL_PROGRAM=install -s -m 555
+INSTALL_PROGRAM=$(INSTALL) -s -m 555
+INSTALL_LIB=$(INSTALL) -s -m 444
INSTALL_DATA=$(INSTALL) -m 444
INSTALL_SCRIPT=$(INSTALL_PROGRAM)
XGETTEXT=xgettext
MSGFMT=msgfmt
MKDIR=mkdir
-CP=cp
\ No newline at end of file
+CP=cp
diff --git a/makefile b/makefile
index 9462651..4b53cb7 100644
--- a/makefile
+++ b/makefile
@@ -1,84 +1,84 @@
include commands.mk
OPTS := -O2
CFLAGS := -std=c99 $(OPTS) $(shell pkg-config --cflags pidgin purple gtk+-2.0 gobject-2.0) -fPIC -Wall
LDFLAGS := $(shell pkg-config --libs pidgin purple gtk+-2.0 gobject-2.0)
SRC = $(wildcard *.c)
OBJ = $(foreach obj, $(SRC:.c=.o), $(notdir $(obj)))
DEP = $(SRC:.c=.d)
POFILES = $(wildcard *.po)
CATALOGS = $(foreach cat, $(POFILES:.po=.mo), $(notdir $(cat)))
PREFIX ?= /usr/local
LOCALEDIR ?= $(PREFIX)/share/locale
PLUGINDIR ?= $(shell pkg-config --variable=plugindir pidgin)
DATADIR ?= $(shell pkg-config --variable=datadir pidgin)
PBAR_VERSION := $(shell cat VERSION)
CFLAGS += -DVERSION="\"$(PBAR_VERSION)\""
ifndef DISABLE_DEBUG
CFLAGS += -ggdb
endif
commit = $(shell ./hash.sh)
ifneq ($(commit), UNKNOWN)
CFLAGS += -DCOMMIT="\"$(commit)\""
CFLAGS += -DPARTIAL_COMMIT="\"$(shell echo $(commit) | cut -c1-8)\""
endif
ifndef DISABLE_NLS
CFLAGS += -DENABLE_NLS=1 -DLOCALEDIR="\"$(LOCALEDIR)\""
locales := locales
install-locales := install-locales
uninstall-locales := uninstall-locales
endif
CFLAGS += -DDATADIR="\"$(DATADIR)\""
.PHONY: all clean
all: pbar.so $(locales)
pbar.so: $(OBJ)
$(CC) -shared -o $@ $^ $(LDFLAGS)
%.o: %.c
$(CC) -Wp,-MMD,$*.d -c $(CFLAGS) -o $@ $<
clean:
$(RM) $(DEP)
$(RM) $(OBJ)
$(RM) $(CATALOGS)
$(RM) messages.pot
$(RM) pbar.so
install: $(install-locales)
$(MKDIR) -p $(DESTDIR)$(PLUGINDIR)
- $(INSTALL_PROGRAM) pbar.so $(DESTDIR)$(PLUGINDIR)
+ $(INSTALL_LIB) pbar.so $(DESTDIR)$(PLUGINDIR)
uninstall: $(uninstall-locales)
$(RM) $(PLUGINDIR)/pbar.so
locales: $(CATALOGS)
CAT_INST_PATH = $(foreach lang, $(POFILES:.po=), $(DESTDIR)$(LOCALEDIR)/$(lang)/LC_MESSAGES/pidgin-pbar.mo)
install-locales: $(CAT_INST_PATH)
$(DESTDIR)$(LOCALEDIR)/%/LC_MESSAGES/pidgin-pbar.mo: %.mo
$(MKDIR) -p $(DESTDIR)$(LOCALEDIR)/$(basename $<)/LC_MESSAGES
$(INSTALL_DATA) $< $@
uninstall-locales:
$(RM) $(CAT_INST_PATH)
%.mo: %.po
$(MSGFMT) -c -o $@ $<
messages.pot: POTFILES.in
$(XGETTEXT) --no-wrap -m -c --files-from $< --keyword --keyword=_ --keyword=N_ -o $@
-include $(DEP)
|
gawen947/pidgin-pbar
|
09bb281e990e252339b2a34fde0f2ac1cd653f93
|
Set gtk settings (for Windows) just before widget creation
|
diff --git a/pbar.c b/pbar.c
index 9f88c6c..48f5462 100644
--- a/pbar.c
+++ b/pbar.c
@@ -1,142 +1,135 @@
/* File: pbar.c
Time-stamp: <2011-09-17 01:29:53 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#define PURPLE_PLUGINS
#include "common.h"
#include "pbar.h"
#include "actions.h"
#include "preferences.h"
#include "widget.h"
#include "purple.h"
static gboolean plugin_load(PurplePlugin *plugin);
static gboolean plugin_unload(PurplePlugin *plugin);
static PidginPluginUiInfo ui_info = { get_config_frame };
static PurplePluginInfo info = {
PURPLE_PLUGIN_MAGIC,
PURPLE_MAJOR_VERSION,
PURPLE_MINOR_VERSION,
PURPLE_PLUGIN_STANDARD,
PIDGIN_PLUGIN_TYPE,
0,
NULL,
PURPLE_PRIORITY_DEFAULT,
PLUGIN_ID,
NULL, /* defined later for NLS */
PLUGIN_VERSION,
NULL, /* defined later for NLS */
NULL, /* defined later for NLS */
PLUGIN_AUTHOR,
PLUGIN_WEBSITE,
plugin_load,
plugin_unload,
NULL,
&ui_info,
NULL,
NULL,
create_actions,
NULL,
NULL,
NULL,
NULL
};
PurplePlugin *thisplugin;
/* we need this callback to catch
blist construction and install
widget when we may do so */
static void cb_blist_created(GtkWidget *widget, gpointer data)
{
/* create widget and
load preferences */
create_widget();
init_widget();
}
static gboolean plugin_load(PurplePlugin *plugin)
{
/* connect construction signal only when needed
as when installing the plugin after launching
pidgin there is no need to wait for blist
creation */
if(is_gtk_blist_created()) {
/* create widget and
load preferences */
create_widget();
init_widget();
}
else
/* connect construction signal */
purple_signal_connect(pidgin_blist_get_handle(),
"gtkblist-created",
plugin,
PURPLE_CALLBACK(cb_blist_created),
NULL);
purple_debug_info(NAME,"plugin initialized...\n");
return TRUE;
}
static gboolean plugin_unload(PurplePlugin *plugin)
{
-#ifdef _WIN32
- /* force gtk-button-images to 1 on Windows,
- otherwise, mood and status images won't
- be displayed */
- GtkSettings *settings = gtk_settings_get_default();
- gtk_settings_set_long_property(settings, "gtk-button-images", 1, "gtkrc:21");
-#endif /* _WIN32 */
/* destroy widget and free memory */
destroy_widget();
/* restore statusbox */
set_statusbox_visible(TRUE);
purple_debug_info(NAME,"plugin destroyed...\n");
return TRUE;
}
static void init_plugin(PurplePlugin *plugin)
{
thisplugin = plugin;
#ifdef ENABLE_NLS
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
#endif /* ENABLE_NLS */
/* translate name, summary and description */
info.name = _(PLUGIN_NAME);
info.summary = _(PLUGIN_SUMMARY);
info.description = _(PLUGIN_DESCRIPTION);
/* load or create preferences */
init_prefs();
}
PURPLE_INIT_PLUGIN(pbar, init_plugin, info)
diff --git a/widget.c b/widget.c
index bda8b5c..d073143 100644
--- a/widget.c
+++ b/widget.c
@@ -1,556 +1,564 @@
/* File: widget.c
Time-stamp: <2011-08-26 18:48:52 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "pbar.h"
#include "widget.h"
#include "widget_gtk.h"
#include "widget_prpl.h"
#include "preferences.h"
#include "purple.h"
#include "gtk.h"
/* we only have one widget per plugin
but this might change in the future */
struct widget *bar;
void create_widget()
{
/* we need this when the bar is reset for example
using the preferences dialog */
if(!bar) {
bar = g_malloc(sizeof(struct widget));
memset(bar, 0, sizeof(struct widget));
check_available_features();
}
+#ifdef _WIN32
+ /* force gtk-button-images to 1 on Windows,
+ otherwise, mood and status images won't
+ be displayed */
+ GtkSettings *settings = gtk_settings_get_default();
+ gtk_settings_set_long_property(settings, "gtk-button-images", 1, "gtkrc:21");
+#endif /* _WIN32 */
+
/* widgets that can possibly be modified along plugin's execution */
bar->icon = gtk_image_new();
bar->status = gtk_button_new_from_stock(NULL);
bar->mood = gtk_button_new_from_stock(NULL);
bar->name_label = gtk_label_new(NULL);
bar->name_eventbox = gtk_event_box_new();
bar->name_entry = gtk_entry_new();
bar->pm_label = gtk_label_new(NULL);
bar->pm_eventbox = gtk_event_box_new();
bar->pm_entry = gtk_entry_new();
bar->hbox = gtk_hbox_new(FALSE, 2);
bar->icon_eventbox = gtk_event_box_new();
bar->status_menu = gtk_menu_new();
bar->mood_menu = gtk_menu_new();
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(bar), bar->hbox);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->status_menu);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->mood_menu);
/* widgets that are not modified */
GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
GtkWidget *hbox1 = gtk_hbox_new(FALSE, 2);
GtkWidget *hbox2 = gtk_hbox_new(FALSE, 2);
/* setup widgets */
gtk_label_set_ellipsize(GTK_LABEL(bar->name_label), PANGO_ELLIPSIZE_END);
gtk_label_set_ellipsize(GTK_LABEL(bar->pm_label), PANGO_ELLIPSIZE_END);
gtk_label_set_max_width_chars(GTK_LABEL(bar->name_label), 50);
gtk_button_set_relief(GTK_BUTTON(bar->status), GTK_RELIEF_NONE);
gtk_button_set_relief(GTK_BUTTON(bar->mood), GTK_RELIEF_NONE);
gtk_widget_set_can_focus(bar->name_eventbox, FALSE);
gtk_widget_set_can_focus(bar->pm_eventbox, FALSE);
gtk_widget_set_can_focus(bar->status, FALSE);
gtk_widget_set_can_focus(bar->mood, FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->icon_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->name_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->pm_eventbox), FALSE);
/* pack widgets */
gtk_container_add(GTK_CONTAINER(bar->name_eventbox), bar->name_label);
gtk_container_add(GTK_CONTAINER(bar->pm_eventbox), bar->pm_label);
gtk_container_add(GTK_CONTAINER(bar->icon_eventbox), bar->icon);
if(purple_prefs_get_bool(PREF "/compact")) {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
}
else {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0);
}
gtk_box_pack_start(GTK_BOX(bar->hbox), bar->icon_eventbox, FALSE, FALSE, 5);
gtk_box_pack_start(GTK_BOX(bar->hbox), vbox, TRUE, TRUE, 0);
/* pack at top of the buddy list and fallback to top
if the position option is unknown */
void (*gtk_box_pack)(GtkBox *, GtkWidget *, gboolean, gboolean, guint) = gtk_box_pack_start;
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
switch(purple_prefs_get_int(PREF "/widget-position")) {
case(POSITION_TOP):
gtk_box_pack = gtk_box_pack_start;
break;
case(POSITION_BOTTOM):
gtk_box_pack = gtk_box_pack_end;
break;
};
gtk_box_pack(GTK_BOX(blist->vbox), bar->hbox, FALSE, TRUE, 2);
gtk_box_reorder_child(GTK_BOX(blist->vbox), bar->hbox, 0);
/* setup initial states */
bar->gtk_hnd = NULL;
bar->gtk_inst = NULL;
bar->hover_name = FALSE;
bar->hover_pm = FALSE;
bar->name_entry_activated = FALSE;
bar->pm_entry_activated = FALSE;
bar->name_dialog = FALSE;
bar->pm_dialog = FALSE;
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ bar->icon_eventbox, "button-press-event", cb_buddy_icon },
{ bar->icon_eventbox, "enter-notify-event", cb_buddy_icon_enter },
{ bar->icon_eventbox, "leave-notify-event", cb_buddy_icon_leave },
{ bar->name_eventbox, "button-press-event", cb_name },
{ bar->name_eventbox, "enter-notify-event", cb_name_enter },
{ bar->name_eventbox, "leave-notify-event", cb_name_leave },
{ bar->name_entry, "activate", cb_name_entry },
{ bar->name_entry, "focus-out-event", cb_name_entry_focus_out },
{ bar->pm_eventbox, "button-press-event", cb_pm },
{ bar->pm_eventbox, "enter-notify-event", cb_pm_enter },
{ bar->pm_eventbox, "leave-notify-event", cb_pm_leave },
{ bar->pm_entry, "activate", cb_pm_entry },
{ bar->pm_entry, "focus-out-event", cb_pm_entry_focus_out },
{ bar->status, "clicked", cb_status_button },
{ bar->mood, "clicked", cb_mood_button },
{ NULL, NULL, NULL }
};
/* purple signals and callback */
const struct pbar_prpl_signal p_signal_connections[] = {
{ purple_accounts_get_handle(), "account-status-changed", cb_status },
{ purple_connections_get_handle(), "signed-on", cb_signed_on },
{ purple_connections_get_handle(), "signed-off", cb_signed_off },
{ NULL, NULL, NULL }
};
/* purple preferences signals and callback */
const struct pbar_prpl_signal pp_signal_connections[] = {
{ bar, PIDGIN_PREFS_ROOT "/accounts/buddyicon", cb_buddy_icon_update },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(bar), g_signal_connections, NULL);
prpl_connect_signals(PBAR_WIDGET(bar), p_signal_connections, NULL);
prpl_prefs_connect_signals(PBAR_WIDGET(bar), pp_signal_connections, NULL);
/* show everything */
gtk_widget_show_all(bar->hbox);
gtk_widget_hide(bar->name_entry);
gtk_widget_hide(bar->pm_entry);
/* inform that the bar is installed */
widget_set_all_sensitive(FALSE);
update_available_widgets();
bar->installed = TRUE;
}
static void free_inner_widget()
{
g_return_if_fail(bar->installed);
bar->installed = FALSE;
/* disconnect purple and prefs signals */
prpl_disconnect_signals(PBAR_WIDGET(bar));
prpl_prefs_disconnect_signals(PBAR_WIDGET(bar));
gtk_destroy(PBAR_WIDGET(bar)); /* destroy widgets */
}
void reset_widget()
{
free_inner_widget();
/* create widget but do not free the structure itself
to save references for available features */
create_widget();
}
void destroy_widget()
{
free_inner_widget();
g_free(bar); /* free widget */
bar = NULL;
}
/* load preferences into our widget */
void init_widget()
{
g_return_if_fail(bar->installed);
/* entry frame */
gboolean state = purple_prefs_get_bool(PREF "/frame-entry");
set_widget_entry_frame(state);
/* nickname */
const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup");
const gchar *value = purple_prefs_get_string(PREF "/nickname");
int jtype = purple_prefs_get_int(PREF "/nickname-justify");
set_widget_name(markup, value);
set_widget_name_justify(jtype);
/* personal message */
markup = purple_prefs_get_string(PREF "/personal-message-markup");
value = purple_prefs_get_string(PREF "/personal-message");
jtype = purple_prefs_get_int(PREF "/personal-message-justify");
set_widget_pm(markup, value);
set_widget_pm_justify(jtype);
/* buddy icon */
GdkPixbuf *icon = get_buddy_icon();
set_widget_icon(icon);
/* mood image */
const gchar *current_mood = purple_prefs_get_string(PREF "/mood");
gchar *path = get_mood_icon_path(current_mood);
set_widget_mood(path);
g_free(path);
/* status image */
const gchar *stock = get_status_stock_id();
set_widget_status(stock);
/* fill status menu */
GList *accts = purple_accounts_get_all_active();
GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = (PurpleAccount *)accts->data;
GList *types = purple_account_get_status_types(account);
for(; types ; types = types->next) {
PurpleStatusType *type = (PurpleStatusType *)types->data;
PurpleStatusPrimitive prim;
const gchar *stock, *status_name;
GtkWidget *menu_item, *icon;
if(!purple_status_type_is_user_settable(type) ||
purple_status_type_is_independent(type))
continue;
prim = purple_status_type_get_primitive(type);
stock = pidgin_stock_id_from_status_primitive(prim);
if(g_hash_table_lookup(global_status, stock))
continue;
else
g_hash_table_insert(global_status, (gpointer)stock,
GINT_TO_POINTER(TRUE));
status_name = purple_status_type_get_name(type);
menu_item = gtk_image_menu_item_new_with_label(status_name);
icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), icon);
gtk_menu_shell_append(GTK_MENU_SHELL(bar->status_menu), menu_item);
g_signal_connect_swapped(menu_item, "activate",
G_CALLBACK(cb_status_menu),
(gpointer)type);
gtk_widget_show(menu_item);
}
}
g_hash_table_destroy(global_status);
/* statusbox hiding */
state = purple_prefs_get_bool(PREF "/hide-statusbox");
set_statusbox_visible(!state);
}
/* create a change name dialog */
void create_name_dialog()
{
const gchar *name = purple_prefs_get_string(PREF "/nickname");
if(!name || !strcmp(name, EMPTY_NAME))
name = "";
purple_request_input(thisplugin,
_("Change nickname"),
_("Enter your nickname here..."),
_("This will change your nickname "
"for every account which supports it."),
name,
FALSE,
FALSE,
NULL,
_("OK"),
G_CALLBACK(cb_name_apply),
_("Cancel"),
G_CALLBACK(cb_name_cancel),
NULL,
NULL,
NULL,
NULL);
bar->name_dialog = TRUE;
}
/* disable every features of the widget */
void widget_set_all_sensitive(gboolean sensitive)
{
GtkWidget *widgets[] = {
bar->icon,
bar->icon_eventbox,
bar->status,
bar->status_menu,
bar->mood,
bar->mood_menu,
bar->name_label,
bar->name_eventbox,
bar->name_entry,
bar->pm_label,
bar->pm_eventbox,
bar->pm_entry,
NULL
}; GtkWidget **w = widgets;
gboolean *attrs[] = {
&bar->mood_message,
&bar->current_song,
&bar->song_title,
&bar->song_album,
&bar->game_name,
&bar->office_app,
NULL
}; gboolean **a = attrs;
for(; *w ; w++)
gtk_widget_set_sensitive(*w, sensitive);
for(; *a ; a++)
**a = sensitive;
}
#define assert_ref(count, inc) (bar->count > 0 || inc > 0)
void check_available_features()
{
GList *a = purple_accounts_get_all_active();
for(; a ; a = a->next) {
PurpleAccount *acct = (PurpleAccount *)a->data;
if(purple_account_is_connected(acct))
update_available_features(acct, TRUE);
}
}
/* enable/disable features when an account changes */
void update_available_features(PurpleAccount *acct, gboolean enable)
{
int inc = 1;
PurplePlugin *plugin = purple_find_prpl(acct->protocol_id);
PurplePluginProtocolInfo *protocol = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
GHashTable *attrs = get_account_attrs(acct);
if(!enable)
inc = -1;
/* update references */
if(g_hash_table_lookup(attrs, "mood") &&
assert_ref(mood_ref, inc))
bar->mood_ref += inc;
if(g_hash_table_lookup(attrs, "moodtext") &&
assert_ref(mood_message_ref, inc))
bar->mood_message_ref += inc;
if(g_hash_table_lookup(attrs, "game") && assert_ref(game_name_ref, inc))
bar->game_name_ref += inc;
if(g_hash_table_lookup(attrs, "office") && assert_ref(office_app_ref, inc))
bar->office_app_ref += inc;
if(g_hash_table_lookup(attrs, "tune_title") &&
g_hash_table_lookup(attrs, "tune_artist") &&
g_hash_table_lookup(attrs, "tune_album") &&
assert_ref(current_song_ref, inc))
bar->current_song_ref += inc;
if(protocol->set_status && assert_ref(pm_ref, inc))
bar->pm_ref += inc;
if(protocol->set_buddy_icon && assert_ref(icon_ref, inc))
bar->icon_ref += inc;
if((!strcmp(acct->protocol_id, "prpl-jabber") || protocol->set_public_alias)&&
assert_ref(name_ref, inc))
bar->name_ref += inc;
if(assert_ref(status_ref, inc))
bar->status_ref += inc;
}
void update_available_widgets()
{
PurpleMood *mood = get_global_moods();
const struct s_widget {
GtkWidget *widget;
gboolean sensitive;
} widgets[] = {
{ bar->icon, bar->icon_ref },
{ bar->icon_eventbox, bar->icon_ref },
{ bar->status, bar->status_ref },
{ bar->status_menu, bar->status_ref },
{ bar->mood, bar->mood_ref && mood->mood },
{ bar->mood_menu, bar->mood_ref && mood->mood },
{ bar->name_label, bar->name_ref },
{ bar->name_eventbox, bar->name_ref },
{ bar->name_entry, bar->name_ref },
{ bar->pm_label, bar->pm_ref + bar->mood_message_ref + bar->game_name_ref +\
bar->office_app_ref + bar->current_song_ref },
{ bar->pm_eventbox, bar->pm_ref + bar->mood_message_ref+bar->game_name_ref+\
bar->office_app_ref + bar->current_song_ref },
{ bar->pm_entry, bar->pm_ref + bar->mood_message_ref + bar->game_name_ref +\
bar->office_app_ref + bar->current_song_ref },
{ NULL, FALSE }
}; const struct s_widget *w = widgets;
const struct s_attr {
gboolean *attr;
gboolean sensitive;
} attrs[] = {
{ &bar->pm_message, bar->pm_ref },
{ &bar->mood_message, bar->mood_message_ref && mood->mood },
{ &bar->current_song, bar->current_song_ref },
{ &bar->song_title, bar->current_song_ref },
{ &bar->song_album, bar->current_song_ref },
{ &bar->game_name, bar->game_name },
{ &bar->office_app, bar->office_app },
{ NULL, FALSE }
}; const struct s_attr *a = attrs;
for(; w->widget ; w++)
gtk_widget_set_sensitive(w->widget, w->sensitive);
for(; a->attr ; a++)
*a->attr = a->sensitive;
}
/* create a personal message dialog */
void create_pm_dialog()
{
PurpleRequestFields *fields;
PurpleRequestFieldGroup *group;
PurpleRequestField *field;
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
if(!pm || !strcmp(pm, EMPTY_PM))
pm = "";
const struct s_field {
const gchar *text;
const gchar *pref;
gboolean enable;
} groups[] = {
{ N_("_Mood message"), PREF "/mood-message", bar->mood_message },
{ N_("Current song"), NULL, bar->current_song },
{ N_("Song _title"), PREF "/tune-title", bar->current_song },
{ N_("Song _artist"), PREF "/tune-artist", bar->song_title },
{ N_("Song al_bum"), PREF "/tune-album", bar->song_album },
{ N_("MSN pecan extra attributes"), NULL, bar->game_name && bar->office_app },
{ N_("_Game name"), PREF "/game-message", bar->game_name },
{ N_("_Office app name"), PREF "/office-message", bar->office_app },
{ NULL, NULL },
{ NULL, NULL }
}; const struct s_field *g = groups;
fields = purple_request_fields_new();
group = purple_request_field_group_new(_("Status and mood message"));
purple_request_fields_add_group(fields, group);
if(bar->pm_message) {
field = purple_request_field_string_new(PREF "/personal-message",
_("_Personal message"),
pm,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
for(; g->pref ; g++) {
for(; g->pref ; g++) {
const gchar *message;
if(!g->enable)
continue;
else if(purple_prefs_get_bool(PREF "/reset-attrs"))
message = "";
else
message = purple_prefs_get_string(g->pref);
field = purple_request_field_string_new(g->pref,
_(g->text),
message,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
if(g->enable) {
group = purple_request_field_group_new(_(g->text));
purple_request_fields_add_group(fields, group);
}
}
purple_request_fields(thisplugin,
_("Change status messages"),
_("Enter status message..."),
_("This will change some status messages for every "
"account which supports it, please be advised "
"that some are inconsistent between each other."),
fields,
_("OK"),
G_CALLBACK(cb_pm_apply),
_("Cancel"),
G_CALLBACK(cb_pm_cancel),
NULL, NULL, NULL, NULL);
bar->pm_dialog = TRUE;
}
/* replace format character <c><r> with <n> string and escape with <c><c> */
static gchar * g_strreplacefmt(const gchar *s, gchar c, gchar r, const gchar *n)
{
int sn = strlen(n);
int sr = strlen(s);
int index = 0;
gchar *ret = g_malloc(sr);
for(; *s != '\0' ; s++) {
if(*s == c) {
s++;
if(*s == r) {
const gchar *i = n;
sr += sn;
ret = g_realloc(ret, sr);
for(; *i != '\0' ; i++, index++)
ret[index] = *i;
|
gawen947/pidgin-pbar
|
5bd2e7ef6f45ea5b17c8598bdf0e25f9d3b2f98e
|
Release 0.3
|
diff --git a/VERSION b/VERSION
index bef10a1..be58634 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.3-git
+0.3
|
gawen947/pidgin-pbar
|
e5360246b003335f92d095346cf14afdf54f23dc
|
Add ChangeLog
|
diff --git a/ChangeLog b/ChangeLog
index 69783a9..8594dcd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,20 +1,21 @@
-* Sat Sep 17 2011 David Hauweele <[email protected]>
+* Sat Sep 18 2011 David Hauweele <[email protected]>
- Fix a bug in preference tooltip which state '%m' instead of '%p'
- Add a makefile for Windows
- Add an installer for Windows
- Fix status and mood icons that did not show up correctly on Windows
+ - Release 0.3
* Wed Jun 22 2011 David Hauweele <[email protected]>
- Fix cursor bug
- Fix makefile to ease packaging
- Fix compilation against Gtk 2.12
- Add features dialogs
- Add dialogs to change attributes through Pidgin's tools menu
- Change contact addresses
- Add tooltips to preferences dialog
- Disable features when no connected account supporting them
- Clean code
- Release 0.2
* Wed Jan 5 2010 David Hauweele <[email protected]>
- Release 0.1
|
gawen947/pidgin-pbar
|
a1800006552702a85294912ca3c009f0a0a2064f
|
Add Dutch translation
|
diff --git a/nsis/dutch.nsh b/nsis/dutch.nsh
index cf83c68..c474260 100644
--- a/nsis/dutch.nsh
+++ b/nsis/dutch.nsh
@@ -1,39 +1,39 @@
;;
;; english.nsh
;;
;; Default language strings for the Windows PBar NSIS installer.
;; Windows Code page: 1252
;; Language Code: 1033
;;
; Startup Pidgin check
-LangString PIDGIN_NEEDED ${LANG_ENGLISH} "PBar requires that Pidgin be installed. You must install Pidgin before installing PBar."
+LangString PIDGIN_NEEDED ${LANG_DUTCH} "PBar vereist dat Pidgin word geinstalleerd. U moet Pidgin installeeren voordat U PBar installeerd."
-LangString PBAR_TITLE ${LANG_ENGLISH} "PBar plugin for Pidgin"
+LangString PBAR_TITLE ${LANG_DUTCH} "PBar plugin voor Pidgin"
-LangString BAD_PIDGIN_VERSION_1 ${LANG_ENGLISH} "Incompatible version.$\r$\n$\r$\nThis version of the PBar plugin was built for Pidgin version ${PIDGIN_VERSION}. It appears that you have Pidgin version"
+LangString BAD_PIDGIN_VERSION_1 ${LANG_DUTCH} "Incompatipele versie.$\r$\n$\r$\ndeze versie van de Pbar plugin werd gebouwd voor de pidgin-versie ${PIDGIN_VERSION}. het lijkt erop dat je Pidgin-versie hebt"
-LangString BAD_PIDGIN_VERSION_2 ${LANG_ENGLISH} "installed.$\r$\n$\r$\nSee http://www.hauweele.net/~gawen/pidgin-pbar.html for more information."
+LangString BAD_PIDGIN_VERSION_2 ${LANG_DUTCH} "geïnstalleerd.$\r$\n$\r$\nSee http://www.hauweele.net/~gawen/pidgin-pbar.html voor meer informatie."
-LangString NO_PIDGIN_VERSION ${LANG_ENGLISH} "Unable to determine installed Pidgin version."
+LangString NO_PIDGIN_VERSION ${LANG_DUTCH} "onbekwaam om de geïnstalleerde versie te bepalen."
; Overrides for default text in windows:
-LangString WELCOME_TITLE ${LANG_ENGLISH} "PBar v${PBAR_VERSION} Installer"
-LangString WELCOME_TEXT ${LANG_ENGLISH} "Note: This version of the plugin is designed for Pidgin ${PIDGIN_VERSION}, and will not install or function with versions of Pidgin having a different major version number.\r\n\r\nWhen you upgrade your version of Pidgin, you must uninstall or upgrade this plugin as well.\r\n\r\n"
+LangString WELCOME_TITLE ${LANG_DUTCH} "PBar v${PBAR_VERSION} Installieprogramma"
+LangString WELCOME_TEXT ${LANG_DUTCH} "Opmerking : Deze versie van de plugin is ontworpen voor Pidgin ${PIDGIN_VERSION}, en zal niet installeren of funktioneren met een versie van Pidgin met een verschillend hoofdversienummer.\r\n\r\nWanneer U uw versie van Pidgin upgradeerd, moet u de plugin verwijderen of ook upgraden.\r\n\r\n"
-LangString DIR_SUBTITLE ${LANG_ENGLISH} "Please locate the directory where Pidgin is installed"
-LangString DIR_INNERTEXT ${LANG_ENGLISH} "Install in this Pidgin folder:"
+LangString DIR_SUBTITLE ${LANG_DUTCH} "Gelieve de directory waar pidgin geïnstalleerd is te zoeken"
+LangString DIR_INNERTEXT ${LANG_DUTCH} "installeren in deze Pidgin folder:"
-LangString FINISH_TITLE ${LANG_ENGLISH} "PBar v${PBAR_VERSION} Install Complete"
-LangString FINISH_TEXT ${LANG_ENGLISH} "You will need to restart Pidgin for the plugin to be loaded, then go the Pidgin preferences and enable the PBar Plugin."
+LangString FINISH_TITLE ${LANG_DUTCH} "PBar v${PBAR_VERSION} de installatie is voltooid"
+LangString FINISH_TEXT ${LANG_DUTCH} "U moet Pidgin restarten om de plugin te laden, ga dan naar de Pidgin voorkeuren om de Pbar plugin te aktiveren."
; during install uninstaller
-LangString PBAR_PROMPT_WIPEOUT ${LANG_ENGLISH} "The pbar.dll plugin is about to be deleted from your Pidgin/plugins directory. Continue?"
+LangString PBAR_PROMPT_WIPEOUT ${LANG_DUTCH} "De pbar.dll plugin zal van uw Pidgin/plugins directory worden verwijderd. Doorgaan ?"
; for windows uninstall
-LangString PBAR_UNINSTALL_DESC ${LANG_ENGLISH} "PBar Plugin (remove only)"
-LangString un.PBAR_UNINSTALL_ERROR_1 ${LANG_ENGLISH} "The uninstaller could not find registry entries for PBar.$\rIt is likely that another user installed the plugin."
-LangString un.PBAR_UNINSTALL_ERROR_2 ${LANG_ENGLISH} "You do not have the permissions necessary to uninstall the plugin."
+LangString PBAR_UNINSTALL_DESC ${LANG_DUTCH} "PBar Plugin (Alleen verwijderen)"
+LangString un.PBAR_UNINSTALL_ERROR_1 ${LANG_DUTCH} "De deïnstallatieprogramma kon de registervermeldingen voor PBar niet vinden.$\rIt het is mogelijk dat een andere gebruiker de plugin geïnstalleerd heeft."
+LangString un.PBAR_UNINSTALL_ERROR_2 ${LANG_DUTCH} "U heeft de nodige toestemmingen niet om de plugin te verwijderen."
|
gawen947/pidgin-pbar
|
bf05a85e83d9eb24169023e9e2bd826277010e89
|
Add German translation
|
diff --git a/de.po b/de.po
index d51c40e..264d54a 100644
--- a/de.po
+++ b/de.po
@@ -1,375 +1,375 @@
# Pidgin PBar German translation
# Copyright (C) 2010, Marleen Bekaert <[email protected]>
# This file is distributed under the same license as the Pidgin PBar package.
# Marleen Bekaert <[email protected]>, 2010
#
msgid ""
msgstr ""
"Project-Id-Version: nl\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-06-22 11:04+0200\n"
-"PO-Revision-Date: 2011-06-22 12:40+0100\n"
-"Last-Translator: Bekaert Marleen <[email protected]>\n"
+"POT-Creation-Date: 2011-09-17 19:15+0200\n"
+"PO-Revision-Date: 2011-09-17 19:24+0100\n"
+"Last-Translator: David Hauweele <[email protected]>\n"
"Language-Team: German <[email protected]>\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. name
#. internal name
#: pbar.h:36
msgid "PBar"
msgstr "PBar"
-#: pbar.h:48
+#: pbar.h:50
msgid "A toolbar to update some account settings globally."
msgstr "Eine Symbolleiste um manche Konto Einstellungen vollständig zu aktualisieren."
-#: pbar.h:50
+#: pbar.h:52
msgid "Adds a toolbar to the buddy list to quickly update nickname, personal message, icon, status and mood. It also allows updating of the current song and other parameters which are updated globally on all accounts that support them."
msgstr "Fügt eine Symbolleiste zu der Buddy-liste um schnell den Spitzname, den Persönlichen Bericht, die Ikone, den Status und die Stimmung schnell zu ändern. Erlaubt auch um das aktuelle Lied und anderen parameter die global aktualisiert werden auf alle Account die es ertragen ."
#. widgets that can possibly be modified along dialog lifetime
#: protocol_features.c:63
#: actions.c:92
msgid "Protocol features"
msgstr "Protokoll Funktionen"
#. widgets that are not modified
#: protocol_features.c:83
#: acct_features.c:84
msgid "Available features..."
msgstr "verfügbaren Funktionen..."
#: protocol_features.c:84
msgid "The following list shows the available features for each protocol."
msgstr "Die folgende Liste zeigt die verfügbaren Funktionen für jedes Protokoll."
#: protocol_features.c:100
msgid "Protocol"
msgstr "Protokoll"
#: protocol_features.c:116
#: acct_features.c:119
msgid "Nickname"
msgstr "Spitzname Tag"
#: protocol_features.c:117
#: acct_features.c:120
msgid "Status message"
msgstr "Status Nachricht"
#: protocol_features.c:118
#: acct_features.c:121
msgid "Buddy icon"
msgstr "Buddy Ikone"
#: protocol_features.c:119
#: acct_features.c:122
#: mood_dialog.c:133
msgid "Mood"
msgstr "Stimmung"
#: protocol_features.c:120
#: acct_features.c:123
msgid "Mood message"
msgstr "Stimmung Nachricht"
#: protocol_features.c:121
#: acct_features.c:124
msgid "Tune"
msgstr "Lied"
#: protocol_features.c:122
#: acct_features.c:125
msgid "Game"
msgstr "Spiel"
#: protocol_features.c:123
#: acct_features.c:126
msgid "App."
msgstr "App."
#. widgets that can possibly be modified along dialog lifetime
#: acct_features.c:64
#: actions.c:93
msgid "Account features"
msgstr "Konto Funktionen"
#: acct_features.c:85
msgid "The following list shows the available features for each activated account. The last line summarizes features that have an impact on at least one account."
msgstr "Die folgende Liste zeigt die verfügbaren Funktionen für jeden aktivierten Konto, die letzte Zeile fasst funktionen, die einen Einfluss auf mindestens ein konto haben."
#: acct_features.c:103
msgid "Account"
msgstr "Konto"
#. widgets that can be modifier along dialog lifetime
#: status_dialog.c:100
msgid "Status selection"
msgstr "Status Auswahl"
#. widgets that are not modified
#: status_dialog.c:115
msgid "Select your status..."
msgstr "Wählen Sie Ihren Satus ..."
#: status_dialog.c:116
msgid "This will change your current status for every account which supports it."
msgstr "ändernt ihr Spitzname für jedes Konto die es ertragt."
#: status_dialog.c:132
msgid "Status"
msgstr "Status"
#. widgets that can be modifier along dialog lifetime
#: mood_dialog.c:101
msgid "Mood selection"
msgstr "Stimmung Auswahl"
#. widgets that are not modified
#: mood_dialog.c:116
msgid "Select your mood..."
msgstr "Wählen Sie Ihre Stimmung..."
#: mood_dialog.c:117
msgid "This will change your mood for every account which supports it."
msgstr "ändernt ihre Stimmung für jedes Konto die es ertragt."
#: mood_dialog.c:201
#: mood_dialog.c:203
#: widget_gtk.c:276
msgid "None"
msgstr "Nichts"
#: preferences.c:50
msgid "Left"
msgstr "Linke"
#: preferences.c:51
msgid "Center"
msgstr "Mitte"
#: preferences.c:52
msgid "Right"
msgstr "Rechte"
#: preferences.c:58
msgid "Top"
msgstr "Oben"
#: preferences.c:59
msgid "Bottom"
msgstr "Unter"
#: preferences.c:131
msgid "_Nickname markup"
msgstr "_Spitzname Tag"
#: preferences.c:132
#, c-format
msgid "Change the markup used to display the nickname using the Pango Markup Language where %n is replaced with your nickname."
msgstr "ändert das Markup das verwendet wird um den Spitzname zu anzeigen mit der Pango Markup Language wo %n mit deinem Spitzname ersetzt ist."
#: preferences.c:135
msgid "Nickname markup _hovered"
msgstr "_Ãbergezwegt Spitzname Tag"
#: preferences.c:137
#, c-format
msgid "Change the markup used to display the nickname when hovered by the mouse using the Pango Markup Language where %n is replaced with your nickname."
msgstr "ändert das Markup das verwendet wird um den Spitzname zu anzeigen wenn überzwegt mit der Maus, mit der Pango Markup Language wo %n mit deinem Spitzname ersetzt ist."
#: preferences.c:141
msgid "Personal _message markup"
msgstr "Persönliche _Nachricht Tag"
#: preferences.c:143
#, c-format
msgid "Change the markup used to display the personal message using the Pango Markup Language where %p is replaced with your personal message."
msgstr "ändert das markup das verwendet wird um die persönliche Nachricht zu anzeigen, mit der Pango Markup Language wo %p mit deiner persönliche Nachricht ersetzt ist."
#: preferences.c:147
msgid "Personal message markup _hovered"
msgstr "_Ãbergezwegd persönliche Nachricht Tag"
#: preferences.c:149
#, c-format
-msgid "Change the markup used to display the personal message when hovered by the mouse using the Pango Markup Language where %m is replaced with your personal message."
-msgstr "ändert das Markup das verwendet wird um die persönliche Nachrict zu anzeigen wenn überzwegt mit der Maus, mit der Pango Markup Language wo %m mit deiner persönliche Nachricht."
+msgid "Change the markup used to display the personal message when hovered by the mouse using the Pango Markup Language where %p is replaced with your personal message."
+msgstr "ändert das Markup das verwendet wird um die persönliche Nachricht zu anzeigen wenn überzwegt mit der Maus, mit der Pango Markup Language wo %p mit deiner persönliche Nachricht ersetzt wird."
#: preferences.c:164
msgid "Align _nickname"
msgstr "Spitzname_ausrichten"
#: preferences.c:166
msgid "Alignment of the nickname into the bar."
msgstr "Ausrichtung der Spitzname in der Bar."
#: preferences.c:168
msgid "Align personal _message"
msgstr "_Persönliche Nachricht ausrichten"
#: preferences.c:170
msgid "Alignment of the personal message into the bar."
msgstr "Aurichtung der persönliche Nachricht in die Bar."
#: preferences.c:172
msgid "Widget _position in the buddy list"
msgstr "Widget _Lage in den buddy-Liste"
#: preferences.c:174
msgid "Position of the widget into pidgin's buddy list."
msgstr "Lage des Widget in Pidgin-Buddy-Liste."
#: preferences.c:181
msgid "Hide _statusbox"
msgstr "_Statusbox verbergen"
#: preferences.c:182
msgid "Show or hide the Pidgin's default statusbox."
msgstr "Show or hide the Pidgin's default statusbox."
#: preferences.c:184
msgid "_Ignore status changes"
msgstr "_Ignoriert Status anderungen"
#: preferences.c:185
msgid "Ignore changes made to status from outside the widget. This include changes made in Pidgin's default statusbox and other plugins."
msgstr "Ignoriert änderungen zu Status von auÃerhalb des Widgets gemacht, inbegriffen änderungen in Pidgin standarmäÃige statusbox und andere Plugins gemacht."
#: preferences.c:189
msgid "Use a frame for _entry"
msgstr "Nutz ein ein Rahmen für Textinput"
#: preferences.c:190
msgid "Enable or disable the use of a frame around the entries when editing the nickname or personal message from the bar."
msgstr "Enable or disable the use of a frame around the entries when editing the nickname or personal message from the bar."
#: preferences.c:193
msgid "_Swap left and right click"
msgstr "_Dreht linke und rechte klik um"
#: preferences.c:194
msgid "Swap the role of left and right click to edit the nickname or personal message in the bar."
msgstr "Dreht die Rolle von links und rechts Klik um den Spitzname oder persönliche Nachricht in der Bar zu bearbeiten."
#: preferences.c:197
msgid "Use a _compact bar"
msgstr "Benutz ein kompakt Balken"
#: preferences.c:198
msgid "Reduce the size of the widget putting the nickname and personal message on one line."
msgstr "Reduziert die gröÃe des Widgets und setz den Spitzname und die persönliche Nachricht auf einer Linie."
#: preferences.c:201
msgid "_Reset status messages"
msgstr "_Rûcksetz Status Berichten"
#: preferences.c:202
msgid "Clear the status messages when Pidgin restart (except for personal message). By default these messages are saved in the preferences and reactivated when pidgin restart."
msgstr "Klar die Status nachrichten wenn pidgin neustart (auÃerhalb für persönliche Nacxhrichten). StandarmäÃig werden diese Nachrichten in die Präferenzen gespeichert und neuaktiviert wenn Pidgin neustart."
#. preferences
#. preference root
#. empty messages to display at first installation
#: preferences.h:33
msgid "<Enter nickname here>"
msgstr "<hier Spitzname einführen>"
#: preferences.h:34
msgid "<Enter personal message here>"
msgstr "<Hier persönlich nachricht einführen>"
#: actions.c:87
#: widget.c:309
msgid "Change nickname"
msgstr "ändernt Spitzname"
#: actions.c:88
msgid "Change personal message"
msgstr "Persönliche Nachricht ausrichten"
#: actions.c:89
msgid "Change status"
msgstr "ändernt Status Nachricht"
#: actions.c:90
msgid "Change mood"
msgstr "ändernt Stimmung"
#: actions.c:91
msgid "Change icon"
msgstr "ändernt Ikone"
#: widget.c:310
msgid "Enter your nickname here..."
msgstr "Hier Spitzname einführen..."
#: widget.c:311
msgid "This will change your nickname for every account which supports it."
msgstr "ändernt ihr Spitzname für jeder Account die es ertragen."
#: widget.c:317
#: widget.c:531
msgid "OK"
msgstr "OK"
#: widget.c:319
#: widget.c:533
msgid "Cancel"
msgstr "Annulieren"
#: widget.c:476
msgid "_Mood message"
msgstr "_Stimmung Nachricht"
#: widget.c:477
msgid "Current song"
msgstr "Aktuel lied"
#: widget.c:478
msgid "Song _title"
msgstr "lied _Titel"
#: widget.c:479
msgid "Song _artist"
msgstr "Lied _Künstler"
#: widget.c:480
msgid "Song al_bum"
msgstr "Lied Al_bum"
#: widget.c:481
msgid "MSN pecan extra attributes"
msgstr "MSN pecan extra Parameter"
#: widget.c:482
msgid "_Game name"
msgstr "_Spiel Name"
#: widget.c:483
msgid "_Office app name"
msgstr "_Office app Name"
#: widget.c:489
msgid "Status and mood message"
msgstr "Status und Stimmung Nachricht"
#: widget.c:494
msgid "_Personal message"
msgstr "_Persönliche Nachricht"
#: widget.c:525
msgid "Change status messages"
msgstr "ändernt Status Nachricht"
#: widget.c:526
msgid "Enter status message..."
msgstr "führt Status Nachricht ein..."
#: widget.c:527
msgid "This will change some status messages for every account which supports it, please be advised that some are inconsistent between each other."
msgstr "ändernt einige Status Nachrichten für jeder Account die es ertragt, Bitte beachten Sie dass einige inkonsistent sind untereinander."
diff --git a/nsis/german.nsh b/nsis/german.nsh
index cf83c68..8f9ad2e 100644
--- a/nsis/german.nsh
+++ b/nsis/german.nsh
@@ -1,39 +1,39 @@
;;
-;; english.nsh
+;; german.nsh
;;
;; Default language strings for the Windows PBar NSIS installer.
;; Windows Code page: 1252
;; Language Code: 1033
;;
; Startup Pidgin check
-LangString PIDGIN_NEEDED ${LANG_ENGLISH} "PBar requires that Pidgin be installed. You must install Pidgin before installing PBar."
+LangString PIDGIN_NEEDED ${LANG_GERMAN} "PBar erfordet dass Pidgin installiert werd, Sie müssen Pidgin installieren vorher Sie PBar installieren."
-LangString PBAR_TITLE ${LANG_ENGLISH} "PBar plugin for Pidgin"
+LangString PBAR_TITLE ${LANG_GERMAN} "PBar plugin für Pidgin"
-LangString BAD_PIDGIN_VERSION_1 ${LANG_ENGLISH} "Incompatible version.$\r$\n$\r$\nThis version of the PBar plugin was built for Pidgin version ${PIDGIN_VERSION}. It appears that you have Pidgin version"
+LangString BAD_PIDGIN_VERSION_1 ${LANG_GERMAN} "Inkompatible Version.$\r$\n$\r$\nDiese Version des PBar Plugin wurde fûr Pidgin-version gebaut ${PIDGIN_VERSION}. Es scheint, dass Sie Pidgin-Version haben"
-LangString BAD_PIDGIN_VERSION_2 ${LANG_ENGLISH} "installed.$\r$\n$\r$\nSee http://www.hauweele.net/~gawen/pidgin-pbar.html for more information."
+LangString BAD_PIDGIN_VERSION_2 ${LANG_GERMAN} "installierend.$\r$\n$\r$\nSee http://www.hauweele.net/~gawen/pidgin-pbar.html für weitere Informationenn."
-LangString NO_PIDGIN_VERSION ${LANG_ENGLISH} "Unable to determine installed Pidgin version."
+LangString NO_PIDGIN_VERSION ${LANG_GERMAN} "Kann die installierte Pidgin-Version nicht bestimmen."
; Overrides for default text in windows:
-LangString WELCOME_TITLE ${LANG_ENGLISH} "PBar v${PBAR_VERSION} Installer"
-LangString WELCOME_TEXT ${LANG_ENGLISH} "Note: This version of the plugin is designed for Pidgin ${PIDGIN_VERSION}, and will not install or function with versions of Pidgin having a different major version number.\r\n\r\nWhen you upgrade your version of Pidgin, you must uninstall or upgrade this plugin as well.\r\n\r\n"
+LangString WELCOME_TITLE ${LANG_GERMAN} "PBar v${PBAR_VERSION} Installationprogramm"
+LangString WELCOME_TEXT ${LANG_GERMAN} "Beachten sie; dass diese Version des Plugins für Pidgin konzipiert ${PIDGIN_VERSION}, und lässt sich nicht installieren oder kann nicht funktionieren mit versionen von Pidgin mit einer anderen Hauptversionsnummer.\r\n\r\nWenn Sie Ihre Versionvon Pidgin aktualisieren, müssen Sie deinstallieren oder dieses plugin auch aktualisieren.\r\n\r\n"
-LangString DIR_SUBTITLE ${LANG_ENGLISH} "Please locate the directory where Pidgin is installed"
-LangString DIR_INNERTEXT ${LANG_ENGLISH} "Install in this Pidgin folder:"
+LangString DIR_SUBTITLE ${LANG_GERMAN} "Bitte lokalisieren Sie das Verzeichnis, wo in Pidgin installiert ist"
+LangString DIR_INNERTEXT ${LANG_GERMAN} "Installieren sie in diesem Pidgin Ordner:"
-LangString FINISH_TITLE ${LANG_ENGLISH} "PBar v${PBAR_VERSION} Install Complete"
-LangString FINISH_TEXT ${LANG_ENGLISH} "You will need to restart Pidgin for the plugin to be loaded, then go the Pidgin preferences and enable the PBar Plugin."
+LangString FINISH_TITLE ${LANG_GERMAN} "PBar v${PBAR_VERSION} Installation vollendet"
+LangString FINISH_TEXT ${LANG_GERMAN} "Sie müssen Pidgin wieder einführen für das Plugin neu geladen werden soll, dan auf die Pidgin-Einstellungen gehen und die PBar Plugin aktivieren."
; during install uninstaller
-LangString PBAR_PROMPT_WIPEOUT ${LANG_ENGLISH} "The pbar.dll plugin is about to be deleted from your Pidgin/plugins directory. Continue?"
+LangString PBAR_PROMPT_WIPEOUT ${LANG_GERMAN} "Die pbar.dll Plugin ist im Begriff, aus dem Pidgin/Plugins Verzeichnis gelöscht werden. Weitergehen ?"
; for windows uninstall
-LangString PBAR_UNINSTALL_DESC ${LANG_ENGLISH} "PBar Plugin (remove only)"
-LangString un.PBAR_UNINSTALL_ERROR_1 ${LANG_ENGLISH} "The uninstaller could not find registry entries for PBar.$\rIt is likely that another user installed the plugin."
-LangString un.PBAR_UNINSTALL_ERROR_2 ${LANG_ENGLISH} "You do not have the permissions necessary to uninstall the plugin."
+LangString PBAR_UNINSTALL_DESC ${LANG_GERMAN} "PBar Plugin (nur entfernen)"
+LangString un.PBAR_UNINSTALL_ERROR_1 ${LANG_GERMAN} "Das Deintallationprogramm konnte der Registrierung einträge für PBar nicht finden.$\rIt es ist wahscheinlich, dass ein anderer Benutzer das Plugin installierte."
+LangString un.PBAR_UNINSTALL_ERROR_2 ${LANG_GERMAN} "Sie haben die erfordelichen Berechtigungen nicht, um das Plugin zu deinstallieren."
|
gawen947/pidgin-pbar
|
50bb3716c3b8853439d26f54fc8d1ae96ee925f2
|
Add ChangeLog
|
diff --git a/ChangeLog b/ChangeLog
index 61e1d02..69783a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,16 +1,20 @@
+* Sat Sep 17 2011 David Hauweele <[email protected]>
- Fix a bug in preference tooltip which state '%m' instead of '%p'
+ - Add a makefile for Windows
+ - Add an installer for Windows
+ - Fix status and mood icons that did not show up correctly on Windows
* Wed Jun 22 2011 David Hauweele <[email protected]>
- Fix cursor bug
- Fix makefile to ease packaging
- Fix compilation against Gtk 2.12
- Add features dialogs
- Add dialogs to change attributes through Pidgin's tools menu
- Change contact addresses
- Add tooltips to preferences dialog
- Disable features when no connected account supporting them
- Clean code
- Release 0.2
* Wed Jan 5 2010 David Hauweele <[email protected]>
- Release 0.1
|
gawen947/pidgin-pbar
|
97ec4c88772507076f67d4058ca5648bcfcdd66f
|
French translation for NSIS
|
diff --git a/nsis/french.nsh b/nsis/french.nsh
index b84d3c9..76a7aa5 100644
--- a/nsis/french.nsh
+++ b/nsis/french.nsh
@@ -1,41 +1,41 @@
;;
;; french.nsh
;;
;; French language strings for the Windows PBar NSIS installer.
;; Windows Code page: 1252
;; Language Code: 1036
;; Derived from the French translation for the Windows guificiations NSIS installer by Yannick LE NY
;;
;;
; Startup Pidgin check
LangString PIDGIN_NEEDED ${LANG_FRENCH} "PBar requiert que Pidgin soit installé. Vous devez installer Pidgin avant de faire l'installation de PBar."
LangString PBAR_TITLE ${LANG_FRENCH} "Plugin PBar pour Pidgin"
LangString BAD_PIDGIN_VERSION_1 ${LANG_FRENCH} "Version incompatible.$\r$\n$\r$\nCette version du plugin PBar a été créé pour la version ${PIDGIN_VERSION} de Pidgin. Il apparait que vous avez la version"
-LangString BAD_PIDGIN_VERSION_2 ${LANG_FRENCH} "installée de Pidgin. $\r$\n$\r$\nRegardez à http://guifications.sourceforge.net pour plus d'informations."
+LangString BAD_PIDGIN_VERSION_2 ${LANG_FRENCH} "installée de Pidgin. $\r$\n$\r$\nRegardez à http://www.hauweele.net/~gawen/pidgin-pbar.html pour plus d'informations."
LangString NO_PIDGIN_VERSION ${LANG_FRENCH} "Impossible de déterminer la version installée de Pidgin."
; Overrides for default text in windows:
LangString WELCOME_TITLE ${LANG_FRENCH} "Installeur de PBar v${PBAR_VERSION}"
LangString WELCOME_TEXT ${LANG_FRENCH} "Note: Cette version du plugin est conçu pour Pidgin ${PIDGIN_VERSION}, et ne s'installera pas ou ne fonctionnera pas avec les versions de Pidgin ayant un numéro de version majeur différent.\r\n\r\nQuand vous mettez à jour votre version de Pidgin, vous devez désinstaller ou mettre à jour ce plugin aussi.\r\n\r\n"
LangString DIR_SUBTITLE ${LANG_FRENCH} "Merci d'indiquer le répertoire où Pidgin est installé"
LangString DIR_INNERTEXT ${LANG_FRENCH} "Installation dans le répertoire Pidgin:"
LangString FINISH_TITLE ${LANG_FRENCH} "Installation terminée de PBar v${PBAR_VERSION}"
LangString FINISH_TEXT ${LANG_FRENCH} "Vous avez besoin de redémarrer Pidgin pour que le plugin soit chargé, ensuite allez dans les préférences de Pidgin et activez le plugin PBar."
; during install uninstaller
-LangString PBAR_PROMPT_WIPEOUT ${LANG_FRENCH} "La librairie guifications.dll du plugin sera supprimé de votre répertoire Pidgin/plugins. Continuer ?"
+LangString PBAR_PROMPT_WIPEOUT ${LANG_FRENCH} "La librairie pbar.dll du plugin sera supprimé de votre répertoire Pidgin/plugins. Continuer ?"
; for windows uninstall
LangString PBAR_UNINSTALL_DESC ${LANG_FRENCH} "Plugin PBar (supprimer uniquement)"
-LangString un.PBAR_UNINSTALL_ERROR_1 ${LANG_FRENCH} "Le désinstalleur ne peut pas trouver les entrées de registre pour Guifications.$\rIl se peut qu'un autre utilisateur a installé le plugin."
+LangString un.PBAR_UNINSTALL_ERROR_1 ${LANG_FRENCH} "Le désinstalleur ne peut pas trouver les entrées de registre pour PBar.$\rIl se peut qu'un autre utilisateur a installé le plugin."
LangString un.PBAR_UNINSTALL_ERROR_2 ${LANG_FRENCH} "Vous n'avez pas les permissions nécessaires pour désinstaller le plugin."
|
gawen947/pidgin-pbar
|
df764790c65897e5231686bc1a010c1a070cbe2c
|
Fix status and mood icons that did not show up correctly on Windows
|
diff --git a/pbar.c b/pbar.c
index b384159..9f88c6c 100644
--- a/pbar.c
+++ b/pbar.c
@@ -1,134 +1,142 @@
/* File: pbar.c
- Time-stamp: <2011-01-31 19:06:59 gawen>
+ Time-stamp: <2011-09-17 01:29:53 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#define PURPLE_PLUGINS
#include "common.h"
#include "pbar.h"
#include "actions.h"
#include "preferences.h"
#include "widget.h"
#include "purple.h"
static gboolean plugin_load(PurplePlugin *plugin);
static gboolean plugin_unload(PurplePlugin *plugin);
static PidginPluginUiInfo ui_info = { get_config_frame };
static PurplePluginInfo info = {
PURPLE_PLUGIN_MAGIC,
PURPLE_MAJOR_VERSION,
PURPLE_MINOR_VERSION,
PURPLE_PLUGIN_STANDARD,
PIDGIN_PLUGIN_TYPE,
0,
NULL,
PURPLE_PRIORITY_DEFAULT,
PLUGIN_ID,
NULL, /* defined later for NLS */
PLUGIN_VERSION,
NULL, /* defined later for NLS */
NULL, /* defined later for NLS */
PLUGIN_AUTHOR,
PLUGIN_WEBSITE,
plugin_load,
plugin_unload,
NULL,
&ui_info,
NULL,
NULL,
create_actions,
NULL,
NULL,
NULL,
NULL
};
PurplePlugin *thisplugin;
/* we need this callback to catch
blist construction and install
widget when we may do so */
static void cb_blist_created(GtkWidget *widget, gpointer data)
{
/* create widget and
load preferences */
create_widget();
init_widget();
}
static gboolean plugin_load(PurplePlugin *plugin)
{
/* connect construction signal only when needed
as when installing the plugin after launching
pidgin there is no need to wait for blist
creation */
if(is_gtk_blist_created()) {
/* create widget and
load preferences */
create_widget();
init_widget();
}
else
/* connect construction signal */
purple_signal_connect(pidgin_blist_get_handle(),
"gtkblist-created",
plugin,
PURPLE_CALLBACK(cb_blist_created),
NULL);
purple_debug_info(NAME,"plugin initialized...\n");
return TRUE;
}
static gboolean plugin_unload(PurplePlugin *plugin)
{
+#ifdef _WIN32
+ /* force gtk-button-images to 1 on Windows,
+ otherwise, mood and status images won't
+ be displayed */
+ GtkSettings *settings = gtk_settings_get_default();
+ gtk_settings_set_long_property(settings, "gtk-button-images", 1, "gtkrc:21");
+#endif /* _WIN32 */
+
/* destroy widget and free memory */
destroy_widget();
/* restore statusbox */
set_statusbox_visible(TRUE);
purple_debug_info(NAME,"plugin destroyed...\n");
return TRUE;
}
static void init_plugin(PurplePlugin *plugin)
{
thisplugin = plugin;
#ifdef ENABLE_NLS
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
#endif /* ENABLE_NLS */
/* translate name, summary and description */
info.name = _(PLUGIN_NAME);
info.summary = _(PLUGIN_SUMMARY);
info.description = _(PLUGIN_DESCRIPTION);
/* load or create preferences */
init_prefs();
}
PURPLE_INIT_PLUGIN(pbar, init_plugin, info)
diff --git a/widget.c b/widget.c
index 8d66fea..bda8b5c 100644
--- a/widget.c
+++ b/widget.c
@@ -1,514 +1,514 @@
/* File: widget.c
- Time-stamp: <2011-06-17 19:38:35 gawen>
+ Time-stamp: <2011-08-26 18:48:52 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "pbar.h"
#include "widget.h"
#include "widget_gtk.h"
#include "widget_prpl.h"
#include "preferences.h"
#include "purple.h"
#include "gtk.h"
/* we only have one widget per plugin
but this might change in the future */
struct widget *bar;
void create_widget()
{
/* we need this when the bar is reset for example
using the preferences dialog */
if(!bar) {
bar = g_malloc(sizeof(struct widget));
memset(bar, 0, sizeof(struct widget));
check_available_features();
}
/* widgets that can possibly be modified along plugin's execution */
bar->icon = gtk_image_new();
bar->status = gtk_button_new_from_stock(NULL);
bar->mood = gtk_button_new_from_stock(NULL);
bar->name_label = gtk_label_new(NULL);
bar->name_eventbox = gtk_event_box_new();
bar->name_entry = gtk_entry_new();
bar->pm_label = gtk_label_new(NULL);
bar->pm_eventbox = gtk_event_box_new();
bar->pm_entry = gtk_entry_new();
bar->hbox = gtk_hbox_new(FALSE, 2);
bar->icon_eventbox = gtk_event_box_new();
bar->status_menu = gtk_menu_new();
bar->mood_menu = gtk_menu_new();
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(bar), bar->hbox);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->status_menu);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->mood_menu);
/* widgets that are not modified */
GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
GtkWidget *hbox1 = gtk_hbox_new(FALSE, 2);
GtkWidget *hbox2 = gtk_hbox_new(FALSE, 2);
/* setup widgets */
gtk_label_set_ellipsize(GTK_LABEL(bar->name_label), PANGO_ELLIPSIZE_END);
gtk_label_set_ellipsize(GTK_LABEL(bar->pm_label), PANGO_ELLIPSIZE_END);
gtk_label_set_max_width_chars(GTK_LABEL(bar->name_label), 50);
gtk_button_set_relief(GTK_BUTTON(bar->status), GTK_RELIEF_NONE);
gtk_button_set_relief(GTK_BUTTON(bar->mood), GTK_RELIEF_NONE);
gtk_widget_set_can_focus(bar->name_eventbox, FALSE);
gtk_widget_set_can_focus(bar->pm_eventbox, FALSE);
gtk_widget_set_can_focus(bar->status, FALSE);
gtk_widget_set_can_focus(bar->mood, FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->icon_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->name_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->pm_eventbox), FALSE);
/* pack widgets */
gtk_container_add(GTK_CONTAINER(bar->name_eventbox), bar->name_label);
gtk_container_add(GTK_CONTAINER(bar->pm_eventbox), bar->pm_label);
gtk_container_add(GTK_CONTAINER(bar->icon_eventbox), bar->icon);
if(purple_prefs_get_bool(PREF "/compact")) {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
}
else {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0);
}
gtk_box_pack_start(GTK_BOX(bar->hbox), bar->icon_eventbox, FALSE, FALSE, 5);
gtk_box_pack_start(GTK_BOX(bar->hbox), vbox, TRUE, TRUE, 0);
/* pack at top of the buddy list and fallback to top
if the position option is unknown */
void (*gtk_box_pack)(GtkBox *, GtkWidget *, gboolean, gboolean, guint) = gtk_box_pack_start;
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
switch(purple_prefs_get_int(PREF "/widget-position")) {
case(POSITION_TOP):
gtk_box_pack = gtk_box_pack_start;
break;
case(POSITION_BOTTOM):
gtk_box_pack = gtk_box_pack_end;
break;
};
gtk_box_pack(GTK_BOX(blist->vbox), bar->hbox, FALSE, TRUE, 2);
gtk_box_reorder_child(GTK_BOX(blist->vbox), bar->hbox, 0);
/* setup initial states */
bar->gtk_hnd = NULL;
bar->gtk_inst = NULL;
bar->hover_name = FALSE;
bar->hover_pm = FALSE;
bar->name_entry_activated = FALSE;
bar->pm_entry_activated = FALSE;
bar->name_dialog = FALSE;
bar->pm_dialog = FALSE;
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ bar->icon_eventbox, "button-press-event", cb_buddy_icon },
{ bar->icon_eventbox, "enter-notify-event", cb_buddy_icon_enter },
{ bar->icon_eventbox, "leave-notify-event", cb_buddy_icon_leave },
{ bar->name_eventbox, "button-press-event", cb_name },
{ bar->name_eventbox, "enter-notify-event", cb_name_enter },
{ bar->name_eventbox, "leave-notify-event", cb_name_leave },
{ bar->name_entry, "activate", cb_name_entry },
{ bar->name_entry, "focus-out-event", cb_name_entry_focus_out },
{ bar->pm_eventbox, "button-press-event", cb_pm },
{ bar->pm_eventbox, "enter-notify-event", cb_pm_enter },
{ bar->pm_eventbox, "leave-notify-event", cb_pm_leave },
{ bar->pm_entry, "activate", cb_pm_entry },
{ bar->pm_entry, "focus-out-event", cb_pm_entry_focus_out },
{ bar->status, "clicked", cb_status_button },
{ bar->mood, "clicked", cb_mood_button },
{ NULL, NULL, NULL }
};
/* purple signals and callback */
const struct pbar_prpl_signal p_signal_connections[] = {
{ purple_accounts_get_handle(), "account-status-changed", cb_status },
{ purple_connections_get_handle(), "signed-on", cb_signed_on },
{ purple_connections_get_handle(), "signed-off", cb_signed_off },
{ NULL, NULL, NULL }
};
/* purple preferences signals and callback */
const struct pbar_prpl_signal pp_signal_connections[] = {
{ bar, PIDGIN_PREFS_ROOT "/accounts/buddyicon", cb_buddy_icon_update },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(bar), g_signal_connections, NULL);
prpl_connect_signals(PBAR_WIDGET(bar), p_signal_connections, NULL);
prpl_prefs_connect_signals(PBAR_WIDGET(bar), pp_signal_connections, NULL);
/* show everything */
gtk_widget_show_all(bar->hbox);
gtk_widget_hide(bar->name_entry);
gtk_widget_hide(bar->pm_entry);
/* inform that the bar is installed */
widget_set_all_sensitive(FALSE);
update_available_widgets();
bar->installed = TRUE;
}
static void free_inner_widget()
{
g_return_if_fail(bar->installed);
bar->installed = FALSE;
/* disconnect purple and prefs signals */
prpl_disconnect_signals(PBAR_WIDGET(bar));
prpl_prefs_disconnect_signals(PBAR_WIDGET(bar));
gtk_destroy(PBAR_WIDGET(bar)); /* destroy widgets */
}
void reset_widget()
{
free_inner_widget();
/* create widget but do not free the structure itself
to save references for available features */
create_widget();
}
void destroy_widget()
{
free_inner_widget();
g_free(bar); /* free widget */
bar = NULL;
}
/* load preferences into our widget */
void init_widget()
{
g_return_if_fail(bar->installed);
/* entry frame */
gboolean state = purple_prefs_get_bool(PREF "/frame-entry");
set_widget_entry_frame(state);
/* nickname */
const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup");
const gchar *value = purple_prefs_get_string(PREF "/nickname");
int jtype = purple_prefs_get_int(PREF "/nickname-justify");
set_widget_name(markup, value);
set_widget_name_justify(jtype);
/* personal message */
markup = purple_prefs_get_string(PREF "/personal-message-markup");
value = purple_prefs_get_string(PREF "/personal-message");
jtype = purple_prefs_get_int(PREF "/personal-message-justify");
set_widget_pm(markup, value);
set_widget_pm_justify(jtype);
/* buddy icon */
GdkPixbuf *icon = get_buddy_icon();
set_widget_icon(icon);
/* mood image */
const gchar *current_mood = purple_prefs_get_string(PREF "/mood");
gchar *path = get_mood_icon_path(current_mood);
set_widget_mood(path);
g_free(path);
/* status image */
const gchar *stock = get_status_stock_id();
set_widget_status(stock);
/* fill status menu */
GList *accts = purple_accounts_get_all_active();
GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = (PurpleAccount *)accts->data;
GList *types = purple_account_get_status_types(account);
for(; types ; types = types->next) {
PurpleStatusType *type = (PurpleStatusType *)types->data;
PurpleStatusPrimitive prim;
const gchar *stock, *status_name;
GtkWidget *menu_item, *icon;
if(!purple_status_type_is_user_settable(type) ||
purple_status_type_is_independent(type))
continue;
prim = purple_status_type_get_primitive(type);
stock = pidgin_stock_id_from_status_primitive(prim);
if(g_hash_table_lookup(global_status, stock))
continue;
else
g_hash_table_insert(global_status, (gpointer)stock,
GINT_TO_POINTER(TRUE));
status_name = purple_status_type_get_name(type);
menu_item = gtk_image_menu_item_new_with_label(status_name);
icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), icon);
gtk_menu_shell_append(GTK_MENU_SHELL(bar->status_menu), menu_item);
g_signal_connect_swapped(menu_item, "activate",
G_CALLBACK(cb_status_menu),
(gpointer)type);
gtk_widget_show(menu_item);
}
}
g_hash_table_destroy(global_status);
/* statusbox hiding */
state = purple_prefs_get_bool(PREF "/hide-statusbox");
set_statusbox_visible(!state);
}
/* create a change name dialog */
void create_name_dialog()
{
const gchar *name = purple_prefs_get_string(PREF "/nickname");
if(!name || !strcmp(name, EMPTY_NAME))
name = "";
purple_request_input(thisplugin,
_("Change nickname"),
_("Enter your nickname here..."),
_("This will change your nickname "
"for every account which supports it."),
name,
FALSE,
FALSE,
NULL,
_("OK"),
G_CALLBACK(cb_name_apply),
_("Cancel"),
G_CALLBACK(cb_name_cancel),
NULL,
NULL,
NULL,
NULL);
bar->name_dialog = TRUE;
}
/* disable every features of the widget */
void widget_set_all_sensitive(gboolean sensitive)
{
GtkWidget *widgets[] = {
bar->icon,
bar->icon_eventbox,
bar->status,
bar->status_menu,
bar->mood,
bar->mood_menu,
bar->name_label,
bar->name_eventbox,
bar->name_entry,
bar->pm_label,
bar->pm_eventbox,
bar->pm_entry,
NULL
}; GtkWidget **w = widgets;
gboolean *attrs[] = {
&bar->mood_message,
&bar->current_song,
&bar->song_title,
&bar->song_album,
&bar->game_name,
&bar->office_app,
NULL
}; gboolean **a = attrs;
for(; *w ; w++)
gtk_widget_set_sensitive(*w, sensitive);
for(; *a ; a++)
**a = sensitive;
}
#define assert_ref(count, inc) (bar->count > 0 || inc > 0)
void check_available_features()
{
GList *a = purple_accounts_get_all_active();
for(; a ; a = a->next) {
PurpleAccount *acct = (PurpleAccount *)a->data;
if(purple_account_is_connected(acct))
update_available_features(acct, TRUE);
}
}
/* enable/disable features when an account changes */
void update_available_features(PurpleAccount *acct, gboolean enable)
{
int inc = 1;
PurplePlugin *plugin = purple_find_prpl(acct->protocol_id);
PurplePluginProtocolInfo *protocol = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
GHashTable *attrs = get_account_attrs(acct);
if(!enable)
inc = -1;
/* update references */
if(g_hash_table_lookup(attrs, "mood") &&
assert_ref(mood_ref, inc))
bar->mood_ref += inc;
if(g_hash_table_lookup(attrs, "moodtext") &&
assert_ref(mood_message_ref, inc))
bar->mood_message_ref += inc;
if(g_hash_table_lookup(attrs, "game") && assert_ref(game_name_ref, inc))
bar->game_name_ref += inc;
if(g_hash_table_lookup(attrs, "office") && assert_ref(office_app_ref, inc))
bar->office_app_ref += inc;
if(g_hash_table_lookup(attrs, "tune_title") &&
g_hash_table_lookup(attrs, "tune_artist") &&
g_hash_table_lookup(attrs, "tune_album") &&
assert_ref(current_song_ref, inc))
bar->current_song_ref += inc;
if(protocol->set_status && assert_ref(pm_ref, inc))
bar->pm_ref += inc;
if(protocol->set_buddy_icon && assert_ref(icon_ref, inc))
bar->icon_ref += inc;
if((!strcmp(acct->protocol_id, "prpl-jabber") || protocol->set_public_alias)&&
assert_ref(name_ref, inc))
bar->name_ref += inc;
if(assert_ref(status_ref, inc))
bar->status_ref += inc;
}
void update_available_widgets()
{
PurpleMood *mood = get_global_moods();
const struct s_widget {
GtkWidget *widget;
gboolean sensitive;
} widgets[] = {
{ bar->icon, bar->icon_ref },
{ bar->icon_eventbox, bar->icon_ref },
{ bar->status, bar->status_ref },
{ bar->status_menu, bar->status_ref },
{ bar->mood, bar->mood_ref && mood->mood },
{ bar->mood_menu, bar->mood_ref && mood->mood },
{ bar->name_label, bar->name_ref },
{ bar->name_eventbox, bar->name_ref },
{ bar->name_entry, bar->name_ref },
{ bar->pm_label, bar->pm_ref + bar->mood_message_ref + bar->game_name_ref +\
bar->office_app_ref + bar->current_song_ref },
{ bar->pm_eventbox, bar->pm_ref + bar->mood_message_ref+bar->game_name_ref+\
bar->office_app_ref + bar->current_song_ref },
{ bar->pm_entry, bar->pm_ref + bar->mood_message_ref + bar->game_name_ref +\
bar->office_app_ref + bar->current_song_ref },
{ NULL, FALSE }
}; const struct s_widget *w = widgets;
const struct s_attr {
gboolean *attr;
gboolean sensitive;
} attrs[] = {
{ &bar->pm_message, bar->pm_ref },
{ &bar->mood_message, bar->mood_message_ref && mood->mood },
{ &bar->current_song, bar->current_song_ref },
{ &bar->song_title, bar->current_song_ref },
{ &bar->song_album, bar->current_song_ref },
{ &bar->game_name, bar->game_name },
{ &bar->office_app, bar->office_app },
{ NULL, FALSE }
}; const struct s_attr *a = attrs;
for(; w->widget ; w++)
gtk_widget_set_sensitive(w->widget, w->sensitive);
for(; a->attr ; a++)
*a->attr = a->sensitive;
}
/* create a personal message dialog */
void create_pm_dialog()
{
PurpleRequestFields *fields;
PurpleRequestFieldGroup *group;
PurpleRequestField *field;
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
if(!pm || !strcmp(pm, EMPTY_PM))
pm = "";
const struct s_field {
const gchar *text;
const gchar *pref;
gboolean enable;
} groups[] = {
{ N_("_Mood message"), PREF "/mood-message", bar->mood_message },
{ N_("Current song"), NULL, bar->current_song },
{ N_("Song _title"), PREF "/tune-title", bar->current_song },
{ N_("Song _artist"), PREF "/tune-artist", bar->song_title },
{ N_("Song al_bum"), PREF "/tune-album", bar->song_album },
{ N_("MSN pecan extra attributes"), NULL, bar->game_name && bar->office_app },
{ N_("_Game name"), PREF "/game-message", bar->game_name },
{ N_("_Office app name"), PREF "/office-message", bar->office_app },
{ NULL, NULL },
{ NULL, NULL }
}; const struct s_field *g = groups;
fields = purple_request_fields_new();
group = purple_request_field_group_new(_("Status and mood message"));
purple_request_fields_add_group(fields, group);
if(bar->pm_message) {
field = purple_request_field_string_new(PREF "/personal-message",
_("_Personal message"),
pm,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
for(; g->pref ; g++) {
for(; g->pref ; g++) {
const gchar *message;
if(!g->enable)
continue;
else if(purple_prefs_get_bool(PREF "/reset-attrs"))
message = "";
else
message = purple_prefs_get_string(g->pref);
field = purple_request_field_string_new(g->pref,
_(g->text),
message,
FALSE);
|
gawen947/pidgin-pbar
|
da0f946342fed7331738a6ef2b08d2cfa71e4a5b
|
Add version information to Windows installer
|
diff --git a/installer.nsi b/installer.nsi
index fd4971f..f87c946 100644
--- a/installer.nsi
+++ b/installer.nsi
@@ -1,407 +1,413 @@
; NSIS Script For PBar Plugin
; Author David Hauweele
; Based on the Guifications Plugin installer by Daniel A. Atallah
; Uses NSIS v2.0
;--------------------------------
;Include Modern UI
!include "MUI.nsh"
!include "FileFunc.nsh"
!insertmacro GetParameters
!insertmacro GetOptions
;--------------------------------
;General
Name "Pidgin PBar ${PBAR_VERSION}"
;Do A CRC Check
CRCCheck On
;Output File Name
OutFile "Pidgin-PBar_${PBAR_VERSION}.exe"
;The Default Installation Directory
InstallDir "$PROGRAMFILES\pidgin"
InstallDirRegKey HKLM SOFTWARE\pidgin ""
ShowInstDetails show
ShowUnInstDetails show
SetCompressor /SOLID lzma
;Reserve files used in .onInit for faster start-up
!insertmacro MUI_RESERVEFILE_LANGDLL
!define PBAR_UNINST_EXE "Pidgin-PBar-uninst.exe"
!define PBAR_DLL "pbar.dll"
!define PBAR_UNINSTALL_LNK "PBar Uninstall.lnk"
;--------------------------------
; Registry keys:
!define PBAR_REG_KEY "SOFTWARE\pidgin-pbar"
!define PBAR_UNINSTALL_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\pidgin-pbar"
;-------------------------------
; Pidgin Plugin installer helper stuff
!addincludedir "${PIDGIN_TREE_TOP}\pidgin\win32\nsis"
!include "pidgin-plugin.nsh"
;--------------------------------
; Modern UI Configuration
!define MUI_ICON .\nsis\install.ico
!define MUI_UNICON .\nsis\install.ico
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "nsis\header.bmp"
!define MUI_CUSTOMFUNCTION_GUIINIT pbar_checkPidginVersion
!define MUI_ABORTWARNING
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY ${PBAR_REG_KEY}
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
;--------------------------------
; Pages
;Welcome Page
!define MUI_WELCOMEPAGE_TITLE $(WELCOME_TITLE)
!define MUI_WELCOMEPAGE_TEXT $(WELCOME_TEXT)
!insertmacro MUI_PAGE_WELCOME
;License Page
!define MUI_LICENSEPAGE_RADIOBUTTONS
!insertmacro MUI_PAGE_LICENSE ".\COPYING"
;Directory Page
!define MUI_DIRECTORYPAGE_TEXT_TOP $(DIR_SUBTITLE)
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION $(DIR_INNERTEXT)
!insertmacro MUI_PAGE_DIRECTORY
;Installation Page
!insertmacro MUI_PAGE_INSTFILES
;Finish Page
!define MUI_FINISHPAGE_TITLE $(FINISH_TITLE)
!define MUI_FINISHPAGE_TEXT $(FINISH_TEXT)
!insertmacro MUI_PAGE_FINISH
;--------------------------------
; Languages
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "Dutch"
!insertmacro MUI_LANGUAGE "German"
;Translations
!include "nsis\english.nsh"
!include "nsis\french.nsh"
!include "nsis\dutch.nsh"
!include "nsis\german.nsh"
; Uninstall the previous version if it exists
Section -SecUninstallOldPlugin
; Check install rights..
Call CheckUserInstallRights
Pop $R0
StrCmp $R0 "HKLM" rights_hklm
StrCmp $R0 "HKCU" rights_hkcu done
rights_hkcu:
ReadRegStr $R1 HKCU "${PBAR_REG_KEY}" ""
ReadRegStr $R2 HKCU "${PBAR_REG_KEY}" "Version"
ReadRegStr $R3 HKCU "${PBAR_UNINSTALL_KEY}" "UninstallString"
Goto try_uninstall
rights_hklm:
ReadRegStr $R1 HKLM "${PBAR_REG_KEY}" ""
ReadRegStr $R2 HKLM "${PBAR_REG_KEY}" "Version"
ReadRegStr $R3 HKLM "${PBAR_UNINSTALL_KEY}" "UninstallString"
; If previous version exists .. remove
try_uninstall:
StrCmp $R1 "" done
StrCmp $R2 "" uninstall_problem
IfFileExists $R3 0 uninstall_problem
; Have uninstall string.. go ahead and uninstall.
SetOverwrite on
; Need to copy uninstaller outside of the install dir
ClearErrors
CopyFiles /SILENT $R3 "$TEMP\${PBAR_UNINST_EXE}"
SetOverwrite off
IfErrors uninstall_problem
; Ready to uninstall..
ClearErrors
ExecWait '"$TEMP\${PBAR_UNINST_EXE}" /S _?=$R1'
IfErrors exec_error
Delete "$TEMP\${PBAR_UNINST_EXE}"
Goto done
exec_error:
Delete "$TEMP\${PBAR_UNINST_EXE}"
Goto uninstall_problem
uninstall_problem:
; Just delete the plugin and uninstaller, and remove Registry key
MessageBox MB_YESNO $(PBAR_PROMPT_WIPEOUT) IDYES do_wipeout IDNO cancel_install
cancel_install:
Quit
do_wipeout:
StrCmp $R0 "HKLM" del_lm_reg del_cu_reg
del_cu_reg:
DeleteRegKey HKCU ${PBAR_REG_KEY}
Goto uninstall_prob_cont
del_lm_reg:
DeleteRegKey HKLM ${PBAR_REG_KEY}
uninstall_prob_cont:
; plugin DLL
Delete "$R1\plugins\${PBAR_DLL}"
Delete "$R3"
done:
SectionEnd
!macro INSTALL_MO LANG
SetOutPath "$INSTDIR\locale\${LANG}\LC_MESSAGES"
File /oname=pidgin-pbar.mo ${LANG}.mo
!macroend
Section "Install"
Call CheckUserInstallRights
Pop $R0
StrCmp $R0 "NONE" instrights_none
StrCmp $R0 "HKLM" instrights_hklm instrights_hkcu
instrights_hklm:
; Write the version registry keys:
WriteRegStr HKLM ${PBAR_REG_KEY} "" "$INSTDIR"
WriteRegStr HKLM ${PBAR_REG_KEY} "Version" "${PBAR_VERSION}"
; Write the uninstall keys for Windows
WriteRegStr HKLM ${PBAR_UNINSTALL_KEY} "DisplayName" "$(PBAR_UNINSTALL_DESC)"
WriteRegStr HKLM ${PBAR_UNINSTALL_KEY} "UninstallString" "$INSTDIR\${PBAR_UNINST_EXE}"
+ WriteRegStr HKLM ${PBAR_UNINSTALL_KEY} "DisplayVersion" "${PBAR_VERSION}"
+ WriteRegStr HKLM ${PBAR_UNINSTALL_KEY} "HelpLink" "http://www.hauweele.net/~gawen/pidgin-pbar.html"
+ WriteRegStr HKLM ${PBAR_UNINSTALL_KEY} "Publisher" "David Hauweele"
SetShellVarContext "all"
Goto install_files
instrights_hkcu:
; Write the version registry keys:
WriteRegStr HKCU ${PBAR_REG_KEY} "" "$INSTDIR"
WriteRegStr HKCU ${PBAR_REG_KEY} "Version" "${PBAR_VERSION}"
; Write the uninstall keys for Windows
WriteRegStr HKCU ${PBAR_UNINSTALL_KEY} "DisplayName" "$(PBAR_UNINSTALL_DESC)"
WriteRegStr HKCU ${PBAR_UNINSTALL_KEY} "UninstallString" "$INSTDIR\${PBAR_UNINST_EXE}"
+ WriteRegStr HKCU ${PBAR_UNINSTALL_KEY} "DisplayVersion" "${PBAR_VERSION}"
+ WriteRegStr HKCU ${PBAR_UNINSTALL_KEY} "HelpLink" "http://www.hauweele.net/~gawen/pidgin-pbar.html"
+ WriteRegStr HKCU ${PBAR_UNINSTALL_KEY} "Publisher" "David Hauweele"
Goto install_files
instrights_none:
; No registry keys for us...
install_files:
SetOutPath "$INSTDIR\plugins"
SetCompress Auto
SetOverwrite on
File "${PBAR_DLL}"
; translations - if there is a way to automate this, i can't find it
!insertmacro INSTALL_MO "de"
!insertmacro INSTALL_MO "fr"
!insertmacro INSTALL_MO "nl"
StrCmp $R0 "NONE" done
CreateShortCut "$SMPROGRAMS\Pidgin\${PBAR_UNINSTALL_LNK}" "$INSTDIR\${PBAR_UNINST_EXE}"
WriteUninstaller "$INSTDIR\${PBAR_UNINST_EXE}"
SetOverWrite off
done:
SectionEnd
Section Uninstall
Call un.CheckUserInstallRights
Pop $R0
StrCmp $R0 "NONE" no_rights
StrCmp $R0 "HKCU" try_hkcu try_hklm
try_hkcu:
ReadRegStr $R0 HKCU "${PBAR_REG_KEY}" ""
StrCmp $R0 $INSTDIR 0 cant_uninstall
; HKCU install path matches our INSTDIR.. so uninstall
DeleteRegKey HKCU "${PBAR_REG_KEY}"
DeleteRegKey HKCU "${PBAR_UNINSTALL_KEY}"
Goto cont_uninstall
try_hklm:
ReadRegStr $R0 HKLM "${PBAR_REG_KEY}" ""
StrCmp $R0 $INSTDIR 0 try_hkcu
; HKLM install path matches our INSTDIR.. so uninstall
DeleteRegKey HKLM "${PBAR_REG_KEY}"
DeleteRegKey HKLM "${PBAR_UNINSTALL_KEY}"
; Sets start menu and desktop scope to all users..
SetShellVarContext "all"
cont_uninstall:
; plugin
Delete "$INSTDIR\plugins\${PBAR_DLL}"
; translations
; loop through locale dirs and try to delete any PBar translations
ClearErrors
FindFirst $R1 $R2 "$INSTDIR\locale\*"
IfErrors doneFindingTranslations
processCurrentTranslationDir:
;Ignore "." and ".."
StrCmp $R2 "." readNextTranslationDir
StrCmp $R2 ".." readNextTranslationDir
IfFileExists "$INSTDIR\locale\$R2\LC_MESSAGES\pidgin-pbar.mo" +1 readNextTranslationDir
Delete "$INSTDIR\locale\$R2\LC_MESSAGES\pidgin-pbar.mo"
RMDir "$INSTDIR\locale\$R2\LC_MESSAGES"
RMDir "$INSTDIR\locale\$R2"
ClearErrors
readNextTranslationDir:
FindNext $R1 $R2
IfErrors doneFindingTranslations processCurrentTranslationDir
doneFindingTranslations:
FindClose $R1
RMDir "$INSTDIR\locale"
; uninstaller
Delete "$INSTDIR\${PBAR_UNINST_EXE}"
; uninstaller shortcut
Delete "$SMPROGRAMS\Pidgin\${PBAR_UNINSTALL_LNK}"
; try to delete the Pidgin directories, in case it has already uninstalled
RMDir "$INSTDIR\plugins"
RMDir "$INSTDIR"
RMDir "$SMPROGRAMS\Pidgin"
Goto done
cant_uninstall:
MessageBox MB_OK $(un.PBAR_UNINSTALL_ERROR_1) IDOK
Quit
no_rights:
MessageBox MB_OK $(un.PBAR_UNINSTALL_ERROR_2) IDOK
Quit
done:
SectionEnd
Function .onInit
${GetParameters} $R0
ClearErrors
${GetOptions} $R0 "/L=" $R0
IfErrors +3
StrCpy $LANGUAGE $R0
Goto skip_lang
; Select Language
; Display Language selection dialog
!insertmacro MUI_LANGDLL_DISPLAY
skip_lang:
FunctionEnd
Function un.onInit
; Get stored language preference
!insertmacro MUI_UNGETLANGUAGE
FunctionEnd
; Check that the selected installation dir contains pidgin.exe
Function .onVerifyInstDir
IfFileExists $INSTDIR\pidgin.exe +2
Abort
FunctionEnd
; Check that the currently installed pidgin version is compatible with the version of PBar we are installing
Function pbar_checkPidginVersion
Push $R0
Push ${PIDGIN_VERSION}
Call CheckPidginVersion
Pop $R0
StrCmp $R0 ${PIDGIN_VERSION_OK} pbar_checkPidginVersion_OK
StrCmp $R0 ${PIDGIN_VERSION_INCOMPATIBLE} +1 +6
Call GetPidginVersion
IfErrors +3
Pop $R0
MessageBox MB_OK|MB_ICONSTOP "$(BAD_PIDGIN_VERSION_1) $R0 $(BAD_PIDGIN_VERSION_2)"
goto +2
MessageBox MB_OK|MB_ICONSTOP "$(NO_PIDGIN_VERSION)"
Quit
pbar_checkPidginVersion_OK:
Pop $R0
FunctionEnd
Function CheckUserInstallRights
ClearErrors
UserInfo::GetName
IfErrors Win9x
Pop $0
UserInfo::GetAccountType
Pop $1
StrCmp $1 "Admin" 0 +3
StrCpy $1 "HKLM"
Goto done
StrCmp $1 "Power" 0 +3
StrCpy $1 "HKLM"
Goto done
StrCmp $1 "User" 0 +3
StrCpy $1 "HKCU"
Goto done
StrCmp $1 "Guest" 0 +3
StrCpy $1 "NONE"
Goto done
; Unknown error
StrCpy $1 "NONE"
Goto done
Win9x:
StrCpy $1 "HKLM"
done:
Push $1
FunctionEnd
; This is necessary because the uninstaller doesn't have access to installer functions
; (it is identical to CheckUserInstallRights)
Function un.CheckUserInstallRights
ClearErrors
UserInfo::GetName
IfErrors Win9x
Pop $0
UserInfo::GetAccountType
Pop $1
StrCmp $1 "Admin" 0 +3
StrCpy $1 "HKLM"
Goto done
StrCmp $1 "Power" 0 +3
StrCpy $1 "HKLM"
Goto done
StrCmp $1 "User" 0 +3
StrCpy $1 "HKCU"
Goto done
StrCmp $1 "Guest" 0 +3
StrCpy $1 "NONE"
Goto done
; Unknown error
StrCpy $1 "NONE"
Goto done
Win9x:
StrCpy $1 "HKLM"
done:
Push $1
FunctionEnd
|
gawen947/pidgin-pbar
|
629250f2a82f4d81687ca64ff53e4c7254344f99
|
Fix Windows locales
|
diff --git a/installer.nsi b/installer.nsi
index 4424baa..fd4971f 100644
--- a/installer.nsi
+++ b/installer.nsi
@@ -1,407 +1,407 @@
; NSIS Script For PBar Plugin
; Author David Hauweele
; Based on the Guifications Plugin installer by Daniel A. Atallah
; Uses NSIS v2.0
;--------------------------------
;Include Modern UI
!include "MUI.nsh"
!include "FileFunc.nsh"
!insertmacro GetParameters
!insertmacro GetOptions
;--------------------------------
;General
Name "Pidgin PBar ${PBAR_VERSION}"
;Do A CRC Check
CRCCheck On
;Output File Name
OutFile "Pidgin-PBar_${PBAR_VERSION}.exe"
;The Default Installation Directory
InstallDir "$PROGRAMFILES\pidgin"
InstallDirRegKey HKLM SOFTWARE\pidgin ""
ShowInstDetails show
ShowUnInstDetails show
SetCompressor /SOLID lzma
;Reserve files used in .onInit for faster start-up
!insertmacro MUI_RESERVEFILE_LANGDLL
!define PBAR_UNINST_EXE "Pidgin-PBar-uninst.exe"
!define PBAR_DLL "pbar.dll"
!define PBAR_UNINSTALL_LNK "PBar Uninstall.lnk"
;--------------------------------
; Registry keys:
!define PBAR_REG_KEY "SOFTWARE\pidgin-pbar"
!define PBAR_UNINSTALL_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\pidgin-pbar"
;-------------------------------
; Pidgin Plugin installer helper stuff
!addincludedir "${PIDGIN_TREE_TOP}\pidgin\win32\nsis"
!include "pidgin-plugin.nsh"
;--------------------------------
; Modern UI Configuration
!define MUI_ICON .\nsis\install.ico
!define MUI_UNICON .\nsis\install.ico
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "nsis\header.bmp"
!define MUI_CUSTOMFUNCTION_GUIINIT pbar_checkPidginVersion
!define MUI_ABORTWARNING
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY ${PBAR_REG_KEY}
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
;--------------------------------
; Pages
;Welcome Page
!define MUI_WELCOMEPAGE_TITLE $(WELCOME_TITLE)
!define MUI_WELCOMEPAGE_TEXT $(WELCOME_TEXT)
!insertmacro MUI_PAGE_WELCOME
;License Page
!define MUI_LICENSEPAGE_RADIOBUTTONS
!insertmacro MUI_PAGE_LICENSE ".\COPYING"
;Directory Page
!define MUI_DIRECTORYPAGE_TEXT_TOP $(DIR_SUBTITLE)
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION $(DIR_INNERTEXT)
!insertmacro MUI_PAGE_DIRECTORY
;Installation Page
!insertmacro MUI_PAGE_INSTFILES
;Finish Page
!define MUI_FINISHPAGE_TITLE $(FINISH_TITLE)
!define MUI_FINISHPAGE_TEXT $(FINISH_TEXT)
!insertmacro MUI_PAGE_FINISH
;--------------------------------
; Languages
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "Dutch"
!insertmacro MUI_LANGUAGE "German"
;Translations
!include "nsis\english.nsh"
!include "nsis\french.nsh"
!include "nsis\dutch.nsh"
!include "nsis\german.nsh"
; Uninstall the previous version if it exists
Section -SecUninstallOldPlugin
; Check install rights..
Call CheckUserInstallRights
Pop $R0
StrCmp $R0 "HKLM" rights_hklm
StrCmp $R0 "HKCU" rights_hkcu done
rights_hkcu:
ReadRegStr $R1 HKCU "${PBAR_REG_KEY}" ""
ReadRegStr $R2 HKCU "${PBAR_REG_KEY}" "Version"
ReadRegStr $R3 HKCU "${PBAR_UNINSTALL_KEY}" "UninstallString"
Goto try_uninstall
rights_hklm:
ReadRegStr $R1 HKLM "${PBAR_REG_KEY}" ""
ReadRegStr $R2 HKLM "${PBAR_REG_KEY}" "Version"
ReadRegStr $R3 HKLM "${PBAR_UNINSTALL_KEY}" "UninstallString"
; If previous version exists .. remove
try_uninstall:
StrCmp $R1 "" done
StrCmp $R2 "" uninstall_problem
IfFileExists $R3 0 uninstall_problem
; Have uninstall string.. go ahead and uninstall.
SetOverwrite on
; Need to copy uninstaller outside of the install dir
ClearErrors
CopyFiles /SILENT $R3 "$TEMP\${PBAR_UNINST_EXE}"
SetOverwrite off
IfErrors uninstall_problem
; Ready to uninstall..
ClearErrors
ExecWait '"$TEMP\${PBAR_UNINST_EXE}" /S _?=$R1'
IfErrors exec_error
Delete "$TEMP\${PBAR_UNINST_EXE}"
Goto done
exec_error:
Delete "$TEMP\${PBAR_UNINST_EXE}"
Goto uninstall_problem
uninstall_problem:
; Just delete the plugin and uninstaller, and remove Registry key
MessageBox MB_YESNO $(PBAR_PROMPT_WIPEOUT) IDYES do_wipeout IDNO cancel_install
cancel_install:
Quit
do_wipeout:
StrCmp $R0 "HKLM" del_lm_reg del_cu_reg
del_cu_reg:
DeleteRegKey HKCU ${PBAR_REG_KEY}
Goto uninstall_prob_cont
del_lm_reg:
DeleteRegKey HKLM ${PBAR_REG_KEY}
uninstall_prob_cont:
; plugin DLL
Delete "$R1\plugins\${PBAR_DLL}"
Delete "$R3"
done:
SectionEnd
!macro INSTALL_MO LANG
SetOutPath "$INSTDIR\locale\${LANG}\LC_MESSAGES"
- File /oname=pbar.mo ${LANG}.mo
+ File /oname=pidgin-pbar.mo ${LANG}.mo
!macroend
Section "Install"
Call CheckUserInstallRights
Pop $R0
StrCmp $R0 "NONE" instrights_none
StrCmp $R0 "HKLM" instrights_hklm instrights_hkcu
instrights_hklm:
; Write the version registry keys:
WriteRegStr HKLM ${PBAR_REG_KEY} "" "$INSTDIR"
WriteRegStr HKLM ${PBAR_REG_KEY} "Version" "${PBAR_VERSION}"
; Write the uninstall keys for Windows
WriteRegStr HKLM ${PBAR_UNINSTALL_KEY} "DisplayName" "$(PBAR_UNINSTALL_DESC)"
WriteRegStr HKLM ${PBAR_UNINSTALL_KEY} "UninstallString" "$INSTDIR\${PBAR_UNINST_EXE}"
SetShellVarContext "all"
Goto install_files
instrights_hkcu:
; Write the version registry keys:
WriteRegStr HKCU ${PBAR_REG_KEY} "" "$INSTDIR"
WriteRegStr HKCU ${PBAR_REG_KEY} "Version" "${PBAR_VERSION}"
; Write the uninstall keys for Windows
WriteRegStr HKCU ${PBAR_UNINSTALL_KEY} "DisplayName" "$(PBAR_UNINSTALL_DESC)"
WriteRegStr HKCU ${PBAR_UNINSTALL_KEY} "UninstallString" "$INSTDIR\${PBAR_UNINST_EXE}"
Goto install_files
instrights_none:
; No registry keys for us...
install_files:
SetOutPath "$INSTDIR\plugins"
SetCompress Auto
SetOverwrite on
File "${PBAR_DLL}"
; translations - if there is a way to automate this, i can't find it
!insertmacro INSTALL_MO "de"
!insertmacro INSTALL_MO "fr"
!insertmacro INSTALL_MO "nl"
StrCmp $R0 "NONE" done
CreateShortCut "$SMPROGRAMS\Pidgin\${PBAR_UNINSTALL_LNK}" "$INSTDIR\${PBAR_UNINST_EXE}"
WriteUninstaller "$INSTDIR\${PBAR_UNINST_EXE}"
SetOverWrite off
done:
SectionEnd
Section Uninstall
Call un.CheckUserInstallRights
Pop $R0
StrCmp $R0 "NONE" no_rights
StrCmp $R0 "HKCU" try_hkcu try_hklm
try_hkcu:
ReadRegStr $R0 HKCU "${PBAR_REG_KEY}" ""
StrCmp $R0 $INSTDIR 0 cant_uninstall
; HKCU install path matches our INSTDIR.. so uninstall
DeleteRegKey HKCU "${PBAR_REG_KEY}"
DeleteRegKey HKCU "${PBAR_UNINSTALL_KEY}"
Goto cont_uninstall
try_hklm:
ReadRegStr $R0 HKLM "${PBAR_REG_KEY}" ""
StrCmp $R0 $INSTDIR 0 try_hkcu
; HKLM install path matches our INSTDIR.. so uninstall
DeleteRegKey HKLM "${PBAR_REG_KEY}"
DeleteRegKey HKLM "${PBAR_UNINSTALL_KEY}"
; Sets start menu and desktop scope to all users..
SetShellVarContext "all"
cont_uninstall:
; plugin
Delete "$INSTDIR\plugins\${PBAR_DLL}"
; translations
; loop through locale dirs and try to delete any PBar translations
ClearErrors
FindFirst $R1 $R2 "$INSTDIR\locale\*"
IfErrors doneFindingTranslations
processCurrentTranslationDir:
;Ignore "." and ".."
StrCmp $R2 "." readNextTranslationDir
StrCmp $R2 ".." readNextTranslationDir
- IfFileExists "$INSTDIR\locale\$R2\LC_MESSAGES\pbar.mo" +1 readNextTranslationDir
- Delete "$INSTDIR\locale\$R2\LC_MESSAGES\pbar.mo"
+ IfFileExists "$INSTDIR\locale\$R2\LC_MESSAGES\pidgin-pbar.mo" +1 readNextTranslationDir
+ Delete "$INSTDIR\locale\$R2\LC_MESSAGES\pidgin-pbar.mo"
RMDir "$INSTDIR\locale\$R2\LC_MESSAGES"
RMDir "$INSTDIR\locale\$R2"
ClearErrors
readNextTranslationDir:
FindNext $R1 $R2
IfErrors doneFindingTranslations processCurrentTranslationDir
doneFindingTranslations:
FindClose $R1
RMDir "$INSTDIR\locale"
; uninstaller
Delete "$INSTDIR\${PBAR_UNINST_EXE}"
; uninstaller shortcut
Delete "$SMPROGRAMS\Pidgin\${PBAR_UNINSTALL_LNK}"
; try to delete the Pidgin directories, in case it has already uninstalled
RMDir "$INSTDIR\plugins"
RMDir "$INSTDIR"
RMDir "$SMPROGRAMS\Pidgin"
Goto done
cant_uninstall:
MessageBox MB_OK $(un.PBAR_UNINSTALL_ERROR_1) IDOK
Quit
no_rights:
MessageBox MB_OK $(un.PBAR_UNINSTALL_ERROR_2) IDOK
Quit
done:
SectionEnd
Function .onInit
${GetParameters} $R0
ClearErrors
${GetOptions} $R0 "/L=" $R0
IfErrors +3
StrCpy $LANGUAGE $R0
Goto skip_lang
; Select Language
; Display Language selection dialog
!insertmacro MUI_LANGDLL_DISPLAY
skip_lang:
FunctionEnd
Function un.onInit
; Get stored language preference
!insertmacro MUI_UNGETLANGUAGE
FunctionEnd
; Check that the selected installation dir contains pidgin.exe
Function .onVerifyInstDir
IfFileExists $INSTDIR\pidgin.exe +2
Abort
FunctionEnd
; Check that the currently installed pidgin version is compatible with the version of PBar we are installing
Function pbar_checkPidginVersion
Push $R0
Push ${PIDGIN_VERSION}
Call CheckPidginVersion
Pop $R0
StrCmp $R0 ${PIDGIN_VERSION_OK} pbar_checkPidginVersion_OK
StrCmp $R0 ${PIDGIN_VERSION_INCOMPATIBLE} +1 +6
Call GetPidginVersion
IfErrors +3
Pop $R0
MessageBox MB_OK|MB_ICONSTOP "$(BAD_PIDGIN_VERSION_1) $R0 $(BAD_PIDGIN_VERSION_2)"
goto +2
MessageBox MB_OK|MB_ICONSTOP "$(NO_PIDGIN_VERSION)"
Quit
pbar_checkPidginVersion_OK:
Pop $R0
FunctionEnd
Function CheckUserInstallRights
ClearErrors
UserInfo::GetName
IfErrors Win9x
Pop $0
UserInfo::GetAccountType
Pop $1
StrCmp $1 "Admin" 0 +3
StrCpy $1 "HKLM"
Goto done
StrCmp $1 "Power" 0 +3
StrCpy $1 "HKLM"
Goto done
StrCmp $1 "User" 0 +3
StrCpy $1 "HKCU"
Goto done
StrCmp $1 "Guest" 0 +3
StrCpy $1 "NONE"
Goto done
; Unknown error
StrCpy $1 "NONE"
Goto done
Win9x:
StrCpy $1 "HKLM"
done:
Push $1
FunctionEnd
; This is necessary because the uninstaller doesn't have access to installer functions
; (it is identical to CheckUserInstallRights)
Function un.CheckUserInstallRights
ClearErrors
UserInfo::GetName
IfErrors Win9x
Pop $0
UserInfo::GetAccountType
Pop $1
StrCmp $1 "Admin" 0 +3
StrCpy $1 "HKLM"
Goto done
StrCmp $1 "Power" 0 +3
StrCpy $1 "HKLM"
Goto done
StrCmp $1 "User" 0 +3
StrCpy $1 "HKCU"
Goto done
StrCmp $1 "Guest" 0 +3
StrCpy $1 "NONE"
Goto done
; Unknown error
StrCpy $1 "NONE"
Goto done
Win9x:
StrCpy $1 "HKLM"
done:
Push $1
FunctionEnd
|
gawen947/pidgin-pbar
|
d0961370ee3cb662cfbdf79af0d7c1c30a7cfca0
|
Fix Windows makefile
|
diff --git a/makefile.mingw b/makefile.mingw
index 59b9d58..b06370b 100644
--- a/makefile.mingw
+++ b/makefile.mingw
@@ -1,113 +1,111 @@
#
# Makefile.mingw
#
# Description: Makefile for Pidgin PBar.
# Taken from the privacy please plugin.
#
include commands.mk
PIDGIN_TREE_TOP := ../../..
include $(PIDGIN_TREE_TOP)/libpurple/win32/global.mak
VERSION = $(shell cat VERSION)
NSIS_VERSION = "$(VERSION)"
TARGET = pbar
-#DEFINES += -DGETTEXT_PACKAGE=\"pbar\"
-DEFINES += -DVERSION=\"$(VERSION)\"
-#DEFINES += -DDATADIR=\"$(PIDGIN_INSTALL_DIR)\"
+DEFINES += -DVERSION="\"$(VERSION)\""
INCLUDE_PATHS += -I. \
-I$(GTK_TOP)/include \
-I$(GTK_TOP)/include/gtk-2.0 \
-I$(GTK_TOP)/include/glib-2.0 \
-I$(GTK_TOP)/include/pango-1.0 \
-I$(GTK_TOP)/include/atk-1.0 \
-I$(GTK_TOP)/include/cairo \
-I$(GTK_TOP)/lib/glib-2.0/include \
-I$(GTK_TOP)/lib/gtk-2.0/include \
-I$(PURPLE_TOP) \
-I$(PURPLE_TOP)/win32 \
-I$(PIDGIN_TOP) \
-I$(PIDGIN_TOP)/win32 \
-I$(PIDGIN_TREE_TOP)
LIB_PATHS += -L$(GTK_TOP)/lib \
-L$(PURPLE_TOP) \
-L$(PIDGIN_TOP)
C_SRC = $(wildcard *.c)
OBJECTS = $(C_SRC:%.c=%.o)
LIBS = -lgtk-win32-2.0 \
-lglib-2.0 \
-lgdk-win32-2.0 \
-lgdk_pixbuf-2.0 \
-lgobject-2.0 \
-lintl \
-lpurple \
-lpidgin
ifndef DISABLE_DEBUG
CFLAGS += -ggdb
endif
commit = $(shell ./hash.sh)
ifneq ($(commit), UNKNOWN)
DEFINES += -DCOMMIT="\"$(commit)\""
DEFINES += -DPARTIAL_COMMIT="\"$(shell echo $(commit) | cut -c1-8)\""
-NSIS_VERSION = "$(VERSION)+$(shell echo $(commit) | cut -c1- 8)\""
+NSIS_VERSION = "$(VERSION)+$(shell echo $(commit) | cut -c1-8)"
endif
POFILES = $(wildcard *.po)
CATALOGS = $(foreach cat, $(POFILES:.po=.mo), $(notdir $(cat)))
ifndef DISABLE_NLS
DEFINES += -DENABLE_NLS=1
locales := locales
install-locales := install-locales
uninstall-locales := uninstall-locales
endif
include $(PIDGIN_COMMON_RULES)
.PHONY: all install clean
all: $(TARGET).dll $(locales)
install: $(PIDGIN_INSTALL_PLUGINS_DIR) all
cp $(TARGET).dll $(PIDGIN_INSTALL_PLUGINS_DIR)
$(OBJECTS): $(PIDGIN_CONFIG_H)
$(TARGET).dll: $(PURPLE_DLL).a $(PIDGIN_DLL).a $(OBJECTS)
$(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -o $(TARGET).dll
clean:
rm -rf $(OBJECTS)
rm -rf $(TARGET).dll
locales: $(CATALOGS)
CAT_INST_PATH = $(foreach lang, $(POFILES:.po=), $(LOCALEDIR)/$(lang)/LC_MESSAGES/pidgin-pbar.mo)
install-locales: $(CAT_INST_PATH)
$(LOCALEDIR)/%/LC_MESSAGES/pidgin-pbar.mo: %.mo
$(MKDIR) -p $(LOCALEDIR)/$(basename $<)/LC_MESSAGES
$(INSTALL_DATA) $< $@
uninstall-locales:
$(RM) $(CAT_INST_PATH)
%.mo: %.po
$(MSGFMT) -c -o $@ $<
messages.pot: POTFILES.in
$(XGETTEXT) --no-wrap -m -c --files-from $< --keyword --keyword=_ --keyword=N_ -o $@
installer: all
$(MAKENSIS) -DPBAR_VERSION="$(NSIS_VERSION)" -DPIDGIN_VERSION="$(PIDGIN_VERSION)" -DPIDGIN_TREE_TOP="$(PIDGIN_TREE_TOP)" installer.nsi
include $(PIDGIN_COMMON_TARGETS)
|
gawen947/pidgin-pbar
|
080876f0dca2f651393c280f125b71192b553401
|
Full and partial commit
|
diff --git a/hash.sh b/hash.sh
index 636c96f..8baa549 100755
--- a/hash.sh
+++ b/hash.sh
@@ -1,15 +1,15 @@
#!/bin/sh
# script to determine git hash of current source tree
# try to use whatever git tells us if there is a .git folder
if [ -d .git -a -r .git ]
then
hash=$(git log 2>/dev/null | head -n1 2>/dev/null | sed "s/.* //" 2>/dev/null)
fi
if [ x"$hash" != x ]
then
- echo $hash | cut -c1-8
+ echo $hash
else
echo "UNKNOWN"
fi
exit 0
diff --git a/makefile b/makefile
index afa76ea..9462651 100644
--- a/makefile
+++ b/makefile
@@ -1,83 +1,84 @@
include commands.mk
OPTS := -O2
CFLAGS := -std=c99 $(OPTS) $(shell pkg-config --cflags pidgin purple gtk+-2.0 gobject-2.0) -fPIC -Wall
LDFLAGS := $(shell pkg-config --libs pidgin purple gtk+-2.0 gobject-2.0)
SRC = $(wildcard *.c)
OBJ = $(foreach obj, $(SRC:.c=.o), $(notdir $(obj)))
DEP = $(SRC:.c=.d)
POFILES = $(wildcard *.po)
CATALOGS = $(foreach cat, $(POFILES:.po=.mo), $(notdir $(cat)))
PREFIX ?= /usr/local
LOCALEDIR ?= $(PREFIX)/share/locale
PLUGINDIR ?= $(shell pkg-config --variable=plugindir pidgin)
DATADIR ?= $(shell pkg-config --variable=datadir pidgin)
PBAR_VERSION := $(shell cat VERSION)
CFLAGS += -DVERSION="\"$(PBAR_VERSION)\""
ifndef DISABLE_DEBUG
CFLAGS += -ggdb
endif
commit = $(shell ./hash.sh)
ifneq ($(commit), UNKNOWN)
CFLAGS += -DCOMMIT="\"$(commit)\""
+CFLAGS += -DPARTIAL_COMMIT="\"$(shell echo $(commit) | cut -c1-8)\""
endif
ifndef DISABLE_NLS
CFLAGS += -DENABLE_NLS=1 -DLOCALEDIR="\"$(LOCALEDIR)\""
locales := locales
install-locales := install-locales
uninstall-locales := uninstall-locales
endif
CFLAGS += -DDATADIR="\"$(DATADIR)\""
.PHONY: all clean
all: pbar.so $(locales)
pbar.so: $(OBJ)
$(CC) -shared -o $@ $^ $(LDFLAGS)
%.o: %.c
$(CC) -Wp,-MMD,$*.d -c $(CFLAGS) -o $@ $<
clean:
$(RM) $(DEP)
$(RM) $(OBJ)
$(RM) $(CATALOGS)
$(RM) messages.pot
$(RM) pbar.so
install: $(install-locales)
$(MKDIR) -p $(DESTDIR)$(PLUGINDIR)
$(INSTALL_PROGRAM) pbar.so $(DESTDIR)$(PLUGINDIR)
uninstall: $(uninstall-locales)
$(RM) $(PLUGINDIR)/pbar.so
locales: $(CATALOGS)
CAT_INST_PATH = $(foreach lang, $(POFILES:.po=), $(DESTDIR)$(LOCALEDIR)/$(lang)/LC_MESSAGES/pidgin-pbar.mo)
install-locales: $(CAT_INST_PATH)
$(DESTDIR)$(LOCALEDIR)/%/LC_MESSAGES/pidgin-pbar.mo: %.mo
$(MKDIR) -p $(DESTDIR)$(LOCALEDIR)/$(basename $<)/LC_MESSAGES
$(INSTALL_DATA) $< $@
uninstall-locales:
$(RM) $(CAT_INST_PATH)
%.mo: %.po
$(MSGFMT) -c -o $@ $<
messages.pot: POTFILES.in
$(XGETTEXT) --no-wrap -m -c --files-from $< --keyword --keyword=_ --keyword=N_ -o $@
-include $(DEP)
diff --git a/makefile.mingw b/makefile.mingw
index efe7868..59b9d58 100644
--- a/makefile.mingw
+++ b/makefile.mingw
@@ -1,112 +1,113 @@
#
# Makefile.mingw
#
# Description: Makefile for Pidgin PBar.
# Taken from the privacy please plugin.
#
include commands.mk
PIDGIN_TREE_TOP := ../../..
include $(PIDGIN_TREE_TOP)/libpurple/win32/global.mak
VERSION = $(shell cat VERSION)
NSIS_VERSION = "$(VERSION)"
TARGET = pbar
#DEFINES += -DGETTEXT_PACKAGE=\"pbar\"
DEFINES += -DVERSION=\"$(VERSION)\"
#DEFINES += -DDATADIR=\"$(PIDGIN_INSTALL_DIR)\"
INCLUDE_PATHS += -I. \
-I$(GTK_TOP)/include \
-I$(GTK_TOP)/include/gtk-2.0 \
-I$(GTK_TOP)/include/glib-2.0 \
-I$(GTK_TOP)/include/pango-1.0 \
-I$(GTK_TOP)/include/atk-1.0 \
-I$(GTK_TOP)/include/cairo \
-I$(GTK_TOP)/lib/glib-2.0/include \
-I$(GTK_TOP)/lib/gtk-2.0/include \
-I$(PURPLE_TOP) \
-I$(PURPLE_TOP)/win32 \
-I$(PIDGIN_TOP) \
-I$(PIDGIN_TOP)/win32 \
-I$(PIDGIN_TREE_TOP)
LIB_PATHS += -L$(GTK_TOP)/lib \
-L$(PURPLE_TOP) \
-L$(PIDGIN_TOP)
C_SRC = $(wildcard *.c)
OBJECTS = $(C_SRC:%.c=%.o)
LIBS = -lgtk-win32-2.0 \
-lglib-2.0 \
-lgdk-win32-2.0 \
-lgdk_pixbuf-2.0 \
-lgobject-2.0 \
-lintl \
-lpurple \
-lpidgin
ifndef DISABLE_DEBUG
CFLAGS += -ggdb
endif
commit = $(shell ./hash.sh)
ifneq ($(commit), UNKNOWN)
-NSIS_VERSION = "$(VERSION)+$(commit)"
DEFINES += -DCOMMIT="\"$(commit)\""
+DEFINES += -DPARTIAL_COMMIT="\"$(shell echo $(commit) | cut -c1-8)\""
+NSIS_VERSION = "$(VERSION)+$(shell echo $(commit) | cut -c1- 8)\""
endif
POFILES = $(wildcard *.po)
CATALOGS = $(foreach cat, $(POFILES:.po=.mo), $(notdir $(cat)))
ifndef DISABLE_NLS
DEFINES += -DENABLE_NLS=1
locales := locales
install-locales := install-locales
uninstall-locales := uninstall-locales
endif
include $(PIDGIN_COMMON_RULES)
.PHONY: all install clean
all: $(TARGET).dll $(locales)
install: $(PIDGIN_INSTALL_PLUGINS_DIR) all
cp $(TARGET).dll $(PIDGIN_INSTALL_PLUGINS_DIR)
$(OBJECTS): $(PIDGIN_CONFIG_H)
$(TARGET).dll: $(PURPLE_DLL).a $(PIDGIN_DLL).a $(OBJECTS)
$(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -o $(TARGET).dll
clean:
rm -rf $(OBJECTS)
rm -rf $(TARGET).dll
locales: $(CATALOGS)
CAT_INST_PATH = $(foreach lang, $(POFILES:.po=), $(LOCALEDIR)/$(lang)/LC_MESSAGES/pidgin-pbar.mo)
install-locales: $(CAT_INST_PATH)
$(LOCALEDIR)/%/LC_MESSAGES/pidgin-pbar.mo: %.mo
$(MKDIR) -p $(LOCALEDIR)/$(basename $<)/LC_MESSAGES
$(INSTALL_DATA) $< $@
uninstall-locales:
$(RM) $(CAT_INST_PATH)
%.mo: %.po
$(MSGFMT) -c -o $@ $<
messages.pot: POTFILES.in
$(XGETTEXT) --no-wrap -m -c --files-from $< --keyword --keyword=_ --keyword=N_ -o $@
installer: all
$(MAKENSIS) -DPBAR_VERSION="$(NSIS_VERSION)" -DPIDGIN_VERSION="$(PIDGIN_VERSION)" -DPIDGIN_TREE_TOP="$(PIDGIN_TREE_TOP)" installer.nsi
include $(PIDGIN_COMMON_TARGETS)
diff --git a/pbar.h b/pbar.h
index 118f0dc..eedc1a8 100644
--- a/pbar.h
+++ b/pbar.h
@@ -1,60 +1,63 @@
/* File: pbar.h
Time-stamp: <2011-06-26 21:15:42 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _PBAR_H_
#define _PBAR_H_
#include "common.h"
#ifndef G_GNUC_NULL_TERMINATED
# if __GNUC__ >= 4
# define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
# else
# define G_GNUC_NULL_TERMINATED
# endif /* __GNUC__ >= 4 */
#endif /* G_GNUC_NULL_TERMINATED */
/* name */
#define NAME "pbar" /* internal name */
#define DISP_NAME N_("PBar") /* displayed name */
/* plugin information */
#define PLUGIN_ID "gtk-" NAME /* gtk plugin id */
#define PLUGIN_NAME DISP_NAME
#ifndef COMMIT
# define PLUGIN_VERSION VERSION
#else
-# define PLUGIN_VERSION VERSION " (commit: " COMMIT ")" /* add git commit
- when available */
+# define PLUGIN_VERSION VERSION " (commit: " PARTIAL_COMMIT ")" /* add git
+ commit
+ when
+ available
+ */
#endif
#define PLUGIN_SUMMARY N_("A toolbar to update some account settings " \
"globally.")
#define PLUGIN_DESCRIPTION N_("Adds a toolbar to the buddy list to quickly " \
"update nickname, personal message, icon, " \
"status and mood. It also allows updating of " \
"the current song and other parameters which " \
"are updated globally on all accounts that " \
"support them.")
#define PLUGIN_AUTHOR "David Hauweele <[email protected]>"
#define PLUGIN_WEBSITE "http://www.hauweele.net/~gawen/pidgin-pbar.html"
extern PurplePlugin *thisplugin;
#endif /* _PBAR_H_ */
|
gawen947/pidgin-pbar
|
5b7dd61189fd1df835dd55bd48ce7e9f6a752d2e
|
Display partial commit
|
diff --git a/pbar.h b/pbar.h
index 2a0c4ed..118f0dc 100644
--- a/pbar.h
+++ b/pbar.h
@@ -1,60 +1,60 @@
/* File: pbar.h
- Time-stamp: <2010-11-15 23:55:36 gawen>
+ Time-stamp: <2011-06-26 21:15:42 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _PBAR_H_
#define _PBAR_H_
#include "common.h"
#ifndef G_GNUC_NULL_TERMINATED
# if __GNUC__ >= 4
# define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
# else
# define G_GNUC_NULL_TERMINATED
# endif /* __GNUC__ >= 4 */
#endif /* G_GNUC_NULL_TERMINATED */
/* name */
#define NAME "pbar" /* internal name */
#define DISP_NAME N_("PBar") /* displayed name */
/* plugin information */
#define PLUGIN_ID "gtk-" NAME /* gtk plugin id */
#define PLUGIN_NAME DISP_NAME
#ifndef COMMIT
# define PLUGIN_VERSION VERSION
#else
-# define PLUGIN_VERSION VERSION " (commit:" COMMIT ")" /* add git commit
- when available */
+# define PLUGIN_VERSION VERSION " (commit: " COMMIT ")" /* add git commit
+ when available */
#endif
#define PLUGIN_SUMMARY N_("A toolbar to update some account settings " \
"globally.")
#define PLUGIN_DESCRIPTION N_("Adds a toolbar to the buddy list to quickly " \
"update nickname, personal message, icon, " \
"status and mood. It also allows updating of " \
"the current song and other parameters which " \
"are updated globally on all accounts that " \
"support them.")
#define PLUGIN_AUTHOR "David Hauweele <[email protected]>"
#define PLUGIN_WEBSITE "http://www.hauweele.net/~gawen/pidgin-pbar.html"
extern PurplePlugin *thisplugin;
#endif /* _PBAR_H_ */
|
gawen947/pidgin-pbar
|
1fdebf19e71bc5c45fba1c8a25c70a86c79dd519
|
Fix installer version Add partial commit to version
|
diff --git a/hash.sh b/hash.sh
index 8baa549..636c96f 100755
--- a/hash.sh
+++ b/hash.sh
@@ -1,15 +1,15 @@
#!/bin/sh
# script to determine git hash of current source tree
# try to use whatever git tells us if there is a .git folder
if [ -d .git -a -r .git ]
then
hash=$(git log 2>/dev/null | head -n1 2>/dev/null | sed "s/.* //" 2>/dev/null)
fi
if [ x"$hash" != x ]
then
- echo $hash
+ echo $hash | cut -c1-8
else
echo "UNKNOWN"
fi
exit 0
diff --git a/makefile.mingw b/makefile.mingw
index fc19e1b..efe7868 100644
--- a/makefile.mingw
+++ b/makefile.mingw
@@ -1,111 +1,112 @@
#
# Makefile.mingw
#
# Description: Makefile for Pidgin PBar.
# Taken from the privacy please plugin.
#
include commands.mk
PIDGIN_TREE_TOP := ../../..
include $(PIDGIN_TREE_TOP)/libpurple/win32/global.mak
-VERSION = $(shell cat VERSION)
-
+VERSION = $(shell cat VERSION)
+NSIS_VERSION = "$(VERSION)"
TARGET = pbar
-DEFINES += -DGETTEXT_PACKAGE=\"pbar\"
+#DEFINES += -DGETTEXT_PACKAGE=\"pbar\"
DEFINES += -DVERSION=\"$(VERSION)\"
-DEFINES += -DDATADIR=\"$(PIDGIN_INSTALL_DIR)\"
+#DEFINES += -DDATADIR=\"$(PIDGIN_INSTALL_DIR)\"
INCLUDE_PATHS += -I. \
-I$(GTK_TOP)/include \
-I$(GTK_TOP)/include/gtk-2.0 \
-I$(GTK_TOP)/include/glib-2.0 \
-I$(GTK_TOP)/include/pango-1.0 \
-I$(GTK_TOP)/include/atk-1.0 \
-I$(GTK_TOP)/include/cairo \
-I$(GTK_TOP)/lib/glib-2.0/include \
-I$(GTK_TOP)/lib/gtk-2.0/include \
-I$(PURPLE_TOP) \
-I$(PURPLE_TOP)/win32 \
-I$(PIDGIN_TOP) \
-I$(PIDGIN_TOP)/win32 \
-I$(PIDGIN_TREE_TOP)
LIB_PATHS += -L$(GTK_TOP)/lib \
-L$(PURPLE_TOP) \
-L$(PIDGIN_TOP)
C_SRC = $(wildcard *.c)
OBJECTS = $(C_SRC:%.c=%.o)
LIBS = -lgtk-win32-2.0 \
-lglib-2.0 \
-lgdk-win32-2.0 \
-lgdk_pixbuf-2.0 \
-lgobject-2.0 \
-lintl \
-lpurple \
-lpidgin
ifndef DISABLE_DEBUG
CFLAGS += -ggdb
endif
commit = $(shell ./hash.sh)
ifneq ($(commit), UNKNOWN)
+NSIS_VERSION = "$(VERSION)+$(commit)"
DEFINES += -DCOMMIT="\"$(commit)\""
endif
POFILES = $(wildcard *.po)
CATALOGS = $(foreach cat, $(POFILES:.po=.mo), $(notdir $(cat)))
ifndef DISABLE_NLS
DEFINES += -DENABLE_NLS=1
locales := locales
install-locales := install-locales
uninstall-locales := uninstall-locales
endif
include $(PIDGIN_COMMON_RULES)
.PHONY: all install clean
all: $(TARGET).dll $(locales)
install: $(PIDGIN_INSTALL_PLUGINS_DIR) all
cp $(TARGET).dll $(PIDGIN_INSTALL_PLUGINS_DIR)
$(OBJECTS): $(PIDGIN_CONFIG_H)
$(TARGET).dll: $(PURPLE_DLL).a $(PIDGIN_DLL).a $(OBJECTS)
$(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -o $(TARGET).dll
clean:
rm -rf $(OBJECTS)
rm -rf $(TARGET).dll
locales: $(CATALOGS)
CAT_INST_PATH = $(foreach lang, $(POFILES:.po=), $(LOCALEDIR)/$(lang)/LC_MESSAGES/pidgin-pbar.mo)
install-locales: $(CAT_INST_PATH)
$(LOCALEDIR)/%/LC_MESSAGES/pidgin-pbar.mo: %.mo
$(MKDIR) -p $(LOCALEDIR)/$(basename $<)/LC_MESSAGES
$(INSTALL_DATA) $< $@
uninstall-locales:
$(RM) $(CAT_INST_PATH)
%.mo: %.po
$(MSGFMT) -c -o $@ $<
messages.pot: POTFILES.in
$(XGETTEXT) --no-wrap -m -c --files-from $< --keyword --keyword=_ --keyword=N_ -o $@
installer: all
- $(MAKENSIS) -DPBAR_VERSION="$(VERSION)" -DPIDGIN_VERSION="$(PIDGIN_VERSION)" -DPIDGIN_TREE_TOP="$(PIDGIN_TREE_TOP)" installer.nsi
+ $(MAKENSIS) -DPBAR_VERSION="$(NSIS_VERSION)" -DPIDGIN_VERSION="$(PIDGIN_VERSION)" -DPIDGIN_TREE_TOP="$(PIDGIN_TREE_TOP)" installer.nsi
include $(PIDGIN_COMMON_TARGETS)
|
gawen947/pidgin-pbar
|
2cc2c8f779a6144aaab3094e73d2cb3253984136
|
New icon
|
diff --git a/nsis/header.bmp b/nsis/header.bmp
index 77a2da3..b14b4dc 100644
Binary files a/nsis/header.bmp and b/nsis/header.bmp differ
diff --git a/nsis/install.ico b/nsis/install.ico
index e9ae3b6..1b8467c 100644
Binary files a/nsis/install.ico and b/nsis/install.ico differ
|
gawen947/pidgin-pbar
|
ac84ef59d6eccdd3b82fda20c27af3baa1b0bd6a
|
New icon
|
diff --git a/nsis/dutch.nsh b/nsis/dutch.nsh
index 699aa5c..cf83c68 100644
--- a/nsis/dutch.nsh
+++ b/nsis/dutch.nsh
@@ -1,39 +1,39 @@
;;
;; english.nsh
;;
-;; Default language strings for the Windows guifications NSIS installer.
+;; Default language strings for the Windows PBar NSIS installer.
;; Windows Code page: 1252
;; Language Code: 1033
;;
; Startup Pidgin check
-LangString PIDGIN_NEEDED ${LANG_ENGLISH} "Guifications requires that Pidgin be installed. You must install Pidgin before installing Guifications."
+LangString PIDGIN_NEEDED ${LANG_ENGLISH} "PBar requires that Pidgin be installed. You must install Pidgin before installing PBar."
-LangString GUIFICATIONS_TITLE ${LANG_ENGLISH} "Guifications plugin for Pidgin"
+LangString PBAR_TITLE ${LANG_ENGLISH} "PBar plugin for Pidgin"
-LangString BAD_PIDGIN_VERSION_1 ${LANG_ENGLISH} "Incompatible version.$\r$\n$\r$\nThis version of the Guifications plugin was built for Pidgin version ${PIDGIN_VERSION}. It appears that you have Pidgin version"
+LangString BAD_PIDGIN_VERSION_1 ${LANG_ENGLISH} "Incompatible version.$\r$\n$\r$\nThis version of the PBar plugin was built for Pidgin version ${PIDGIN_VERSION}. It appears that you have Pidgin version"
-LangString BAD_PIDGIN_VERSION_2 ${LANG_ENGLISH} "installed.$\r$\n$\r$\nSee http://guifications.sourceforge.net for more information."
+LangString BAD_PIDGIN_VERSION_2 ${LANG_ENGLISH} "installed.$\r$\n$\r$\nSee http://www.hauweele.net/~gawen/pidgin-pbar.html for more information."
LangString NO_PIDGIN_VERSION ${LANG_ENGLISH} "Unable to determine installed Pidgin version."
; Overrides for default text in windows:
-LangString WELCOME_TITLE ${LANG_ENGLISH} "Guifications v${GUIFICATIONS_VERSION} Installer"
+LangString WELCOME_TITLE ${LANG_ENGLISH} "PBar v${PBAR_VERSION} Installer"
LangString WELCOME_TEXT ${LANG_ENGLISH} "Note: This version of the plugin is designed for Pidgin ${PIDGIN_VERSION}, and will not install or function with versions of Pidgin having a different major version number.\r\n\r\nWhen you upgrade your version of Pidgin, you must uninstall or upgrade this plugin as well.\r\n\r\n"
LangString DIR_SUBTITLE ${LANG_ENGLISH} "Please locate the directory where Pidgin is installed"
LangString DIR_INNERTEXT ${LANG_ENGLISH} "Install in this Pidgin folder:"
-LangString FINISH_TITLE ${LANG_ENGLISH} "Guifications v${GUIFICATIONS_VERSION} Install Complete"
-LangString FINISH_TEXT ${LANG_ENGLISH} "You will need to restart Pidgin for the plugin to be loaded, then go the Pidgin preferences and enable the Guifications Plugin."
+LangString FINISH_TITLE ${LANG_ENGLISH} "PBar v${PBAR_VERSION} Install Complete"
+LangString FINISH_TEXT ${LANG_ENGLISH} "You will need to restart Pidgin for the plugin to be loaded, then go the Pidgin preferences and enable the PBar Plugin."
; during install uninstaller
-LangString GUIFICATIONS_PROMPT_WIPEOUT ${LANG_ENGLISH} "The guifications.dll plugin is about to be deleted from your Pidgin/plugins directory. Continue?"
+LangString PBAR_PROMPT_WIPEOUT ${LANG_ENGLISH} "The pbar.dll plugin is about to be deleted from your Pidgin/plugins directory. Continue?"
; for windows uninstall
-LangString GUIFICATIONS_UNINSTALL_DESC ${LANG_ENGLISH} "Guifications Plugin (remove only)"
-LangString un.GUIFICATIONS_UNINSTALL_ERROR_1 ${LANG_ENGLISH} "The uninstaller could not find registry entries for Guifications.$\rIt is likely that another user installed the plugin."
-LangString un.GUIFICATIONS_UNINSTALL_ERROR_2 ${LANG_ENGLISH} "You do not have the permissions necessary to uninstall the plugin."
+LangString PBAR_UNINSTALL_DESC ${LANG_ENGLISH} "PBar Plugin (remove only)"
+LangString un.PBAR_UNINSTALL_ERROR_1 ${LANG_ENGLISH} "The uninstaller could not find registry entries for PBar.$\rIt is likely that another user installed the plugin."
+LangString un.PBAR_UNINSTALL_ERROR_2 ${LANG_ENGLISH} "You do not have the permissions necessary to uninstall the plugin."
diff --git a/nsis/french.nsh b/nsis/french.nsh
index 699aa5c..b84d3c9 100644
--- a/nsis/french.nsh
+++ b/nsis/french.nsh
@@ -1,39 +1,41 @@
;;
-;; english.nsh
+;; french.nsh
;;
-;; Default language strings for the Windows guifications NSIS installer.
+;; French language strings for the Windows PBar NSIS installer.
;; Windows Code page: 1252
-;; Language Code: 1033
+;; Language Code: 1036
+;; Derived from the French translation for the Windows guificiations NSIS installer by Yannick LE NY
+;;
;;
; Startup Pidgin check
-LangString PIDGIN_NEEDED ${LANG_ENGLISH} "Guifications requires that Pidgin be installed. You must install Pidgin before installing Guifications."
+LangString PIDGIN_NEEDED ${LANG_FRENCH} "PBar requiert que Pidgin soit installé. Vous devez installer Pidgin avant de faire l'installation de PBar."
-LangString GUIFICATIONS_TITLE ${LANG_ENGLISH} "Guifications plugin for Pidgin"
+LangString PBAR_TITLE ${LANG_FRENCH} "Plugin PBar pour Pidgin"
-LangString BAD_PIDGIN_VERSION_1 ${LANG_ENGLISH} "Incompatible version.$\r$\n$\r$\nThis version of the Guifications plugin was built for Pidgin version ${PIDGIN_VERSION}. It appears that you have Pidgin version"
+LangString BAD_PIDGIN_VERSION_1 ${LANG_FRENCH} "Version incompatible.$\r$\n$\r$\nCette version du plugin PBar a été créé pour la version ${PIDGIN_VERSION} de Pidgin. Il apparait que vous avez la version"
-LangString BAD_PIDGIN_VERSION_2 ${LANG_ENGLISH} "installed.$\r$\n$\r$\nSee http://guifications.sourceforge.net for more information."
+LangString BAD_PIDGIN_VERSION_2 ${LANG_FRENCH} "installée de Pidgin. $\r$\n$\r$\nRegardez à http://guifications.sourceforge.net pour plus d'informations."
-LangString NO_PIDGIN_VERSION ${LANG_ENGLISH} "Unable to determine installed Pidgin version."
+LangString NO_PIDGIN_VERSION ${LANG_FRENCH} "Impossible de déterminer la version installée de Pidgin."
; Overrides for default text in windows:
-LangString WELCOME_TITLE ${LANG_ENGLISH} "Guifications v${GUIFICATIONS_VERSION} Installer"
-LangString WELCOME_TEXT ${LANG_ENGLISH} "Note: This version of the plugin is designed for Pidgin ${PIDGIN_VERSION}, and will not install or function with versions of Pidgin having a different major version number.\r\n\r\nWhen you upgrade your version of Pidgin, you must uninstall or upgrade this plugin as well.\r\n\r\n"
+LangString WELCOME_TITLE ${LANG_FRENCH} "Installeur de PBar v${PBAR_VERSION}"
+LangString WELCOME_TEXT ${LANG_FRENCH} "Note: Cette version du plugin est conçu pour Pidgin ${PIDGIN_VERSION}, et ne s'installera pas ou ne fonctionnera pas avec les versions de Pidgin ayant un numéro de version majeur différent.\r\n\r\nQuand vous mettez à jour votre version de Pidgin, vous devez désinstaller ou mettre à jour ce plugin aussi.\r\n\r\n"
-LangString DIR_SUBTITLE ${LANG_ENGLISH} "Please locate the directory where Pidgin is installed"
-LangString DIR_INNERTEXT ${LANG_ENGLISH} "Install in this Pidgin folder:"
+LangString DIR_SUBTITLE ${LANG_FRENCH} "Merci d'indiquer le répertoire où Pidgin est installé"
+LangString DIR_INNERTEXT ${LANG_FRENCH} "Installation dans le répertoire Pidgin:"
-LangString FINISH_TITLE ${LANG_ENGLISH} "Guifications v${GUIFICATIONS_VERSION} Install Complete"
-LangString FINISH_TEXT ${LANG_ENGLISH} "You will need to restart Pidgin for the plugin to be loaded, then go the Pidgin preferences and enable the Guifications Plugin."
+LangString FINISH_TITLE ${LANG_FRENCH} "Installation terminée de PBar v${PBAR_VERSION}"
+LangString FINISH_TEXT ${LANG_FRENCH} "Vous avez besoin de redémarrer Pidgin pour que le plugin soit chargé, ensuite allez dans les préférences de Pidgin et activez le plugin PBar."
; during install uninstaller
-LangString GUIFICATIONS_PROMPT_WIPEOUT ${LANG_ENGLISH} "The guifications.dll plugin is about to be deleted from your Pidgin/plugins directory. Continue?"
+LangString PBAR_PROMPT_WIPEOUT ${LANG_FRENCH} "La librairie guifications.dll du plugin sera supprimé de votre répertoire Pidgin/plugins. Continuer ?"
; for windows uninstall
-LangString GUIFICATIONS_UNINSTALL_DESC ${LANG_ENGLISH} "Guifications Plugin (remove only)"
-LangString un.GUIFICATIONS_UNINSTALL_ERROR_1 ${LANG_ENGLISH} "The uninstaller could not find registry entries for Guifications.$\rIt is likely that another user installed the plugin."
-LangString un.GUIFICATIONS_UNINSTALL_ERROR_2 ${LANG_ENGLISH} "You do not have the permissions necessary to uninstall the plugin."
+LangString PBAR_UNINSTALL_DESC ${LANG_FRENCH} "Plugin PBar (supprimer uniquement)"
+LangString un.PBAR_UNINSTALL_ERROR_1 ${LANG_FRENCH} "Le désinstalleur ne peut pas trouver les entrées de registre pour Guifications.$\rIl se peut qu'un autre utilisateur a installé le plugin."
+LangString un.PBAR_UNINSTALL_ERROR_2 ${LANG_FRENCH} "Vous n'avez pas les permissions nécessaires pour désinstaller le plugin."
diff --git a/nsis/german.nsh b/nsis/german.nsh
index 699aa5c..cf83c68 100644
--- a/nsis/german.nsh
+++ b/nsis/german.nsh
@@ -1,39 +1,39 @@
;;
;; english.nsh
;;
-;; Default language strings for the Windows guifications NSIS installer.
+;; Default language strings for the Windows PBar NSIS installer.
;; Windows Code page: 1252
;; Language Code: 1033
;;
; Startup Pidgin check
-LangString PIDGIN_NEEDED ${LANG_ENGLISH} "Guifications requires that Pidgin be installed. You must install Pidgin before installing Guifications."
+LangString PIDGIN_NEEDED ${LANG_ENGLISH} "PBar requires that Pidgin be installed. You must install Pidgin before installing PBar."
-LangString GUIFICATIONS_TITLE ${LANG_ENGLISH} "Guifications plugin for Pidgin"
+LangString PBAR_TITLE ${LANG_ENGLISH} "PBar plugin for Pidgin"
-LangString BAD_PIDGIN_VERSION_1 ${LANG_ENGLISH} "Incompatible version.$\r$\n$\r$\nThis version of the Guifications plugin was built for Pidgin version ${PIDGIN_VERSION}. It appears that you have Pidgin version"
+LangString BAD_PIDGIN_VERSION_1 ${LANG_ENGLISH} "Incompatible version.$\r$\n$\r$\nThis version of the PBar plugin was built for Pidgin version ${PIDGIN_VERSION}. It appears that you have Pidgin version"
-LangString BAD_PIDGIN_VERSION_2 ${LANG_ENGLISH} "installed.$\r$\n$\r$\nSee http://guifications.sourceforge.net for more information."
+LangString BAD_PIDGIN_VERSION_2 ${LANG_ENGLISH} "installed.$\r$\n$\r$\nSee http://www.hauweele.net/~gawen/pidgin-pbar.html for more information."
LangString NO_PIDGIN_VERSION ${LANG_ENGLISH} "Unable to determine installed Pidgin version."
; Overrides for default text in windows:
-LangString WELCOME_TITLE ${LANG_ENGLISH} "Guifications v${GUIFICATIONS_VERSION} Installer"
+LangString WELCOME_TITLE ${LANG_ENGLISH} "PBar v${PBAR_VERSION} Installer"
LangString WELCOME_TEXT ${LANG_ENGLISH} "Note: This version of the plugin is designed for Pidgin ${PIDGIN_VERSION}, and will not install or function with versions of Pidgin having a different major version number.\r\n\r\nWhen you upgrade your version of Pidgin, you must uninstall or upgrade this plugin as well.\r\n\r\n"
LangString DIR_SUBTITLE ${LANG_ENGLISH} "Please locate the directory where Pidgin is installed"
LangString DIR_INNERTEXT ${LANG_ENGLISH} "Install in this Pidgin folder:"
-LangString FINISH_TITLE ${LANG_ENGLISH} "Guifications v${GUIFICATIONS_VERSION} Install Complete"
-LangString FINISH_TEXT ${LANG_ENGLISH} "You will need to restart Pidgin for the plugin to be loaded, then go the Pidgin preferences and enable the Guifications Plugin."
+LangString FINISH_TITLE ${LANG_ENGLISH} "PBar v${PBAR_VERSION} Install Complete"
+LangString FINISH_TEXT ${LANG_ENGLISH} "You will need to restart Pidgin for the plugin to be loaded, then go the Pidgin preferences and enable the PBar Plugin."
; during install uninstaller
-LangString GUIFICATIONS_PROMPT_WIPEOUT ${LANG_ENGLISH} "The guifications.dll plugin is about to be deleted from your Pidgin/plugins directory. Continue?"
+LangString PBAR_PROMPT_WIPEOUT ${LANG_ENGLISH} "The pbar.dll plugin is about to be deleted from your Pidgin/plugins directory. Continue?"
; for windows uninstall
-LangString GUIFICATIONS_UNINSTALL_DESC ${LANG_ENGLISH} "Guifications Plugin (remove only)"
-LangString un.GUIFICATIONS_UNINSTALL_ERROR_1 ${LANG_ENGLISH} "The uninstaller could not find registry entries for Guifications.$\rIt is likely that another user installed the plugin."
-LangString un.GUIFICATIONS_UNINSTALL_ERROR_2 ${LANG_ENGLISH} "You do not have the permissions necessary to uninstall the plugin."
+LangString PBAR_UNINSTALL_DESC ${LANG_ENGLISH} "PBar Plugin (remove only)"
+LangString un.PBAR_UNINSTALL_ERROR_1 ${LANG_ENGLISH} "The uninstaller could not find registry entries for PBar.$\rIt is likely that another user installed the plugin."
+LangString un.PBAR_UNINSTALL_ERROR_2 ${LANG_ENGLISH} "You do not have the permissions necessary to uninstall the plugin."
diff --git a/nsis/header.bmp b/nsis/header.bmp
index 64df125..77a2da3 100644
Binary files a/nsis/header.bmp and b/nsis/header.bmp differ
diff --git a/nsis/install.ico b/nsis/install.ico
index cc156e3..e9ae3b6 100644
Binary files a/nsis/install.ico and b/nsis/install.ico differ
|
gawen947/pidgin-pbar
|
686dabdc82ae3618b547997a54e30c87580f4539
|
Fix Windows makefile
|
diff --git a/installer.nsi b/installer.nsi
index c3714d1..4424baa 100644
--- a/installer.nsi
+++ b/installer.nsi
@@ -1,407 +1,407 @@
; NSIS Script For PBar Plugin
; Author David Hauweele
; Based on the Guifications Plugin installer by Daniel A. Atallah
; Uses NSIS v2.0
;--------------------------------
;Include Modern UI
!include "MUI.nsh"
!include "FileFunc.nsh"
!insertmacro GetParameters
!insertmacro GetOptions
;--------------------------------
;General
Name "Pidgin PBar ${PBAR_VERSION}"
;Do A CRC Check
CRCCheck On
;Output File Name
OutFile "Pidgin-PBar_${PBAR_VERSION}.exe"
;The Default Installation Directory
InstallDir "$PROGRAMFILES\pidgin"
InstallDirRegKey HKLM SOFTWARE\pidgin ""
ShowInstDetails show
ShowUnInstDetails show
SetCompressor /SOLID lzma
;Reserve files used in .onInit for faster start-up
!insertmacro MUI_RESERVEFILE_LANGDLL
!define PBAR_UNINST_EXE "Pidgin-PBar-uninst.exe"
!define PBAR_DLL "pbar.dll"
!define PBAR_UNINSTALL_LNK "PBar Uninstall.lnk"
;--------------------------------
; Registry keys:
!define PBAR_REG_KEY "SOFTWARE\pidgin-pbar"
!define PBAR_UNINSTALL_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\pidgin-pbar"
;-------------------------------
; Pidgin Plugin installer helper stuff
!addincludedir "${PIDGIN_TREE_TOP}\pidgin\win32\nsis"
!include "pidgin-plugin.nsh"
;--------------------------------
; Modern UI Configuration
!define MUI_ICON .\nsis\install.ico
!define MUI_UNICON .\nsis\install.ico
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "nsis\header.bmp"
!define MUI_CUSTOMFUNCTION_GUIINIT pbar_checkPidginVersion
!define MUI_ABORTWARNING
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY ${PBAR_REG_KEY}
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
;--------------------------------
; Pages
;Welcome Page
!define MUI_WELCOMEPAGE_TITLE $(WELCOME_TITLE)
!define MUI_WELCOMEPAGE_TEXT $(WELCOME_TEXT)
!insertmacro MUI_PAGE_WELCOME
;License Page
!define MUI_LICENSEPAGE_RADIOBUTTONS
!insertmacro MUI_PAGE_LICENSE ".\COPYING"
;Directory Page
!define MUI_DIRECTORYPAGE_TEXT_TOP $(DIR_SUBTITLE)
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION $(DIR_INNERTEXT)
!insertmacro MUI_PAGE_DIRECTORY
;Installation Page
!insertmacro MUI_PAGE_INSTFILES
;Finish Page
!define MUI_FINISHPAGE_TITLE $(FINISH_TITLE)
!define MUI_FINISHPAGE_TEXT $(FINISH_TEXT)
!insertmacro MUI_PAGE_FINISH
;--------------------------------
; Languages
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "Dutch"
!insertmacro MUI_LANGUAGE "German"
;Translations
!include "nsis\english.nsh"
!include "nsis\french.nsh"
!include "nsis\dutch.nsh"
!include "nsis\german.nsh"
; Uninstall the previous version if it exists
Section -SecUninstallOldPlugin
; Check install rights..
Call CheckUserInstallRights
Pop $R0
StrCmp $R0 "HKLM" rights_hklm
StrCmp $R0 "HKCU" rights_hkcu done
rights_hkcu:
ReadRegStr $R1 HKCU "${PBAR_REG_KEY}" ""
ReadRegStr $R2 HKCU "${PBAR_REG_KEY}" "Version"
ReadRegStr $R3 HKCU "${PBAR_UNINSTALL_KEY}" "UninstallString"
Goto try_uninstall
rights_hklm:
ReadRegStr $R1 HKLM "${PBAR_REG_KEY}" ""
ReadRegStr $R2 HKLM "${PBAR_REG_KEY}" "Version"
ReadRegStr $R3 HKLM "${PBAR_UNINSTALL_KEY}" "UninstallString"
; If previous version exists .. remove
try_uninstall:
StrCmp $R1 "" done
StrCmp $R2 "" uninstall_problem
IfFileExists $R3 0 uninstall_problem
; Have uninstall string.. go ahead and uninstall.
SetOverwrite on
; Need to copy uninstaller outside of the install dir
ClearErrors
CopyFiles /SILENT $R3 "$TEMP\${PBAR_UNINST_EXE}"
SetOverwrite off
IfErrors uninstall_problem
; Ready to uninstall..
ClearErrors
ExecWait '"$TEMP\${PBAR_UNINST_EXE}" /S _?=$R1'
IfErrors exec_error
Delete "$TEMP\${PBAR_UNINST_EXE}"
Goto done
exec_error:
Delete "$TEMP\${PBAR_UNINST_EXE}"
Goto uninstall_problem
uninstall_problem:
; Just delete the plugin and uninstaller, and remove Registry key
MessageBox MB_YESNO $(PBAR_PROMPT_WIPEOUT) IDYES do_wipeout IDNO cancel_install
cancel_install:
Quit
do_wipeout:
StrCmp $R0 "HKLM" del_lm_reg del_cu_reg
del_cu_reg:
DeleteRegKey HKCU ${PBAR_REG_KEY}
Goto uninstall_prob_cont
del_lm_reg:
DeleteRegKey HKLM ${PBAR_REG_KEY}
uninstall_prob_cont:
; plugin DLL
Delete "$R1\plugins\${PBAR_DLL}"
Delete "$R3"
done:
SectionEnd
-!macro INSTALL_GMO LANG
+!macro INSTALL_MO LANG
SetOutPath "$INSTDIR\locale\${LANG}\LC_MESSAGES"
- File /oname=pbar.mo po\${LANG}.gmo
+ File /oname=pbar.mo ${LANG}.mo
!macroend
Section "Install"
Call CheckUserInstallRights
Pop $R0
StrCmp $R0 "NONE" instrights_none
StrCmp $R0 "HKLM" instrights_hklm instrights_hkcu
instrights_hklm:
; Write the version registry keys:
WriteRegStr HKLM ${PBAR_REG_KEY} "" "$INSTDIR"
WriteRegStr HKLM ${PBAR_REG_KEY} "Version" "${PBAR_VERSION}"
; Write the uninstall keys for Windows
WriteRegStr HKLM ${PBAR_UNINSTALL_KEY} "DisplayName" "$(PBAR_UNINSTALL_DESC)"
WriteRegStr HKLM ${PBAR_UNINSTALL_KEY} "UninstallString" "$INSTDIR\${PBAR_UNINST_EXE}"
SetShellVarContext "all"
Goto install_files
instrights_hkcu:
; Write the version registry keys:
WriteRegStr HKCU ${PBAR_REG_KEY} "" "$INSTDIR"
WriteRegStr HKCU ${PBAR_REG_KEY} "Version" "${PBAR_VERSION}"
; Write the uninstall keys for Windows
WriteRegStr HKCU ${PBAR_UNINSTALL_KEY} "DisplayName" "$(PBAR_UNINSTALL_DESC)"
WriteRegStr HKCU ${PBAR_UNINSTALL_KEY} "UninstallString" "$INSTDIR\${PBAR_UNINST_EXE}"
Goto install_files
instrights_none:
; No registry keys for us...
install_files:
SetOutPath "$INSTDIR\plugins"
SetCompress Auto
SetOverwrite on
- File "src\${PBAR_DLL}"
+ File "${PBAR_DLL}"
; translations - if there is a way to automate this, i can't find it
- !insertmacro INSTALL_GMO "de"
- !insertmacro INSTALL_GMO "fr"
- !insertmacro INSTALL_GMO "nl"
+ !insertmacro INSTALL_MO "de"
+ !insertmacro INSTALL_MO "fr"
+ !insertmacro INSTALL_MO "nl"
StrCmp $R0 "NONE" done
CreateShortCut "$SMPROGRAMS\Pidgin\${PBAR_UNINSTALL_LNK}" "$INSTDIR\${PBAR_UNINST_EXE}"
WriteUninstaller "$INSTDIR\${PBAR_UNINST_EXE}"
SetOverWrite off
done:
SectionEnd
Section Uninstall
Call un.CheckUserInstallRights
Pop $R0
StrCmp $R0 "NONE" no_rights
StrCmp $R0 "HKCU" try_hkcu try_hklm
try_hkcu:
ReadRegStr $R0 HKCU "${PBAR_REG_KEY}" ""
StrCmp $R0 $INSTDIR 0 cant_uninstall
; HKCU install path matches our INSTDIR.. so uninstall
DeleteRegKey HKCU "${PBAR_REG_KEY}"
DeleteRegKey HKCU "${PBAR_UNINSTALL_KEY}"
Goto cont_uninstall
try_hklm:
ReadRegStr $R0 HKLM "${PBAR_REG_KEY}" ""
StrCmp $R0 $INSTDIR 0 try_hkcu
; HKLM install path matches our INSTDIR.. so uninstall
DeleteRegKey HKLM "${PBAR_REG_KEY}"
DeleteRegKey HKLM "${PBAR_UNINSTALL_KEY}"
; Sets start menu and desktop scope to all users..
SetShellVarContext "all"
cont_uninstall:
; plugin
Delete "$INSTDIR\plugins\${PBAR_DLL}"
; translations
; loop through locale dirs and try to delete any PBar translations
ClearErrors
FindFirst $R1 $R2 "$INSTDIR\locale\*"
IfErrors doneFindingTranslations
processCurrentTranslationDir:
;Ignore "." and ".."
StrCmp $R2 "." readNextTranslationDir
StrCmp $R2 ".." readNextTranslationDir
IfFileExists "$INSTDIR\locale\$R2\LC_MESSAGES\pbar.mo" +1 readNextTranslationDir
Delete "$INSTDIR\locale\$R2\LC_MESSAGES\pbar.mo"
RMDir "$INSTDIR\locale\$R2\LC_MESSAGES"
RMDir "$INSTDIR\locale\$R2"
ClearErrors
readNextTranslationDir:
FindNext $R1 $R2
IfErrors doneFindingTranslations processCurrentTranslationDir
doneFindingTranslations:
FindClose $R1
RMDir "$INSTDIR\locale"
; uninstaller
Delete "$INSTDIR\${PBAR_UNINST_EXE}"
; uninstaller shortcut
Delete "$SMPROGRAMS\Pidgin\${PBAR_UNINSTALL_LNK}"
; try to delete the Pidgin directories, in case it has already uninstalled
RMDir "$INSTDIR\plugins"
RMDir "$INSTDIR"
RMDir "$SMPROGRAMS\Pidgin"
Goto done
cant_uninstall:
MessageBox MB_OK $(un.PBAR_UNINSTALL_ERROR_1) IDOK
Quit
no_rights:
MessageBox MB_OK $(un.PBAR_UNINSTALL_ERROR_2) IDOK
Quit
done:
SectionEnd
Function .onInit
${GetParameters} $R0
ClearErrors
${GetOptions} $R0 "/L=" $R0
IfErrors +3
StrCpy $LANGUAGE $R0
Goto skip_lang
; Select Language
; Display Language selection dialog
!insertmacro MUI_LANGDLL_DISPLAY
skip_lang:
FunctionEnd
Function un.onInit
; Get stored language preference
!insertmacro MUI_UNGETLANGUAGE
FunctionEnd
; Check that the selected installation dir contains pidgin.exe
Function .onVerifyInstDir
IfFileExists $INSTDIR\pidgin.exe +2
Abort
FunctionEnd
; Check that the currently installed pidgin version is compatible with the version of PBar we are installing
Function pbar_checkPidginVersion
Push $R0
Push ${PIDGIN_VERSION}
Call CheckPidginVersion
Pop $R0
StrCmp $R0 ${PIDGIN_VERSION_OK} pbar_checkPidginVersion_OK
StrCmp $R0 ${PIDGIN_VERSION_INCOMPATIBLE} +1 +6
Call GetPidginVersion
IfErrors +3
Pop $R0
MessageBox MB_OK|MB_ICONSTOP "$(BAD_PIDGIN_VERSION_1) $R0 $(BAD_PIDGIN_VERSION_2)"
goto +2
MessageBox MB_OK|MB_ICONSTOP "$(NO_PIDGIN_VERSION)"
Quit
pbar_checkPidginVersion_OK:
Pop $R0
FunctionEnd
Function CheckUserInstallRights
ClearErrors
UserInfo::GetName
IfErrors Win9x
Pop $0
UserInfo::GetAccountType
Pop $1
StrCmp $1 "Admin" 0 +3
StrCpy $1 "HKLM"
Goto done
StrCmp $1 "Power" 0 +3
StrCpy $1 "HKLM"
Goto done
StrCmp $1 "User" 0 +3
StrCpy $1 "HKCU"
Goto done
StrCmp $1 "Guest" 0 +3
StrCpy $1 "NONE"
Goto done
; Unknown error
StrCpy $1 "NONE"
Goto done
Win9x:
StrCpy $1 "HKLM"
done:
Push $1
FunctionEnd
; This is necessary because the uninstaller doesn't have access to installer functions
; (it is identical to CheckUserInstallRights)
Function un.CheckUserInstallRights
ClearErrors
UserInfo::GetName
IfErrors Win9x
Pop $0
UserInfo::GetAccountType
Pop $1
StrCmp $1 "Admin" 0 +3
StrCpy $1 "HKLM"
Goto done
StrCmp $1 "Power" 0 +3
StrCpy $1 "HKLM"
Goto done
StrCmp $1 "User" 0 +3
StrCpy $1 "HKCU"
Goto done
StrCmp $1 "Guest" 0 +3
StrCpy $1 "NONE"
Goto done
; Unknown error
StrCpy $1 "NONE"
Goto done
Win9x:
StrCpy $1 "HKLM"
done:
Push $1
FunctionEnd
diff --git a/makefile.mingw b/makefile.mingw
index 96e1042..fc19e1b 100644
--- a/makefile.mingw
+++ b/makefile.mingw
@@ -1,110 +1,111 @@
#
# Makefile.mingw
#
# Description: Makefile for Pidgin PBar.
# Taken from the privacy please plugin.
#
include commands.mk
PIDGIN_TREE_TOP := ../../..
include $(PIDGIN_TREE_TOP)/libpurple/win32/global.mak
VERSION = $(shell cat VERSION)
TARGET = pbar
DEFINES += -DGETTEXT_PACKAGE=\"pbar\"
-DEFINES += -DPACKAGE_VERSION=\"$(VERSION)\"
+DEFINES += -DVERSION=\"$(VERSION)\"
+DEFINES += -DDATADIR=\"$(PIDGIN_INSTALL_DIR)\"
INCLUDE_PATHS += -I. \
-I$(GTK_TOP)/include \
-I$(GTK_TOP)/include/gtk-2.0 \
-I$(GTK_TOP)/include/glib-2.0 \
-I$(GTK_TOP)/include/pango-1.0 \
-I$(GTK_TOP)/include/atk-1.0 \
-I$(GTK_TOP)/include/cairo \
-I$(GTK_TOP)/lib/glib-2.0/include \
-I$(GTK_TOP)/lib/gtk-2.0/include \
-I$(PURPLE_TOP) \
-I$(PURPLE_TOP)/win32 \
-I$(PIDGIN_TOP) \
-I$(PIDGIN_TOP)/win32 \
-I$(PIDGIN_TREE_TOP)
LIB_PATHS += -L$(GTK_TOP)/lib \
-L$(PURPLE_TOP) \
-L$(PIDGIN_TOP)
C_SRC = $(wildcard *.c)
OBJECTS = $(C_SRC:%.c=%.o)
LIBS = -lgtk-win32-2.0 \
-lglib-2.0 \
-lgdk-win32-2.0 \
-lgdk_pixbuf-2.0 \
-lgobject-2.0 \
-lintl \
-lpurple \
-lpidgin
ifndef DISABLE_DEBUG
CFLAGS += -ggdb
endif
commit = $(shell ./hash.sh)
ifneq ($(commit), UNKNOWN)
DEFINES += -DCOMMIT="\"$(commit)\""
endif
POFILES = $(wildcard *.po)
CATALOGS = $(foreach cat, $(POFILES:.po=.mo), $(notdir $(cat)))
ifndef DISABLE_NLS
-DEFINES += -DENABLE_NLS=1 -DLOCALEDIR="\"$(LOCALEDIR)\""
+DEFINES += -DENABLE_NLS=1
locales := locales
install-locales := install-locales
uninstall-locales := uninstall-locales
endif
include $(PIDGIN_COMMON_RULES)
.PHONY: all install clean
all: $(TARGET).dll $(locales)
install: $(PIDGIN_INSTALL_PLUGINS_DIR) all
cp $(TARGET).dll $(PIDGIN_INSTALL_PLUGINS_DIR)
$(OBJECTS): $(PIDGIN_CONFIG_H)
$(TARGET).dll: $(PURPLE_DLL).a $(PIDGIN_DLL).a $(OBJECTS)
$(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -o $(TARGET).dll
clean:
rm -rf $(OBJECTS)
rm -rf $(TARGET).dll
locales: $(CATALOGS)
CAT_INST_PATH = $(foreach lang, $(POFILES:.po=), $(LOCALEDIR)/$(lang)/LC_MESSAGES/pidgin-pbar.mo)
install-locales: $(CAT_INST_PATH)
$(LOCALEDIR)/%/LC_MESSAGES/pidgin-pbar.mo: %.mo
$(MKDIR) -p $(LOCALEDIR)/$(basename $<)/LC_MESSAGES
$(INSTALL_DATA) $< $@
uninstall-locales:
$(RM) $(CAT_INST_PATH)
%.mo: %.po
$(MSGFMT) -c -o $@ $<
messages.pot: POTFILES.in
$(XGETTEXT) --no-wrap -m -c --files-from $< --keyword --keyword=_ --keyword=N_ -o $@
installer: all
- $(MAKENSIS) -DPBAR_VERSION="$(PBAR_VERSION)" -DPIDGIN_VERSION="$(PIDGIN_VERSION)" -DPIDGIN_TREE_TOP="$(PIDGIN_TREE_TOP)" installer.nsi
+ $(MAKENSIS) -DPBAR_VERSION="$(VERSION)" -DPIDGIN_VERSION="$(PIDGIN_VERSION)" -DPIDGIN_TREE_TOP="$(PIDGIN_TREE_TOP)" installer.nsi
include $(PIDGIN_COMMON_TARGETS)
|
gawen947/pidgin-pbar
|
b34659da5323fd79ce28872bb929c4893ac2cc24
|
Fix installer translation
|
diff --git a/installer.nsi b/installer.nsi
index 7430a3b..c3714d1 100644
--- a/installer.nsi
+++ b/installer.nsi
@@ -1,407 +1,407 @@
; NSIS Script For PBar Plugin
; Author David Hauweele
; Based on the Guifications Plugin installer by Daniel A. Atallah
; Uses NSIS v2.0
;--------------------------------
;Include Modern UI
!include "MUI.nsh"
!include "FileFunc.nsh"
!insertmacro GetParameters
!insertmacro GetOptions
;--------------------------------
;General
Name "Pidgin PBar ${PBAR_VERSION}"
;Do A CRC Check
CRCCheck On
;Output File Name
OutFile "Pidgin-PBar_${PBAR_VERSION}.exe"
;The Default Installation Directory
InstallDir "$PROGRAMFILES\pidgin"
InstallDirRegKey HKLM SOFTWARE\pidgin ""
ShowInstDetails show
ShowUnInstDetails show
SetCompressor /SOLID lzma
;Reserve files used in .onInit for faster start-up
!insertmacro MUI_RESERVEFILE_LANGDLL
!define PBAR_UNINST_EXE "Pidgin-PBar-uninst.exe"
!define PBAR_DLL "pbar.dll"
!define PBAR_UNINSTALL_LNK "PBar Uninstall.lnk"
;--------------------------------
; Registry keys:
!define PBAR_REG_KEY "SOFTWARE\pidgin-pbar"
!define PBAR_UNINSTALL_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\pidgin-pbar"
;-------------------------------
; Pidgin Plugin installer helper stuff
!addincludedir "${PIDGIN_TREE_TOP}\pidgin\win32\nsis"
!include "pidgin-plugin.nsh"
;--------------------------------
; Modern UI Configuration
!define MUI_ICON .\nsis\install.ico
!define MUI_UNICON .\nsis\install.ico
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "nsis\header.bmp"
!define MUI_CUSTOMFUNCTION_GUIINIT pbar_checkPidginVersion
!define MUI_ABORTWARNING
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY ${PBAR_REG_KEY}
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
;--------------------------------
; Pages
;Welcome Page
!define MUI_WELCOMEPAGE_TITLE $(WELCOME_TITLE)
!define MUI_WELCOMEPAGE_TEXT $(WELCOME_TEXT)
!insertmacro MUI_PAGE_WELCOME
;License Page
!define MUI_LICENSEPAGE_RADIOBUTTONS
!insertmacro MUI_PAGE_LICENSE ".\COPYING"
;Directory Page
!define MUI_DIRECTORYPAGE_TEXT_TOP $(DIR_SUBTITLE)
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION $(DIR_INNERTEXT)
!insertmacro MUI_PAGE_DIRECTORY
;Installation Page
!insertmacro MUI_PAGE_INSTFILES
;Finish Page
!define MUI_FINISHPAGE_TITLE $(FINISH_TITLE)
!define MUI_FINISHPAGE_TEXT $(FINISH_TEXT)
!insertmacro MUI_PAGE_FINISH
;--------------------------------
; Languages
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "Dutch"
!insertmacro MUI_LANGUAGE "German"
;Translations
- !include "nsis\translations\english.nsh"
- !include "nsis\translations\french.nsh"
- !include "nsis\translations\dutch.nsh"
- !include "nsis\translations\german.nsh"
+ !include "nsis\english.nsh"
+ !include "nsis\french.nsh"
+ !include "nsis\dutch.nsh"
+ !include "nsis\german.nsh"
; Uninstall the previous version if it exists
Section -SecUninstallOldPlugin
; Check install rights..
Call CheckUserInstallRights
Pop $R0
StrCmp $R0 "HKLM" rights_hklm
StrCmp $R0 "HKCU" rights_hkcu done
rights_hkcu:
ReadRegStr $R1 HKCU "${PBAR_REG_KEY}" ""
ReadRegStr $R2 HKCU "${PBAR_REG_KEY}" "Version"
ReadRegStr $R3 HKCU "${PBAR_UNINSTALL_KEY}" "UninstallString"
Goto try_uninstall
rights_hklm:
ReadRegStr $R1 HKLM "${PBAR_REG_KEY}" ""
ReadRegStr $R2 HKLM "${PBAR_REG_KEY}" "Version"
ReadRegStr $R3 HKLM "${PBAR_UNINSTALL_KEY}" "UninstallString"
; If previous version exists .. remove
try_uninstall:
StrCmp $R1 "" done
StrCmp $R2 "" uninstall_problem
IfFileExists $R3 0 uninstall_problem
; Have uninstall string.. go ahead and uninstall.
SetOverwrite on
; Need to copy uninstaller outside of the install dir
ClearErrors
CopyFiles /SILENT $R3 "$TEMP\${PBAR_UNINST_EXE}"
SetOverwrite off
IfErrors uninstall_problem
; Ready to uninstall..
ClearErrors
ExecWait '"$TEMP\${PBAR_UNINST_EXE}" /S _?=$R1'
IfErrors exec_error
Delete "$TEMP\${PBAR_UNINST_EXE}"
Goto done
exec_error:
Delete "$TEMP\${PBAR_UNINST_EXE}"
Goto uninstall_problem
uninstall_problem:
; Just delete the plugin and uninstaller, and remove Registry key
MessageBox MB_YESNO $(PBAR_PROMPT_WIPEOUT) IDYES do_wipeout IDNO cancel_install
cancel_install:
Quit
do_wipeout:
StrCmp $R0 "HKLM" del_lm_reg del_cu_reg
del_cu_reg:
DeleteRegKey HKCU ${PBAR_REG_KEY}
Goto uninstall_prob_cont
del_lm_reg:
DeleteRegKey HKLM ${PBAR_REG_KEY}
uninstall_prob_cont:
; plugin DLL
Delete "$R1\plugins\${PBAR_DLL}"
Delete "$R3"
done:
SectionEnd
!macro INSTALL_GMO LANG
SetOutPath "$INSTDIR\locale\${LANG}\LC_MESSAGES"
File /oname=pbar.mo po\${LANG}.gmo
!macroend
Section "Install"
Call CheckUserInstallRights
Pop $R0
StrCmp $R0 "NONE" instrights_none
StrCmp $R0 "HKLM" instrights_hklm instrights_hkcu
instrights_hklm:
; Write the version registry keys:
WriteRegStr HKLM ${PBAR_REG_KEY} "" "$INSTDIR"
WriteRegStr HKLM ${PBAR_REG_KEY} "Version" "${PBAR_VERSION}"
; Write the uninstall keys for Windows
WriteRegStr HKLM ${PBAR_UNINSTALL_KEY} "DisplayName" "$(PBAR_UNINSTALL_DESC)"
WriteRegStr HKLM ${PBAR_UNINSTALL_KEY} "UninstallString" "$INSTDIR\${PBAR_UNINST_EXE}"
SetShellVarContext "all"
Goto install_files
instrights_hkcu:
; Write the version registry keys:
WriteRegStr HKCU ${PBAR_REG_KEY} "" "$INSTDIR"
WriteRegStr HKCU ${PBAR_REG_KEY} "Version" "${PBAR_VERSION}"
; Write the uninstall keys for Windows
WriteRegStr HKCU ${PBAR_UNINSTALL_KEY} "DisplayName" "$(PBAR_UNINSTALL_DESC)"
WriteRegStr HKCU ${PBAR_UNINSTALL_KEY} "UninstallString" "$INSTDIR\${PBAR_UNINST_EXE}"
Goto install_files
instrights_none:
; No registry keys for us...
install_files:
SetOutPath "$INSTDIR\plugins"
SetCompress Auto
SetOverwrite on
File "src\${PBAR_DLL}"
; translations - if there is a way to automate this, i can't find it
!insertmacro INSTALL_GMO "de"
!insertmacro INSTALL_GMO "fr"
!insertmacro INSTALL_GMO "nl"
StrCmp $R0 "NONE" done
CreateShortCut "$SMPROGRAMS\Pidgin\${PBAR_UNINSTALL_LNK}" "$INSTDIR\${PBAR_UNINST_EXE}"
WriteUninstaller "$INSTDIR\${PBAR_UNINST_EXE}"
SetOverWrite off
done:
SectionEnd
Section Uninstall
Call un.CheckUserInstallRights
Pop $R0
StrCmp $R0 "NONE" no_rights
StrCmp $R0 "HKCU" try_hkcu try_hklm
try_hkcu:
ReadRegStr $R0 HKCU "${PBAR_REG_KEY}" ""
StrCmp $R0 $INSTDIR 0 cant_uninstall
; HKCU install path matches our INSTDIR.. so uninstall
DeleteRegKey HKCU "${PBAR_REG_KEY}"
DeleteRegKey HKCU "${PBAR_UNINSTALL_KEY}"
Goto cont_uninstall
try_hklm:
ReadRegStr $R0 HKLM "${PBAR_REG_KEY}" ""
StrCmp $R0 $INSTDIR 0 try_hkcu
; HKLM install path matches our INSTDIR.. so uninstall
DeleteRegKey HKLM "${PBAR_REG_KEY}"
DeleteRegKey HKLM "${PBAR_UNINSTALL_KEY}"
; Sets start menu and desktop scope to all users..
SetShellVarContext "all"
cont_uninstall:
; plugin
Delete "$INSTDIR\plugins\${PBAR_DLL}"
; translations
; loop through locale dirs and try to delete any PBar translations
ClearErrors
FindFirst $R1 $R2 "$INSTDIR\locale\*"
IfErrors doneFindingTranslations
processCurrentTranslationDir:
;Ignore "." and ".."
StrCmp $R2 "." readNextTranslationDir
StrCmp $R2 ".." readNextTranslationDir
IfFileExists "$INSTDIR\locale\$R2\LC_MESSAGES\pbar.mo" +1 readNextTranslationDir
Delete "$INSTDIR\locale\$R2\LC_MESSAGES\pbar.mo"
RMDir "$INSTDIR\locale\$R2\LC_MESSAGES"
RMDir "$INSTDIR\locale\$R2"
ClearErrors
readNextTranslationDir:
FindNext $R1 $R2
IfErrors doneFindingTranslations processCurrentTranslationDir
doneFindingTranslations:
FindClose $R1
RMDir "$INSTDIR\locale"
; uninstaller
Delete "$INSTDIR\${PBAR_UNINST_EXE}"
; uninstaller shortcut
Delete "$SMPROGRAMS\Pidgin\${PBAR_UNINSTALL_LNK}"
; try to delete the Pidgin directories, in case it has already uninstalled
RMDir "$INSTDIR\plugins"
RMDir "$INSTDIR"
RMDir "$SMPROGRAMS\Pidgin"
Goto done
cant_uninstall:
MessageBox MB_OK $(un.PBAR_UNINSTALL_ERROR_1) IDOK
Quit
no_rights:
MessageBox MB_OK $(un.PBAR_UNINSTALL_ERROR_2) IDOK
Quit
done:
SectionEnd
Function .onInit
${GetParameters} $R0
ClearErrors
${GetOptions} $R0 "/L=" $R0
IfErrors +3
StrCpy $LANGUAGE $R0
Goto skip_lang
; Select Language
; Display Language selection dialog
!insertmacro MUI_LANGDLL_DISPLAY
skip_lang:
FunctionEnd
Function un.onInit
; Get stored language preference
!insertmacro MUI_UNGETLANGUAGE
FunctionEnd
; Check that the selected installation dir contains pidgin.exe
Function .onVerifyInstDir
IfFileExists $INSTDIR\pidgin.exe +2
Abort
FunctionEnd
; Check that the currently installed pidgin version is compatible with the version of PBar we are installing
Function pbar_checkPidginVersion
Push $R0
Push ${PIDGIN_VERSION}
Call CheckPidginVersion
Pop $R0
StrCmp $R0 ${PIDGIN_VERSION_OK} pbar_checkPidginVersion_OK
StrCmp $R0 ${PIDGIN_VERSION_INCOMPATIBLE} +1 +6
Call GetPidginVersion
IfErrors +3
Pop $R0
MessageBox MB_OK|MB_ICONSTOP "$(BAD_PIDGIN_VERSION_1) $R0 $(BAD_PIDGIN_VERSION_2)"
goto +2
MessageBox MB_OK|MB_ICONSTOP "$(NO_PIDGIN_VERSION)"
Quit
pbar_checkPidginVersion_OK:
Pop $R0
FunctionEnd
Function CheckUserInstallRights
ClearErrors
UserInfo::GetName
IfErrors Win9x
Pop $0
UserInfo::GetAccountType
Pop $1
StrCmp $1 "Admin" 0 +3
StrCpy $1 "HKLM"
Goto done
StrCmp $1 "Power" 0 +3
StrCpy $1 "HKLM"
Goto done
StrCmp $1 "User" 0 +3
StrCpy $1 "HKCU"
Goto done
StrCmp $1 "Guest" 0 +3
StrCpy $1 "NONE"
Goto done
; Unknown error
StrCpy $1 "NONE"
Goto done
Win9x:
StrCpy $1 "HKLM"
done:
Push $1
FunctionEnd
; This is necessary because the uninstaller doesn't have access to installer functions
; (it is identical to CheckUserInstallRights)
Function un.CheckUserInstallRights
ClearErrors
UserInfo::GetName
IfErrors Win9x
Pop $0
UserInfo::GetAccountType
Pop $1
StrCmp $1 "Admin" 0 +3
StrCpy $1 "HKLM"
Goto done
StrCmp $1 "Power" 0 +3
StrCpy $1 "HKLM"
Goto done
StrCmp $1 "User" 0 +3
StrCpy $1 "HKCU"
Goto done
StrCmp $1 "Guest" 0 +3
StrCpy $1 "NONE"
Goto done
; Unknown error
StrCpy $1 "NONE"
Goto done
Win9x:
StrCpy $1 "HKLM"
done:
Push $1
FunctionEnd
diff --git a/nsis/english.nsh b/nsis/english.nsh
index 699aa5c..cf83c68 100644
--- a/nsis/english.nsh
+++ b/nsis/english.nsh
@@ -1,39 +1,39 @@
;;
;; english.nsh
;;
-;; Default language strings for the Windows guifications NSIS installer.
+;; Default language strings for the Windows PBar NSIS installer.
;; Windows Code page: 1252
;; Language Code: 1033
;;
; Startup Pidgin check
-LangString PIDGIN_NEEDED ${LANG_ENGLISH} "Guifications requires that Pidgin be installed. You must install Pidgin before installing Guifications."
+LangString PIDGIN_NEEDED ${LANG_ENGLISH} "PBar requires that Pidgin be installed. You must install Pidgin before installing PBar."
-LangString GUIFICATIONS_TITLE ${LANG_ENGLISH} "Guifications plugin for Pidgin"
+LangString PBAR_TITLE ${LANG_ENGLISH} "PBar plugin for Pidgin"
-LangString BAD_PIDGIN_VERSION_1 ${LANG_ENGLISH} "Incompatible version.$\r$\n$\r$\nThis version of the Guifications plugin was built for Pidgin version ${PIDGIN_VERSION}. It appears that you have Pidgin version"
+LangString BAD_PIDGIN_VERSION_1 ${LANG_ENGLISH} "Incompatible version.$\r$\n$\r$\nThis version of the PBar plugin was built for Pidgin version ${PIDGIN_VERSION}. It appears that you have Pidgin version"
-LangString BAD_PIDGIN_VERSION_2 ${LANG_ENGLISH} "installed.$\r$\n$\r$\nSee http://guifications.sourceforge.net for more information."
+LangString BAD_PIDGIN_VERSION_2 ${LANG_ENGLISH} "installed.$\r$\n$\r$\nSee http://www.hauweele.net/~gawen/pidgin-pbar.html for more information."
LangString NO_PIDGIN_VERSION ${LANG_ENGLISH} "Unable to determine installed Pidgin version."
; Overrides for default text in windows:
-LangString WELCOME_TITLE ${LANG_ENGLISH} "Guifications v${GUIFICATIONS_VERSION} Installer"
+LangString WELCOME_TITLE ${LANG_ENGLISH} "PBar v${PBAR_VERSION} Installer"
LangString WELCOME_TEXT ${LANG_ENGLISH} "Note: This version of the plugin is designed for Pidgin ${PIDGIN_VERSION}, and will not install or function with versions of Pidgin having a different major version number.\r\n\r\nWhen you upgrade your version of Pidgin, you must uninstall or upgrade this plugin as well.\r\n\r\n"
LangString DIR_SUBTITLE ${LANG_ENGLISH} "Please locate the directory where Pidgin is installed"
LangString DIR_INNERTEXT ${LANG_ENGLISH} "Install in this Pidgin folder:"
-LangString FINISH_TITLE ${LANG_ENGLISH} "Guifications v${GUIFICATIONS_VERSION} Install Complete"
-LangString FINISH_TEXT ${LANG_ENGLISH} "You will need to restart Pidgin for the plugin to be loaded, then go the Pidgin preferences and enable the Guifications Plugin."
+LangString FINISH_TITLE ${LANG_ENGLISH} "PBar v${PBAR_VERSION} Install Complete"
+LangString FINISH_TEXT ${LANG_ENGLISH} "You will need to restart Pidgin for the plugin to be loaded, then go the Pidgin preferences and enable the PBar Plugin."
; during install uninstaller
-LangString GUIFICATIONS_PROMPT_WIPEOUT ${LANG_ENGLISH} "The guifications.dll plugin is about to be deleted from your Pidgin/plugins directory. Continue?"
+LangString PBAR_PROMPT_WIPEOUT ${LANG_ENGLISH} "The pbar.dll plugin is about to be deleted from your Pidgin/plugins directory. Continue?"
; for windows uninstall
-LangString GUIFICATIONS_UNINSTALL_DESC ${LANG_ENGLISH} "Guifications Plugin (remove only)"
-LangString un.GUIFICATIONS_UNINSTALL_ERROR_1 ${LANG_ENGLISH} "The uninstaller could not find registry entries for Guifications.$\rIt is likely that another user installed the plugin."
-LangString un.GUIFICATIONS_UNINSTALL_ERROR_2 ${LANG_ENGLISH} "You do not have the permissions necessary to uninstall the plugin."
+LangString PBAR_UNINSTALL_DESC ${LANG_ENGLISH} "PBar Plugin (remove only)"
+LangString un.PBAR_UNINSTALL_ERROR_1 ${LANG_ENGLISH} "The uninstaller could not find registry entries for PBar.$\rIt is likely that another user installed the plugin."
+LangString un.PBAR_UNINSTALL_ERROR_2 ${LANG_ENGLISH} "You do not have the permissions necessary to uninstall the plugin."
|
gawen947/pidgin-pbar
|
397ee517db72d1fbf38a3b68adc135f17ae87fce
|
Add nsis directory
|
diff --git a/nsis/dutch.nsh b/nsis/dutch.nsh
new file mode 100644
index 0000000..699aa5c
--- /dev/null
+++ b/nsis/dutch.nsh
@@ -0,0 +1,39 @@
+;;
+;; english.nsh
+;;
+;; Default language strings for the Windows guifications NSIS installer.
+;; Windows Code page: 1252
+;; Language Code: 1033
+;;
+
+; Startup Pidgin check
+LangString PIDGIN_NEEDED ${LANG_ENGLISH} "Guifications requires that Pidgin be installed. You must install Pidgin before installing Guifications."
+
+LangString GUIFICATIONS_TITLE ${LANG_ENGLISH} "Guifications plugin for Pidgin"
+
+LangString BAD_PIDGIN_VERSION_1 ${LANG_ENGLISH} "Incompatible version.$\r$\n$\r$\nThis version of the Guifications plugin was built for Pidgin version ${PIDGIN_VERSION}. It appears that you have Pidgin version"
+
+LangString BAD_PIDGIN_VERSION_2 ${LANG_ENGLISH} "installed.$\r$\n$\r$\nSee http://guifications.sourceforge.net for more information."
+
+LangString NO_PIDGIN_VERSION ${LANG_ENGLISH} "Unable to determine installed Pidgin version."
+
+
+; Overrides for default text in windows:
+
+LangString WELCOME_TITLE ${LANG_ENGLISH} "Guifications v${GUIFICATIONS_VERSION} Installer"
+LangString WELCOME_TEXT ${LANG_ENGLISH} "Note: This version of the plugin is designed for Pidgin ${PIDGIN_VERSION}, and will not install or function with versions of Pidgin having a different major version number.\r\n\r\nWhen you upgrade your version of Pidgin, you must uninstall or upgrade this plugin as well.\r\n\r\n"
+
+LangString DIR_SUBTITLE ${LANG_ENGLISH} "Please locate the directory where Pidgin is installed"
+LangString DIR_INNERTEXT ${LANG_ENGLISH} "Install in this Pidgin folder:"
+
+LangString FINISH_TITLE ${LANG_ENGLISH} "Guifications v${GUIFICATIONS_VERSION} Install Complete"
+LangString FINISH_TEXT ${LANG_ENGLISH} "You will need to restart Pidgin for the plugin to be loaded, then go the Pidgin preferences and enable the Guifications Plugin."
+
+; during install uninstaller
+LangString GUIFICATIONS_PROMPT_WIPEOUT ${LANG_ENGLISH} "The guifications.dll plugin is about to be deleted from your Pidgin/plugins directory. Continue?"
+
+; for windows uninstall
+LangString GUIFICATIONS_UNINSTALL_DESC ${LANG_ENGLISH} "Guifications Plugin (remove only)"
+LangString un.GUIFICATIONS_UNINSTALL_ERROR_1 ${LANG_ENGLISH} "The uninstaller could not find registry entries for Guifications.$\rIt is likely that another user installed the plugin."
+LangString un.GUIFICATIONS_UNINSTALL_ERROR_2 ${LANG_ENGLISH} "You do not have the permissions necessary to uninstall the plugin."
+
diff --git a/nsis/english.nsh b/nsis/english.nsh
new file mode 100644
index 0000000..699aa5c
--- /dev/null
+++ b/nsis/english.nsh
@@ -0,0 +1,39 @@
+;;
+;; english.nsh
+;;
+;; Default language strings for the Windows guifications NSIS installer.
+;; Windows Code page: 1252
+;; Language Code: 1033
+;;
+
+; Startup Pidgin check
+LangString PIDGIN_NEEDED ${LANG_ENGLISH} "Guifications requires that Pidgin be installed. You must install Pidgin before installing Guifications."
+
+LangString GUIFICATIONS_TITLE ${LANG_ENGLISH} "Guifications plugin for Pidgin"
+
+LangString BAD_PIDGIN_VERSION_1 ${LANG_ENGLISH} "Incompatible version.$\r$\n$\r$\nThis version of the Guifications plugin was built for Pidgin version ${PIDGIN_VERSION}. It appears that you have Pidgin version"
+
+LangString BAD_PIDGIN_VERSION_2 ${LANG_ENGLISH} "installed.$\r$\n$\r$\nSee http://guifications.sourceforge.net for more information."
+
+LangString NO_PIDGIN_VERSION ${LANG_ENGLISH} "Unable to determine installed Pidgin version."
+
+
+; Overrides for default text in windows:
+
+LangString WELCOME_TITLE ${LANG_ENGLISH} "Guifications v${GUIFICATIONS_VERSION} Installer"
+LangString WELCOME_TEXT ${LANG_ENGLISH} "Note: This version of the plugin is designed for Pidgin ${PIDGIN_VERSION}, and will not install or function with versions of Pidgin having a different major version number.\r\n\r\nWhen you upgrade your version of Pidgin, you must uninstall or upgrade this plugin as well.\r\n\r\n"
+
+LangString DIR_SUBTITLE ${LANG_ENGLISH} "Please locate the directory where Pidgin is installed"
+LangString DIR_INNERTEXT ${LANG_ENGLISH} "Install in this Pidgin folder:"
+
+LangString FINISH_TITLE ${LANG_ENGLISH} "Guifications v${GUIFICATIONS_VERSION} Install Complete"
+LangString FINISH_TEXT ${LANG_ENGLISH} "You will need to restart Pidgin for the plugin to be loaded, then go the Pidgin preferences and enable the Guifications Plugin."
+
+; during install uninstaller
+LangString GUIFICATIONS_PROMPT_WIPEOUT ${LANG_ENGLISH} "The guifications.dll plugin is about to be deleted from your Pidgin/plugins directory. Continue?"
+
+; for windows uninstall
+LangString GUIFICATIONS_UNINSTALL_DESC ${LANG_ENGLISH} "Guifications Plugin (remove only)"
+LangString un.GUIFICATIONS_UNINSTALL_ERROR_1 ${LANG_ENGLISH} "The uninstaller could not find registry entries for Guifications.$\rIt is likely that another user installed the plugin."
+LangString un.GUIFICATIONS_UNINSTALL_ERROR_2 ${LANG_ENGLISH} "You do not have the permissions necessary to uninstall the plugin."
+
diff --git a/nsis/french.nsh b/nsis/french.nsh
new file mode 100644
index 0000000..699aa5c
--- /dev/null
+++ b/nsis/french.nsh
@@ -0,0 +1,39 @@
+;;
+;; english.nsh
+;;
+;; Default language strings for the Windows guifications NSIS installer.
+;; Windows Code page: 1252
+;; Language Code: 1033
+;;
+
+; Startup Pidgin check
+LangString PIDGIN_NEEDED ${LANG_ENGLISH} "Guifications requires that Pidgin be installed. You must install Pidgin before installing Guifications."
+
+LangString GUIFICATIONS_TITLE ${LANG_ENGLISH} "Guifications plugin for Pidgin"
+
+LangString BAD_PIDGIN_VERSION_1 ${LANG_ENGLISH} "Incompatible version.$\r$\n$\r$\nThis version of the Guifications plugin was built for Pidgin version ${PIDGIN_VERSION}. It appears that you have Pidgin version"
+
+LangString BAD_PIDGIN_VERSION_2 ${LANG_ENGLISH} "installed.$\r$\n$\r$\nSee http://guifications.sourceforge.net for more information."
+
+LangString NO_PIDGIN_VERSION ${LANG_ENGLISH} "Unable to determine installed Pidgin version."
+
+
+; Overrides for default text in windows:
+
+LangString WELCOME_TITLE ${LANG_ENGLISH} "Guifications v${GUIFICATIONS_VERSION} Installer"
+LangString WELCOME_TEXT ${LANG_ENGLISH} "Note: This version of the plugin is designed for Pidgin ${PIDGIN_VERSION}, and will not install or function with versions of Pidgin having a different major version number.\r\n\r\nWhen you upgrade your version of Pidgin, you must uninstall or upgrade this plugin as well.\r\n\r\n"
+
+LangString DIR_SUBTITLE ${LANG_ENGLISH} "Please locate the directory where Pidgin is installed"
+LangString DIR_INNERTEXT ${LANG_ENGLISH} "Install in this Pidgin folder:"
+
+LangString FINISH_TITLE ${LANG_ENGLISH} "Guifications v${GUIFICATIONS_VERSION} Install Complete"
+LangString FINISH_TEXT ${LANG_ENGLISH} "You will need to restart Pidgin for the plugin to be loaded, then go the Pidgin preferences and enable the Guifications Plugin."
+
+; during install uninstaller
+LangString GUIFICATIONS_PROMPT_WIPEOUT ${LANG_ENGLISH} "The guifications.dll plugin is about to be deleted from your Pidgin/plugins directory. Continue?"
+
+; for windows uninstall
+LangString GUIFICATIONS_UNINSTALL_DESC ${LANG_ENGLISH} "Guifications Plugin (remove only)"
+LangString un.GUIFICATIONS_UNINSTALL_ERROR_1 ${LANG_ENGLISH} "The uninstaller could not find registry entries for Guifications.$\rIt is likely that another user installed the plugin."
+LangString un.GUIFICATIONS_UNINSTALL_ERROR_2 ${LANG_ENGLISH} "You do not have the permissions necessary to uninstall the plugin."
+
diff --git a/nsis/german.nsh b/nsis/german.nsh
new file mode 100644
index 0000000..699aa5c
--- /dev/null
+++ b/nsis/german.nsh
@@ -0,0 +1,39 @@
+;;
+;; english.nsh
+;;
+;; Default language strings for the Windows guifications NSIS installer.
+;; Windows Code page: 1252
+;; Language Code: 1033
+;;
+
+; Startup Pidgin check
+LangString PIDGIN_NEEDED ${LANG_ENGLISH} "Guifications requires that Pidgin be installed. You must install Pidgin before installing Guifications."
+
+LangString GUIFICATIONS_TITLE ${LANG_ENGLISH} "Guifications plugin for Pidgin"
+
+LangString BAD_PIDGIN_VERSION_1 ${LANG_ENGLISH} "Incompatible version.$\r$\n$\r$\nThis version of the Guifications plugin was built for Pidgin version ${PIDGIN_VERSION}. It appears that you have Pidgin version"
+
+LangString BAD_PIDGIN_VERSION_2 ${LANG_ENGLISH} "installed.$\r$\n$\r$\nSee http://guifications.sourceforge.net for more information."
+
+LangString NO_PIDGIN_VERSION ${LANG_ENGLISH} "Unable to determine installed Pidgin version."
+
+
+; Overrides for default text in windows:
+
+LangString WELCOME_TITLE ${LANG_ENGLISH} "Guifications v${GUIFICATIONS_VERSION} Installer"
+LangString WELCOME_TEXT ${LANG_ENGLISH} "Note: This version of the plugin is designed for Pidgin ${PIDGIN_VERSION}, and will not install or function with versions of Pidgin having a different major version number.\r\n\r\nWhen you upgrade your version of Pidgin, you must uninstall or upgrade this plugin as well.\r\n\r\n"
+
+LangString DIR_SUBTITLE ${LANG_ENGLISH} "Please locate the directory where Pidgin is installed"
+LangString DIR_INNERTEXT ${LANG_ENGLISH} "Install in this Pidgin folder:"
+
+LangString FINISH_TITLE ${LANG_ENGLISH} "Guifications v${GUIFICATIONS_VERSION} Install Complete"
+LangString FINISH_TEXT ${LANG_ENGLISH} "You will need to restart Pidgin for the plugin to be loaded, then go the Pidgin preferences and enable the Guifications Plugin."
+
+; during install uninstaller
+LangString GUIFICATIONS_PROMPT_WIPEOUT ${LANG_ENGLISH} "The guifications.dll plugin is about to be deleted from your Pidgin/plugins directory. Continue?"
+
+; for windows uninstall
+LangString GUIFICATIONS_UNINSTALL_DESC ${LANG_ENGLISH} "Guifications Plugin (remove only)"
+LangString un.GUIFICATIONS_UNINSTALL_ERROR_1 ${LANG_ENGLISH} "The uninstaller could not find registry entries for Guifications.$\rIt is likely that another user installed the plugin."
+LangString un.GUIFICATIONS_UNINSTALL_ERROR_2 ${LANG_ENGLISH} "You do not have the permissions necessary to uninstall the plugin."
+
diff --git a/nsis/header.bmp b/nsis/header.bmp
new file mode 100644
index 0000000..64df125
Binary files /dev/null and b/nsis/header.bmp differ
diff --git a/nsis/install.ico b/nsis/install.ico
new file mode 100644
index 0000000..cc156e3
Binary files /dev/null and b/nsis/install.ico differ
|
gawen947/pidgin-pbar
|
75e92d21b7199277a0736f5763478bc3e909becc
|
Add experimental installer
|
diff --git a/installer.nsi b/installer.nsi
new file mode 100644
index 0000000..7430a3b
--- /dev/null
+++ b/installer.nsi
@@ -0,0 +1,407 @@
+; NSIS Script For PBar Plugin
+; Author David Hauweele
+; Based on the Guifications Plugin installer by Daniel A. Atallah
+; Uses NSIS v2.0
+
+;--------------------------------
+;Include Modern UI
+ !include "MUI.nsh"
+
+!include "FileFunc.nsh"
+!insertmacro GetParameters
+!insertmacro GetOptions
+
+
+;--------------------------------
+;General
+ Name "Pidgin PBar ${PBAR_VERSION}"
+
+ ;Do A CRC Check
+ CRCCheck On
+
+ ;Output File Name
+ OutFile "Pidgin-PBar_${PBAR_VERSION}.exe"
+
+ ;The Default Installation Directory
+ InstallDir "$PROGRAMFILES\pidgin"
+ InstallDirRegKey HKLM SOFTWARE\pidgin ""
+
+ ShowInstDetails show
+ ShowUnInstDetails show
+ SetCompressor /SOLID lzma
+
+;Reserve files used in .onInit for faster start-up
+!insertmacro MUI_RESERVEFILE_LANGDLL
+
+ !define PBAR_UNINST_EXE "Pidgin-PBar-uninst.exe"
+ !define PBAR_DLL "pbar.dll"
+ !define PBAR_UNINSTALL_LNK "PBar Uninstall.lnk"
+
+;--------------------------------
+; Registry keys:
+ !define PBAR_REG_KEY "SOFTWARE\pidgin-pbar"
+ !define PBAR_UNINSTALL_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\pidgin-pbar"
+
+;-------------------------------
+; Pidgin Plugin installer helper stuff
+ !addincludedir "${PIDGIN_TREE_TOP}\pidgin\win32\nsis"
+ !include "pidgin-plugin.nsh"
+
+;--------------------------------
+; Modern UI Configuration
+ !define MUI_ICON .\nsis\install.ico
+ !define MUI_UNICON .\nsis\install.ico
+ !define MUI_HEADERIMAGE
+ !define MUI_HEADERIMAGE_BITMAP "nsis\header.bmp"
+ !define MUI_CUSTOMFUNCTION_GUIINIT pbar_checkPidginVersion
+ !define MUI_ABORTWARNING
+
+ !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
+ !define MUI_LANGDLL_REGISTRY_KEY ${PBAR_REG_KEY}
+ !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
+
+;--------------------------------
+; Pages
+ ;Welcome Page
+ !define MUI_WELCOMEPAGE_TITLE $(WELCOME_TITLE)
+ !define MUI_WELCOMEPAGE_TEXT $(WELCOME_TEXT)
+ !insertmacro MUI_PAGE_WELCOME
+
+ ;License Page
+ !define MUI_LICENSEPAGE_RADIOBUTTONS
+ !insertmacro MUI_PAGE_LICENSE ".\COPYING"
+
+ ;Directory Page
+ !define MUI_DIRECTORYPAGE_TEXT_TOP $(DIR_SUBTITLE)
+ !define MUI_DIRECTORYPAGE_TEXT_DESTINATION $(DIR_INNERTEXT)
+ !insertmacro MUI_PAGE_DIRECTORY
+
+ ;Installation Page
+ !insertmacro MUI_PAGE_INSTFILES
+
+ ;Finish Page
+ !define MUI_FINISHPAGE_TITLE $(FINISH_TITLE)
+ !define MUI_FINISHPAGE_TEXT $(FINISH_TEXT)
+ !insertmacro MUI_PAGE_FINISH
+
+
+;--------------------------------
+; Languages
+ !insertmacro MUI_LANGUAGE "English"
+ !insertmacro MUI_LANGUAGE "French"
+ !insertmacro MUI_LANGUAGE "Dutch"
+ !insertmacro MUI_LANGUAGE "German"
+
+ ;Translations
+ !include "nsis\translations\english.nsh"
+ !include "nsis\translations\french.nsh"
+ !include "nsis\translations\dutch.nsh"
+ !include "nsis\translations\german.nsh"
+
+; Uninstall the previous version if it exists
+Section -SecUninstallOldPlugin
+ ; Check install rights..
+ Call CheckUserInstallRights
+ Pop $R0
+
+ StrCmp $R0 "HKLM" rights_hklm
+ StrCmp $R0 "HKCU" rights_hkcu done
+
+ rights_hkcu:
+ ReadRegStr $R1 HKCU "${PBAR_REG_KEY}" ""
+ ReadRegStr $R2 HKCU "${PBAR_REG_KEY}" "Version"
+ ReadRegStr $R3 HKCU "${PBAR_UNINSTALL_KEY}" "UninstallString"
+ Goto try_uninstall
+
+ rights_hklm:
+ ReadRegStr $R1 HKLM "${PBAR_REG_KEY}" ""
+ ReadRegStr $R2 HKLM "${PBAR_REG_KEY}" "Version"
+ ReadRegStr $R3 HKLM "${PBAR_UNINSTALL_KEY}" "UninstallString"
+
+ ; If previous version exists .. remove
+ try_uninstall:
+ StrCmp $R1 "" done
+ StrCmp $R2 "" uninstall_problem
+ IfFileExists $R3 0 uninstall_problem
+ ; Have uninstall string.. go ahead and uninstall.
+ SetOverwrite on
+ ; Need to copy uninstaller outside of the install dir
+ ClearErrors
+ CopyFiles /SILENT $R3 "$TEMP\${PBAR_UNINST_EXE}"
+ SetOverwrite off
+ IfErrors uninstall_problem
+ ; Ready to uninstall..
+ ClearErrors
+ ExecWait '"$TEMP\${PBAR_UNINST_EXE}" /S _?=$R1'
+ IfErrors exec_error
+ Delete "$TEMP\${PBAR_UNINST_EXE}"
+ Goto done
+
+ exec_error:
+ Delete "$TEMP\${PBAR_UNINST_EXE}"
+ Goto uninstall_problem
+
+ uninstall_problem:
+ ; Just delete the plugin and uninstaller, and remove Registry key
+ MessageBox MB_YESNO $(PBAR_PROMPT_WIPEOUT) IDYES do_wipeout IDNO cancel_install
+ cancel_install:
+ Quit
+
+ do_wipeout:
+ StrCmp $R0 "HKLM" del_lm_reg del_cu_reg
+ del_cu_reg:
+ DeleteRegKey HKCU ${PBAR_REG_KEY}
+ Goto uninstall_prob_cont
+ del_lm_reg:
+ DeleteRegKey HKLM ${PBAR_REG_KEY}
+
+ uninstall_prob_cont:
+ ; plugin DLL
+ Delete "$R1\plugins\${PBAR_DLL}"
+ Delete "$R3"
+
+ done:
+SectionEnd
+
+!macro INSTALL_GMO LANG
+ SetOutPath "$INSTDIR\locale\${LANG}\LC_MESSAGES"
+ File /oname=pbar.mo po\${LANG}.gmo
+!macroend
+
+Section "Install"
+ Call CheckUserInstallRights
+ Pop $R0
+
+ StrCmp $R0 "NONE" instrights_none
+ StrCmp $R0 "HKLM" instrights_hklm instrights_hkcu
+
+ instrights_hklm:
+ ; Write the version registry keys:
+ WriteRegStr HKLM ${PBAR_REG_KEY} "" "$INSTDIR"
+ WriteRegStr HKLM ${PBAR_REG_KEY} "Version" "${PBAR_VERSION}"
+
+ ; Write the uninstall keys for Windows
+ WriteRegStr HKLM ${PBAR_UNINSTALL_KEY} "DisplayName" "$(PBAR_UNINSTALL_DESC)"
+ WriteRegStr HKLM ${PBAR_UNINSTALL_KEY} "UninstallString" "$INSTDIR\${PBAR_UNINST_EXE}"
+ SetShellVarContext "all"
+ Goto install_files
+
+ instrights_hkcu:
+ ; Write the version registry keys:
+ WriteRegStr HKCU ${PBAR_REG_KEY} "" "$INSTDIR"
+ WriteRegStr HKCU ${PBAR_REG_KEY} "Version" "${PBAR_VERSION}"
+
+ ; Write the uninstall keys for Windows
+ WriteRegStr HKCU ${PBAR_UNINSTALL_KEY} "DisplayName" "$(PBAR_UNINSTALL_DESC)"
+ WriteRegStr HKCU ${PBAR_UNINSTALL_KEY} "UninstallString" "$INSTDIR\${PBAR_UNINST_EXE}"
+ Goto install_files
+
+ instrights_none:
+ ; No registry keys for us...
+
+ install_files:
+ SetOutPath "$INSTDIR\plugins"
+ SetCompress Auto
+ SetOverwrite on
+ File "src\${PBAR_DLL}"
+
+ ; translations - if there is a way to automate this, i can't find it
+ !insertmacro INSTALL_GMO "de"
+ !insertmacro INSTALL_GMO "fr"
+ !insertmacro INSTALL_GMO "nl"
+
+ StrCmp $R0 "NONE" done
+ CreateShortCut "$SMPROGRAMS\Pidgin\${PBAR_UNINSTALL_LNK}" "$INSTDIR\${PBAR_UNINST_EXE}"
+ WriteUninstaller "$INSTDIR\${PBAR_UNINST_EXE}"
+ SetOverWrite off
+
+ done:
+SectionEnd
+
+Section Uninstall
+ Call un.CheckUserInstallRights
+ Pop $R0
+ StrCmp $R0 "NONE" no_rights
+ StrCmp $R0 "HKCU" try_hkcu try_hklm
+
+ try_hkcu:
+ ReadRegStr $R0 HKCU "${PBAR_REG_KEY}" ""
+ StrCmp $R0 $INSTDIR 0 cant_uninstall
+ ; HKCU install path matches our INSTDIR.. so uninstall
+ DeleteRegKey HKCU "${PBAR_REG_KEY}"
+ DeleteRegKey HKCU "${PBAR_UNINSTALL_KEY}"
+ Goto cont_uninstall
+
+ try_hklm:
+ ReadRegStr $R0 HKLM "${PBAR_REG_KEY}" ""
+ StrCmp $R0 $INSTDIR 0 try_hkcu
+ ; HKLM install path matches our INSTDIR.. so uninstall
+ DeleteRegKey HKLM "${PBAR_REG_KEY}"
+ DeleteRegKey HKLM "${PBAR_UNINSTALL_KEY}"
+ ; Sets start menu and desktop scope to all users..
+ SetShellVarContext "all"
+
+ cont_uninstall:
+ ; plugin
+ Delete "$INSTDIR\plugins\${PBAR_DLL}"
+
+ ; translations
+ ; loop through locale dirs and try to delete any PBar translations
+ ClearErrors
+ FindFirst $R1 $R2 "$INSTDIR\locale\*"
+ IfErrors doneFindingTranslations
+
+ processCurrentTranslationDir:
+ ;Ignore "." and ".."
+ StrCmp $R2 "." readNextTranslationDir
+ StrCmp $R2 ".." readNextTranslationDir
+ IfFileExists "$INSTDIR\locale\$R2\LC_MESSAGES\pbar.mo" +1 readNextTranslationDir
+ Delete "$INSTDIR\locale\$R2\LC_MESSAGES\pbar.mo"
+ RMDir "$INSTDIR\locale\$R2\LC_MESSAGES"
+ RMDir "$INSTDIR\locale\$R2"
+ ClearErrors
+ readNextTranslationDir:
+ FindNext $R1 $R2
+ IfErrors doneFindingTranslations processCurrentTranslationDir
+
+ doneFindingTranslations:
+ FindClose $R1
+ RMDir "$INSTDIR\locale"
+
+ ; uninstaller
+ Delete "$INSTDIR\${PBAR_UNINST_EXE}"
+ ; uninstaller shortcut
+ Delete "$SMPROGRAMS\Pidgin\${PBAR_UNINSTALL_LNK}"
+
+ ; try to delete the Pidgin directories, in case it has already uninstalled
+ RMDir "$INSTDIR\plugins"
+ RMDir "$INSTDIR"
+ RMDir "$SMPROGRAMS\Pidgin"
+
+ Goto done
+
+ cant_uninstall:
+ MessageBox MB_OK $(un.PBAR_UNINSTALL_ERROR_1) IDOK
+ Quit
+
+ no_rights:
+ MessageBox MB_OK $(un.PBAR_UNINSTALL_ERROR_2) IDOK
+ Quit
+
+ done:
+SectionEnd
+
+Function .onInit
+ ${GetParameters} $R0
+ ClearErrors
+ ${GetOptions} $R0 "/L=" $R0
+ IfErrors +3
+ StrCpy $LANGUAGE $R0
+ Goto skip_lang
+
+ ; Select Language
+ ; Display Language selection dialog
+ !insertmacro MUI_LANGDLL_DISPLAY
+ skip_lang:
+
+FunctionEnd
+
+Function un.onInit
+ ; Get stored language preference
+ !insertmacro MUI_UNGETLANGUAGE
+FunctionEnd
+
+
+; Check that the selected installation dir contains pidgin.exe
+Function .onVerifyInstDir
+ IfFileExists $INSTDIR\pidgin.exe +2
+ Abort
+FunctionEnd
+
+; Check that the currently installed pidgin version is compatible with the version of PBar we are installing
+Function pbar_checkPidginVersion
+ Push $R0
+
+ Push ${PIDGIN_VERSION}
+ Call CheckPidginVersion
+ Pop $R0
+
+ StrCmp $R0 ${PIDGIN_VERSION_OK} pbar_checkPidginVersion_OK
+ StrCmp $R0 ${PIDGIN_VERSION_INCOMPATIBLE} +1 +6
+ Call GetPidginVersion
+ IfErrors +3
+ Pop $R0
+ MessageBox MB_OK|MB_ICONSTOP "$(BAD_PIDGIN_VERSION_1) $R0 $(BAD_PIDGIN_VERSION_2)"
+ goto +2
+ MessageBox MB_OK|MB_ICONSTOP "$(NO_PIDGIN_VERSION)"
+ Quit
+
+ pbar_checkPidginVersion_OK:
+ Pop $R0
+FunctionEnd
+
+Function CheckUserInstallRights
+ ClearErrors
+ UserInfo::GetName
+ IfErrors Win9x
+ Pop $0
+ UserInfo::GetAccountType
+ Pop $1
+
+ StrCmp $1 "Admin" 0 +3
+ StrCpy $1 "HKLM"
+ Goto done
+ StrCmp $1 "Power" 0 +3
+ StrCpy $1 "HKLM"
+ Goto done
+ StrCmp $1 "User" 0 +3
+ StrCpy $1 "HKCU"
+ Goto done
+ StrCmp $1 "Guest" 0 +3
+ StrCpy $1 "NONE"
+ Goto done
+
+ ; Unknown error
+ StrCpy $1 "NONE"
+ Goto done
+
+ Win9x:
+ StrCpy $1 "HKLM"
+
+ done:
+ Push $1
+FunctionEnd
+
+; This is necessary because the uninstaller doesn't have access to installer functions
+; (it is identical to CheckUserInstallRights)
+Function un.CheckUserInstallRights
+ ClearErrors
+ UserInfo::GetName
+ IfErrors Win9x
+ Pop $0
+ UserInfo::GetAccountType
+ Pop $1
+
+ StrCmp $1 "Admin" 0 +3
+ StrCpy $1 "HKLM"
+ Goto done
+ StrCmp $1 "Power" 0 +3
+ StrCpy $1 "HKLM"
+ Goto done
+ StrCmp $1 "User" 0 +3
+ StrCpy $1 "HKCU"
+ Goto done
+ StrCmp $1 "Guest" 0 +3
+ StrCpy $1 "NONE"
+ Goto done
+
+ ; Unknown error
+ StrCpy $1 "NONE"
+ Goto done
+
+ Win9x:
+ StrCpy $1 "HKLM"
+
+ done:
+ Push $1
+FunctionEnd
|
gawen947/pidgin-pbar
|
756561ae482abe0941c1cb168087b16619161a53
|
Change Windows makefile
|
diff --git a/makefile.mingw b/makefile.mingw
index 5b15354..96e1042 100644
--- a/makefile.mingw
+++ b/makefile.mingw
@@ -1,109 +1,110 @@
+#
+# Makefile.mingw
+#
+# Description: Makefile for Pidgin PBar.
+# Taken from the privacy please plugin.
+#
+
include commands.mk
PIDGIN_TREE_TOP := ../../..
include $(PIDGIN_TREE_TOP)/libpurple/win32/global.mak
-SRC = $(wildcard *.c)
-OBJ = $(SRC:%.c=%.o)
-DEP = $(SRC:.c=.c)
-POFILES = $(wildcard *.po)
-CATALOGS = $(foreach cat, $(POFILES:.po=.mo), $(notdir $(cat)))
+VERSION = $(shell cat VERSION)
+
+TARGET = pbar
-PLUGINDIR ?= $(PIDGIN_INSTALL_PLUGINS_DIR)
-DATADIR ?= $(PIDGIN_INSTALL_DIR)
-LOCALDIR ?= $(PURPLE_INSTALL_PO_DIR)
-
-PIDGIN_VERSION := $(shell cat $(PIDGIN_TREE_TOP)/VERSION)
-PBAR_VERSION := $(shell cat VERSION)
-CFLAGS += -DVERSION="\"$(PBAR_VERSION)\"" -DPIDGIN_VERSION="\"$(PIDGIN_VERSION)\""
-
-INCLUDE += -I. \
- -I$(GTK_TOP)/include \
- -I$(GTK_TOP)/include/gtk-2.0 \
- -I$(GTK_TOP)/include/glib-2.0 \
- -I$(GTK_TOP)/include/pango-1.0 \
- -I$(GTK_TOP)/include/atk-1.0 \
- -I$(GTK_TOP)/include/cairo \
- -I$(GTK_TOP)/lib/glib-2.0/include \
- -I$(GTK_TOP)/lib/gtk-2.0/include \
- -I$(PURPLE_TOP) \
- -I$(PURPLE_TOP)/win32 \
- -I$(PIDGIN_TOP) \
- -I$(PIDGIN_TOP)/win32 \
- -I$(PIDGIN_TREE_TOP)
+DEFINES += -DGETTEXT_PACKAGE=\"pbar\"
+DEFINES += -DPACKAGE_VERSION=\"$(VERSION)\"
+
+INCLUDE_PATHS += -I. \
+ -I$(GTK_TOP)/include \
+ -I$(GTK_TOP)/include/gtk-2.0 \
+ -I$(GTK_TOP)/include/glib-2.0 \
+ -I$(GTK_TOP)/include/pango-1.0 \
+ -I$(GTK_TOP)/include/atk-1.0 \
+ -I$(GTK_TOP)/include/cairo \
+ -I$(GTK_TOP)/lib/glib-2.0/include \
+ -I$(GTK_TOP)/lib/gtk-2.0/include \
+ -I$(PURPLE_TOP) \
+ -I$(PURPLE_TOP)/win32 \
+ -I$(PIDGIN_TOP) \
+ -I$(PIDGIN_TOP)/win32 \
+ -I$(PIDGIN_TREE_TOP)
LIB_PATHS += -L$(GTK_TOP)/lib \
- -L$(PURPLE_TOP) \
- -L$(PIDGIN_TOP)
-LDFLAGS = -lgtk-win32-2.0 \
- -lglib-2.0 \
- -lgdk-win32-2.0 \
- -lgdk_pixbuf-2.0 \
- -lgobject-2.0 \
- -lintl \
- -lpurple \
- -lpidgin
+ -L$(PURPLE_TOP) \
+ -L$(PIDGIN_TOP)
+
+C_SRC = $(wildcard *.c)
+OBJECTS = $(C_SRC:%.c=%.o)
+
+LIBS = -lgtk-win32-2.0 \
+ -lglib-2.0 \
+ -lgdk-win32-2.0 \
+ -lgdk_pixbuf-2.0 \
+ -lgobject-2.0 \
+ -lintl \
+ -lpurple \
+ -lpidgin
ifndef DISABLE_DEBUG
CFLAGS += -ggdb
endif
commit = $(shell ./hash.sh)
ifneq ($(commit), UNKNOWN)
-CFLAGS += -DCOMMIT="\"$(commit)\""
+DEFINES += -DCOMMIT="\"$(commit)\""
endif
+POFILES = $(wildcard *.po)
+CATALOGS = $(foreach cat, $(POFILES:.po=.mo), $(notdir $(cat)))
+
ifndef DISABLE_NLS
-CFLAGS += -DENABLE_NLS=1 -DLOCALEDIR="\"$(LOCALEDIR)\""
+DEFINES += -DENABLE_NLS=1 -DLOCALEDIR="\"$(LOCALEDIR)\""
locales := locales
install-locales := install-locales
uninstall-locales := uninstall-locales
endif
include $(PIDGIN_COMMON_RULES)
-.PHONY: all clean
+.PHONY: all install clean
-all: pbar.dll $(locales)
+all: $(TARGET).dll $(locales)
-pbar.dll: $(OBJ)
- $(CC) -shared -o $@ $^ $LIB_PATHS) $(LDFLAGS) $(DLL_LD_FLAGS)
+install: $(PIDGIN_INSTALL_PLUGINS_DIR) all
+ cp $(TARGET).dll $(PIDGIN_INSTALL_PLUGINS_DIR)
-%o: %.c
- $(CC) -Wp,-MMD,$*.d -c $(CFLAGS) -o $@ $<
-
-clean:
- $(RM) $(DEP)
- $(RM) $(OBJ)
- $(RM) $(CATALOGS)
- $(RM) messages.pot
- $(RM) pbar.dll
+$(OBJECTS): $(PIDGIN_CONFIG_H)
-install: $(install-locales)
- cp pbar.dll $(PLUGINDIR)
+$(TARGET).dll: $(PURPLE_DLL).a $(PIDGIN_DLL).a $(OBJECTS)
+ $(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -o $(TARGET).dll
-$(OBJECTS): $(PIDGIN_CONFIG_H)
+clean:
+ rm -rf $(OBJECTS)
+ rm -rf $(TARGET).dll
locales: $(CATALOGS)
CAT_INST_PATH = $(foreach lang, $(POFILES:.po=), $(LOCALEDIR)/$(lang)/LC_MESSAGES/pidgin-pbar.mo)
install-locales: $(CAT_INST_PATH)
$(LOCALEDIR)/%/LC_MESSAGES/pidgin-pbar.mo: %.mo
$(MKDIR) -p $(LOCALEDIR)/$(basename $<)/LC_MESSAGES
$(INSTALL_DATA) $< $@
uninstall-locales:
$(RM) $(CAT_INST_PATH)
%.mo: %.po
$(MSGFMT) -c -o $@ $<
messages.pot: POTFILES.in
$(XGETTEXT) --no-wrap -m -c --files-from $< --keyword --keyword=_ --keyword=N_ -o $@
installer: all
$(MAKENSIS) -DPBAR_VERSION="$(PBAR_VERSION)" -DPIDGIN_VERSION="$(PIDGIN_VERSION)" -DPIDGIN_TREE_TOP="$(PIDGIN_TREE_TOP)" installer.nsi
include $(PIDGIN_COMMON_TARGETS)
|
gawen947/pidgin-pbar
|
c83e301f73cf2ce81f67db35f42b8b73095dfbca
|
Fix Windows makefile
|
diff --git a/makefile.mingw b/makefile.mingw
index 7d7edbc..5b15354 100644
--- a/makefile.mingw
+++ b/makefile.mingw
@@ -1,109 +1,109 @@
include commands.mk
PIDGIN_TREE_TOP := ../../..
include $(PIDGIN_TREE_TOP)/libpurple/win32/global.mak
SRC = $(wildcard *.c)
OBJ = $(SRC:%.c=%.o)
DEP = $(SRC:.c=.c)
POFILES = $(wildcard *.po)
CATALOGS = $(foreach cat, $(POFILES:.po=.mo), $(notdir $(cat)))
PLUGINDIR ?= $(PIDGIN_INSTALL_PLUGINS_DIR)
DATADIR ?= $(PIDGIN_INSTALL_DIR)
LOCALDIR ?= $(PURPLE_INSTALL_PO_DIR)
PIDGIN_VERSION := $(shell cat $(PIDGIN_TREE_TOP)/VERSION)
PBAR_VERSION := $(shell cat VERSION)
CFLAGS += -DVERSION="\"$(PBAR_VERSION)\"" -DPIDGIN_VERSION="\"$(PIDGIN_VERSION)\""
INCLUDE += -I. \
-I$(GTK_TOP)/include \
-I$(GTK_TOP)/include/gtk-2.0 \
-I$(GTK_TOP)/include/glib-2.0 \
-I$(GTK_TOP)/include/pango-1.0 \
-I$(GTK_TOP)/include/atk-1.0 \
-I$(GTK_TOP)/include/cairo \
-I$(GTK_TOP)/lib/glib-2.0/include \
-I$(GTK_TOP)/lib/gtk-2.0/include \
-I$(PURPLE_TOP) \
-I$(PURPLE_TOP)/win32 \
-I$(PIDGIN_TOP) \
-I$(PIDGIN_TOP)/win32 \
-I$(PIDGIN_TREE_TOP)
LIB_PATHS += -L$(GTK_TOP)/lib \
-L$(PURPLE_TOP) \
-L$(PIDGIN_TOP)
LDFLAGS = -lgtk-win32-2.0 \
-lglib-2.0 \
-lgdk-win32-2.0 \
-lgdk_pixbuf-2.0 \
-lgobject-2.0 \
-lintl \
-lpurple \
-lpidgin
ifndef DISABLE_DEBUG
CFLAGS += -ggdb
endif
commit = $(shell ./hash.sh)
ifneq ($(commit), UNKNOWN)
CFLAGS += -DCOMMIT="\"$(commit)\""
endif
ifndef DISABLE_NLS
CFLAGS += -DENABLE_NLS=1 -DLOCALEDIR="\"$(LOCALEDIR)\""
locales := locales
install-locales := install-locales
uninstall-locales := uninstall-locales
endif
include $(PIDGIN_COMMON_RULES)
.PHONY: all clean
all: pbar.dll $(locales)
pbar.dll: $(OBJ)
- $(CC) -shared -o $@ $^ $LIB_PATHS) $(LDFLAGS) $(DLL_LD_FLAGS)
+ $(CC) -shared -o $@ $^ $LIB_PATHS) $(LDFLAGS) $(DLL_LD_FLAGS)
%o: %.c
- $(CC) -Wp,-MMD,$*.d -c $(CFLAGS) -o $@ $<
+ $(CC) -Wp,-MMD,$*.d -c $(CFLAGS) -o $@ $<
clean:
- $(RM) $(DEP)
- $(RM) $(OBJ)
- $(RM) $(CATALOGS)
- $(RM) messages.pot
- $(RM) pbar.dll
+ $(RM) $(DEP)
+ $(RM) $(OBJ)
+ $(RM) $(CATALOGS)
+ $(RM) messages.pot
+ $(RM) pbar.dll
install: $(install-locales)
- cp pbar.dll $(PLUGINDIR)
+ cp pbar.dll $(PLUGINDIR)
$(OBJECTS): $(PIDGIN_CONFIG_H)
locales: $(CATALOGS)
CAT_INST_PATH = $(foreach lang, $(POFILES:.po=), $(LOCALEDIR)/$(lang)/LC_MESSAGES/pidgin-pbar.mo)
install-locales: $(CAT_INST_PATH)
$(LOCALEDIR)/%/LC_MESSAGES/pidgin-pbar.mo: %.mo
$(MKDIR) -p $(LOCALEDIR)/$(basename $<)/LC_MESSAGES
$(INSTALL_DATA) $< $@
uninstall-locales:
$(RM) $(CAT_INST_PATH)
%.mo: %.po
$(MSGFMT) -c -o $@ $<
messages.pot: POTFILES.in
$(XGETTEXT) --no-wrap -m -c --files-from $< --keyword --keyword=_ --keyword=N_ -o $@
installer: all
$(MAKENSIS) -DPBAR_VERSION="$(PBAR_VERSION)" -DPIDGIN_VERSION="$(PIDGIN_VERSION)" -DPIDGIN_TREE_TOP="$(PIDGIN_TREE_TOP)" installer.nsi
include $(PIDGIN_COMMON_TARGETS)
|
gawen947/pidgin-pbar
|
8eb6c348bcbb0114a39e43a72249b9507d50136e
|
Add experimental makefile for Windows
|
diff --git a/makefile.mingw b/makefile.mingw
new file mode 100644
index 0000000..7d7edbc
--- /dev/null
+++ b/makefile.mingw
@@ -0,0 +1,109 @@
+include commands.mk
+
+PIDGIN_TREE_TOP := ../../..
+include $(PIDGIN_TREE_TOP)/libpurple/win32/global.mak
+
+SRC = $(wildcard *.c)
+OBJ = $(SRC:%.c=%.o)
+DEP = $(SRC:.c=.c)
+POFILES = $(wildcard *.po)
+CATALOGS = $(foreach cat, $(POFILES:.po=.mo), $(notdir $(cat)))
+
+PLUGINDIR ?= $(PIDGIN_INSTALL_PLUGINS_DIR)
+DATADIR ?= $(PIDGIN_INSTALL_DIR)
+LOCALDIR ?= $(PURPLE_INSTALL_PO_DIR)
+
+PIDGIN_VERSION := $(shell cat $(PIDGIN_TREE_TOP)/VERSION)
+PBAR_VERSION := $(shell cat VERSION)
+CFLAGS += -DVERSION="\"$(PBAR_VERSION)\"" -DPIDGIN_VERSION="\"$(PIDGIN_VERSION)\""
+
+INCLUDE += -I. \
+ -I$(GTK_TOP)/include \
+ -I$(GTK_TOP)/include/gtk-2.0 \
+ -I$(GTK_TOP)/include/glib-2.0 \
+ -I$(GTK_TOP)/include/pango-1.0 \
+ -I$(GTK_TOP)/include/atk-1.0 \
+ -I$(GTK_TOP)/include/cairo \
+ -I$(GTK_TOP)/lib/glib-2.0/include \
+ -I$(GTK_TOP)/lib/gtk-2.0/include \
+ -I$(PURPLE_TOP) \
+ -I$(PURPLE_TOP)/win32 \
+ -I$(PIDGIN_TOP) \
+ -I$(PIDGIN_TOP)/win32 \
+ -I$(PIDGIN_TREE_TOP)
+
+LIB_PATHS += -L$(GTK_TOP)/lib \
+ -L$(PURPLE_TOP) \
+ -L$(PIDGIN_TOP)
+LDFLAGS = -lgtk-win32-2.0 \
+ -lglib-2.0 \
+ -lgdk-win32-2.0 \
+ -lgdk_pixbuf-2.0 \
+ -lgobject-2.0 \
+ -lintl \
+ -lpurple \
+ -lpidgin
+
+ifndef DISABLE_DEBUG
+CFLAGS += -ggdb
+endif
+
+commit = $(shell ./hash.sh)
+ifneq ($(commit), UNKNOWN)
+CFLAGS += -DCOMMIT="\"$(commit)\""
+endif
+
+ifndef DISABLE_NLS
+CFLAGS += -DENABLE_NLS=1 -DLOCALEDIR="\"$(LOCALEDIR)\""
+locales := locales
+install-locales := install-locales
+uninstall-locales := uninstall-locales
+endif
+
+include $(PIDGIN_COMMON_RULES)
+
+.PHONY: all clean
+
+all: pbar.dll $(locales)
+
+pbar.dll: $(OBJ)
+ $(CC) -shared -o $@ $^ $LIB_PATHS) $(LDFLAGS) $(DLL_LD_FLAGS)
+
+%o: %.c
+ $(CC) -Wp,-MMD,$*.d -c $(CFLAGS) -o $@ $<
+
+clean:
+ $(RM) $(DEP)
+ $(RM) $(OBJ)
+ $(RM) $(CATALOGS)
+ $(RM) messages.pot
+ $(RM) pbar.dll
+
+install: $(install-locales)
+ cp pbar.dll $(PLUGINDIR)
+
+$(OBJECTS): $(PIDGIN_CONFIG_H)
+
+locales: $(CATALOGS)
+
+CAT_INST_PATH = $(foreach lang, $(POFILES:.po=), $(LOCALEDIR)/$(lang)/LC_MESSAGES/pidgin-pbar.mo)
+
+install-locales: $(CAT_INST_PATH)
+
+$(LOCALEDIR)/%/LC_MESSAGES/pidgin-pbar.mo: %.mo
+ $(MKDIR) -p $(LOCALEDIR)/$(basename $<)/LC_MESSAGES
+ $(INSTALL_DATA) $< $@
+
+uninstall-locales:
+ $(RM) $(CAT_INST_PATH)
+
+%.mo: %.po
+ $(MSGFMT) -c -o $@ $<
+
+messages.pot: POTFILES.in
+ $(XGETTEXT) --no-wrap -m -c --files-from $< --keyword --keyword=_ --keyword=N_ -o $@
+
+installer: all
+ $(MAKENSIS) -DPBAR_VERSION="$(PBAR_VERSION)" -DPIDGIN_VERSION="$(PIDGIN_VERSION)" -DPIDGIN_TREE_TOP="$(PIDGIN_TREE_TOP)" installer.nsi
+
+include $(PIDGIN_COMMON_TARGETS)
|
gawen947/pidgin-pbar
|
37383574474b4e61554fd22eea22e0ddd44c5532
|
Fix makefile
|
diff --git a/makefile b/makefile
index d8d8763..afa76ea 100644
--- a/makefile
+++ b/makefile
@@ -1,84 +1,83 @@
include commands.mk
OPTS := -O2
CFLAGS := -std=c99 $(OPTS) $(shell pkg-config --cflags pidgin purple gtk+-2.0 gobject-2.0) -fPIC -Wall
LDFLAGS := $(shell pkg-config --libs pidgin purple gtk+-2.0 gobject-2.0)
SRC = $(wildcard *.c)
OBJ = $(foreach obj, $(SRC:.c=.o), $(notdir $(obj)))
DEP = $(SRC:.c=.d)
POFILES = $(wildcard *.po)
CATALOGS = $(foreach cat, $(POFILES:.po=.mo), $(notdir $(cat)))
PREFIX ?= /usr/local
LOCALEDIR ?= $(PREFIX)/share/locale
PLUGINDIR ?= $(shell pkg-config --variable=plugindir pidgin)
DATADIR ?= $(shell pkg-config --variable=datadir pidgin)
-PBAR_VERSION ?= $(shell cat VERSION)
-
+PBAR_VERSION := $(shell cat VERSION)
CFLAGS += -DVERSION="\"$(PBAR_VERSION)\""
ifndef DISABLE_DEBUG
CFLAGS += -ggdb
endif
commit = $(shell ./hash.sh)
ifneq ($(commit), UNKNOWN)
CFLAGS += -DCOMMIT="\"$(commit)\""
endif
ifndef DISABLE_NLS
CFLAGS += -DENABLE_NLS=1 -DLOCALEDIR="\"$(LOCALEDIR)\""
locales := locales
install-locales := install-locales
uninstall-locales := uninstall-locales
endif
CFLAGS += -DDATADIR="\"$(DATADIR)\""
.PHONY: all clean
all: pbar.so $(locales)
pbar.so: $(OBJ)
$(CC) -shared -o $@ $^ $(LDFLAGS)
%.o: %.c
$(CC) -Wp,-MMD,$*.d -c $(CFLAGS) -o $@ $<
clean:
$(RM) $(DEP)
$(RM) $(OBJ)
$(RM) $(CATALOGS)
$(RM) messages.pot
$(RM) pbar.so
install: $(install-locales)
$(MKDIR) -p $(DESTDIR)$(PLUGINDIR)
$(INSTALL_PROGRAM) pbar.so $(DESTDIR)$(PLUGINDIR)
uninstall: $(uninstall-locales)
$(RM) $(PLUGINDIR)/pbar.so
locales: $(CATALOGS)
CAT_INST_PATH = $(foreach lang, $(POFILES:.po=), $(DESTDIR)$(LOCALEDIR)/$(lang)/LC_MESSAGES/pidgin-pbar.mo)
install-locales: $(CAT_INST_PATH)
$(DESTDIR)$(LOCALEDIR)/%/LC_MESSAGES/pidgin-pbar.mo: %.mo
$(MKDIR) -p $(DESTDIR)$(LOCALEDIR)/$(basename $<)/LC_MESSAGES
$(INSTALL_DATA) $< $@
uninstall-locales:
$(RM) $(CAT_INST_PATH)
%.mo: %.po
$(MSGFMT) -c -o $@ $<
messages.pot: POTFILES.in
$(XGETTEXT) --no-wrap -m -c --files-from $< --keyword --keyword=_ --keyword=N_ -o $@
-include $(DEP)
|
gawen947/pidgin-pbar
|
1f90552e384a7dcda0b32dc15a70059e674ad0cd
|
Use VERSION file to fill version information
|
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..bef10a1
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+0.3-git
diff --git a/makefile b/makefile
index dab7be3..d8d8763 100644
--- a/makefile
+++ b/makefile
@@ -1,81 +1,84 @@
include commands.mk
OPTS := -O2
CFLAGS := -std=c99 $(OPTS) $(shell pkg-config --cflags pidgin purple gtk+-2.0 gobject-2.0) -fPIC -Wall
LDFLAGS := $(shell pkg-config --libs pidgin purple gtk+-2.0 gobject-2.0)
SRC = $(wildcard *.c)
OBJ = $(foreach obj, $(SRC:.c=.o), $(notdir $(obj)))
DEP = $(SRC:.c=.d)
POFILES = $(wildcard *.po)
CATALOGS = $(foreach cat, $(POFILES:.po=.mo), $(notdir $(cat)))
PREFIX ?= /usr/local
LOCALEDIR ?= $(PREFIX)/share/locale
PLUGINDIR ?= $(shell pkg-config --variable=plugindir pidgin)
DATADIR ?= $(shell pkg-config --variable=datadir pidgin)
+PBAR_VERSION ?= $(shell cat VERSION)
+
+CFLAGS += -DVERSION="\"$(PBAR_VERSION)\""
ifndef DISABLE_DEBUG
CFLAGS += -ggdb
endif
commit = $(shell ./hash.sh)
ifneq ($(commit), UNKNOWN)
CFLAGS += -DCOMMIT="\"$(commit)\""
endif
ifndef DISABLE_NLS
CFLAGS += -DENABLE_NLS=1 -DLOCALEDIR="\"$(LOCALEDIR)\""
locales := locales
install-locales := install-locales
uninstall-locales := uninstall-locales
endif
CFLAGS += -DDATADIR="\"$(DATADIR)\""
.PHONY: all clean
all: pbar.so $(locales)
pbar.so: $(OBJ)
$(CC) -shared -o $@ $^ $(LDFLAGS)
%.o: %.c
$(CC) -Wp,-MMD,$*.d -c $(CFLAGS) -o $@ $<
clean:
$(RM) $(DEP)
$(RM) $(OBJ)
$(RM) $(CATALOGS)
$(RM) messages.pot
$(RM) pbar.so
install: $(install-locales)
$(MKDIR) -p $(DESTDIR)$(PLUGINDIR)
$(INSTALL_PROGRAM) pbar.so $(DESTDIR)$(PLUGINDIR)
uninstall: $(uninstall-locales)
$(RM) $(PLUGINDIR)/pbar.so
locales: $(CATALOGS)
CAT_INST_PATH = $(foreach lang, $(POFILES:.po=), $(DESTDIR)$(LOCALEDIR)/$(lang)/LC_MESSAGES/pidgin-pbar.mo)
install-locales: $(CAT_INST_PATH)
$(DESTDIR)$(LOCALEDIR)/%/LC_MESSAGES/pidgin-pbar.mo: %.mo
$(MKDIR) -p $(DESTDIR)$(LOCALEDIR)/$(basename $<)/LC_MESSAGES
$(INSTALL_DATA) $< $@
uninstall-locales:
$(RM) $(CAT_INST_PATH)
%.mo: %.po
$(MSGFMT) -c -o $@ $<
messages.pot: POTFILES.in
$(XGETTEXT) --no-wrap -m -c --files-from $< --keyword --keyword=_ --keyword=N_ -o $@
-include $(DEP)
diff --git a/pbar.h b/pbar.h
index 9543a0f..2a0c4ed 100644
--- a/pbar.h
+++ b/pbar.h
@@ -1,61 +1,60 @@
/* File: pbar.h
Time-stamp: <2010-11-15 23:55:36 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _PBAR_H_
#define _PBAR_H_
#include "common.h"
#ifndef G_GNUC_NULL_TERMINATED
# if __GNUC__ >= 4
# define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
# else
# define G_GNUC_NULL_TERMINATED
# endif /* __GNUC__ >= 4 */
#endif /* G_GNUC_NULL_TERMINATED */
/* name */
#define NAME "pbar" /* internal name */
#define DISP_NAME N_("PBar") /* displayed name */
-#define VERSION "0.3-git" /* current version */
/* plugin information */
#define PLUGIN_ID "gtk-" NAME /* gtk plugin id */
#define PLUGIN_NAME DISP_NAME
#ifndef COMMIT
# define PLUGIN_VERSION VERSION
#else
# define PLUGIN_VERSION VERSION " (commit:" COMMIT ")" /* add git commit
when available */
#endif
#define PLUGIN_SUMMARY N_("A toolbar to update some account settings " \
"globally.")
#define PLUGIN_DESCRIPTION N_("Adds a toolbar to the buddy list to quickly " \
"update nickname, personal message, icon, " \
"status and mood. It also allows updating of " \
"the current song and other parameters which " \
"are updated globally on all accounts that " \
"support them.")
#define PLUGIN_AUTHOR "David Hauweele <[email protected]>"
#define PLUGIN_WEBSITE "http://www.hauweele.net/~gawen/pidgin-pbar.html"
extern PurplePlugin *thisplugin;
#endif /* _PBAR_H_ */
|
gawen947/pidgin-pbar
|
121241ff6e7a50633e581313a25ce26d2285a1dc
|
Add in ChangeLog
|
diff --git a/ChangeLog b/ChangeLog
index 20d7e75..61e1d02 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,14 +1,16 @@
+ - Fix a bug in preference tooltip which state '%m' instead of '%p'
+
* Wed Jun 22 2011 David Hauweele <[email protected]>
- Fix cursor bug
- Fix makefile to ease packaging
- Fix compilation against Gtk 2.12
- Add features dialogs
- Add dialogs to change attributes through Pidgin's tools menu
- Change contact addresses
- Add tooltips to preferences dialog
- Disable features when no connected account supporting them
- Clean code
- Release 0.2
* Wed Jan 5 2010 David Hauweele <[email protected]>
- Release 0.1
|
gawen947/pidgin-pbar
|
ad28bcd84a1713626632d18f50e19eb5a077908e
|
Fix a bug in preference tooltip which state '%m' instead of '%p'
|
diff --git a/de.po b/de.po
index cb486ba..d51c40e 100644
--- a/de.po
+++ b/de.po
@@ -1,375 +1,375 @@
# Pidgin PBar German translation
# Copyright (C) 2010, Marleen Bekaert <[email protected]>
# This file is distributed under the same license as the Pidgin PBar package.
# Marleen Bekaert <[email protected]>, 2010
#
msgid ""
msgstr ""
"Project-Id-Version: nl\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-06-22 11:04+0200\n"
"PO-Revision-Date: 2011-06-22 12:40+0100\n"
"Last-Translator: Bekaert Marleen <[email protected]>\n"
"Language-Team: German <[email protected]>\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. name
#. internal name
#: pbar.h:36
msgid "PBar"
msgstr "PBar"
#: pbar.h:48
msgid "A toolbar to update some account settings globally."
msgstr "Eine Symbolleiste um manche Konto Einstellungen vollständig zu aktualisieren."
#: pbar.h:50
msgid "Adds a toolbar to the buddy list to quickly update nickname, personal message, icon, status and mood. It also allows updating of the current song and other parameters which are updated globally on all accounts that support them."
msgstr "Fügt eine Symbolleiste zu der Buddy-liste um schnell den Spitzname, den Persönlichen Bericht, die Ikone, den Status und die Stimmung schnell zu ändern. Erlaubt auch um das aktuelle Lied und anderen parameter die global aktualisiert werden auf alle Account die es ertragen ."
#. widgets that can possibly be modified along dialog lifetime
#: protocol_features.c:63
#: actions.c:92
msgid "Protocol features"
msgstr "Protokoll Funktionen"
#. widgets that are not modified
#: protocol_features.c:83
#: acct_features.c:84
msgid "Available features..."
msgstr "verfügbaren Funktionen..."
#: protocol_features.c:84
msgid "The following list shows the available features for each protocol."
msgstr "Die folgende Liste zeigt die verfügbaren Funktionen für jedes Protokoll."
#: protocol_features.c:100
msgid "Protocol"
msgstr "Protokoll"
#: protocol_features.c:116
#: acct_features.c:119
msgid "Nickname"
msgstr "Spitzname Tag"
#: protocol_features.c:117
#: acct_features.c:120
msgid "Status message"
msgstr "Status Nachricht"
#: protocol_features.c:118
#: acct_features.c:121
msgid "Buddy icon"
msgstr "Buddy Ikone"
#: protocol_features.c:119
#: acct_features.c:122
#: mood_dialog.c:133
msgid "Mood"
msgstr "Stimmung"
#: protocol_features.c:120
#: acct_features.c:123
msgid "Mood message"
msgstr "Stimmung Nachricht"
#: protocol_features.c:121
#: acct_features.c:124
msgid "Tune"
msgstr "Lied"
#: protocol_features.c:122
#: acct_features.c:125
msgid "Game"
msgstr "Spiel"
#: protocol_features.c:123
#: acct_features.c:126
msgid "App."
msgstr "App."
#. widgets that can possibly be modified along dialog lifetime
#: acct_features.c:64
#: actions.c:93
msgid "Account features"
msgstr "Konto Funktionen"
#: acct_features.c:85
msgid "The following list shows the available features for each activated account. The last line summarizes features that have an impact on at least one account."
msgstr "Die folgende Liste zeigt die verfügbaren Funktionen für jeden aktivierten Konto, die letzte Zeile fasst funktionen, die einen Einfluss auf mindestens ein konto haben."
#: acct_features.c:103
msgid "Account"
msgstr "Konto"
#. widgets that can be modifier along dialog lifetime
#: status_dialog.c:100
msgid "Status selection"
msgstr "Status Auswahl"
#. widgets that are not modified
#: status_dialog.c:115
msgid "Select your status..."
msgstr "Wählen Sie Ihren Satus ..."
#: status_dialog.c:116
msgid "This will change your current status for every account which supports it."
msgstr "ändernt ihr Spitzname für jedes Konto die es ertragt."
#: status_dialog.c:132
msgid "Status"
msgstr "Status"
#. widgets that can be modifier along dialog lifetime
#: mood_dialog.c:101
msgid "Mood selection"
msgstr "Stimmung Auswahl"
#. widgets that are not modified
#: mood_dialog.c:116
msgid "Select your mood..."
msgstr "Wählen Sie Ihre Stimmung..."
#: mood_dialog.c:117
msgid "This will change your mood for every account which supports it."
msgstr "ändernt ihre Stimmung für jedes Konto die es ertragt."
#: mood_dialog.c:201
#: mood_dialog.c:203
#: widget_gtk.c:276
msgid "None"
msgstr "Nichts"
#: preferences.c:50
msgid "Left"
msgstr "Linke"
#: preferences.c:51
msgid "Center"
msgstr "Mitte"
#: preferences.c:52
msgid "Right"
msgstr "Rechte"
#: preferences.c:58
msgid "Top"
msgstr "Oben"
#: preferences.c:59
msgid "Bottom"
msgstr "Unter"
#: preferences.c:131
msgid "_Nickname markup"
msgstr "_Spitzname Tag"
#: preferences.c:132
#, c-format
msgid "Change the markup used to display the nickname using the Pango Markup Language where %n is replaced with your nickname."
msgstr "ändert das Markup das verwendet wird um den Spitzname zu anzeigen mit der Pango Markup Language wo %n mit deinem Spitzname ersetzt ist."
#: preferences.c:135
msgid "Nickname markup _hovered"
msgstr "_Ãbergezwegt Spitzname Tag"
#: preferences.c:137
#, c-format
msgid "Change the markup used to display the nickname when hovered by the mouse using the Pango Markup Language where %n is replaced with your nickname."
msgstr "ändert das Markup das verwendet wird um den Spitzname zu anzeigen wenn überzwegt mit der Maus, mit der Pango Markup Language wo %n mit deinem Spitzname ersetzt ist."
#: preferences.c:141
msgid "Personal _message markup"
msgstr "Persönliche _Nachricht Tag"
#: preferences.c:143
#, c-format
-msgid "Change the markup used to display the personal message using the Pango Markup Language where %m is replaced with your personal message."
-msgstr "ändert das markup das verwendet wird um die persönliche Nachricht zu anzeigen, mit der Pango Markup Language wo %m mit deiner persönliche Nachricht ersetzt ist."
+msgid "Change the markup used to display the personal message using the Pango Markup Language where %p is replaced with your personal message."
+msgstr "ändert das markup das verwendet wird um die persönliche Nachricht zu anzeigen, mit der Pango Markup Language wo %p mit deiner persönliche Nachricht ersetzt ist."
#: preferences.c:147
msgid "Personal message markup _hovered"
msgstr "_Ãbergezwegd persönliche Nachricht Tag"
#: preferences.c:149
#, c-format
msgid "Change the markup used to display the personal message when hovered by the mouse using the Pango Markup Language where %m is replaced with your personal message."
msgstr "ändert das Markup das verwendet wird um die persönliche Nachrict zu anzeigen wenn überzwegt mit der Maus, mit der Pango Markup Language wo %m mit deiner persönliche Nachricht."
#: preferences.c:164
msgid "Align _nickname"
msgstr "Spitzname_ausrichten"
#: preferences.c:166
msgid "Alignment of the nickname into the bar."
msgstr "Ausrichtung der Spitzname in der Bar."
#: preferences.c:168
msgid "Align personal _message"
msgstr "_Persönliche Nachricht ausrichten"
#: preferences.c:170
msgid "Alignment of the personal message into the bar."
msgstr "Aurichtung der persönliche Nachricht in die Bar."
#: preferences.c:172
msgid "Widget _position in the buddy list"
msgstr "Widget _Lage in den buddy-Liste"
#: preferences.c:174
msgid "Position of the widget into pidgin's buddy list."
msgstr "Lage des Widget in Pidgin-Buddy-Liste."
#: preferences.c:181
msgid "Hide _statusbox"
msgstr "_Statusbox verbergen"
#: preferences.c:182
msgid "Show or hide the Pidgin's default statusbox."
msgstr "Show or hide the Pidgin's default statusbox."
#: preferences.c:184
msgid "_Ignore status changes"
msgstr "_Ignoriert Status anderungen"
#: preferences.c:185
msgid "Ignore changes made to status from outside the widget. This include changes made in Pidgin's default statusbox and other plugins."
msgstr "Ignoriert änderungen zu Status von auÃerhalb des Widgets gemacht, inbegriffen änderungen in Pidgin standarmäÃige statusbox und andere Plugins gemacht."
#: preferences.c:189
msgid "Use a frame for _entry"
msgstr "Nutz ein ein Rahmen für Textinput"
#: preferences.c:190
msgid "Enable or disable the use of a frame around the entries when editing the nickname or personal message from the bar."
msgstr "Enable or disable the use of a frame around the entries when editing the nickname or personal message from the bar."
#: preferences.c:193
msgid "_Swap left and right click"
msgstr "_Dreht linke und rechte klik um"
#: preferences.c:194
msgid "Swap the role of left and right click to edit the nickname or personal message in the bar."
msgstr "Dreht die Rolle von links und rechts Klik um den Spitzname oder persönliche Nachricht in der Bar zu bearbeiten."
#: preferences.c:197
msgid "Use a _compact bar"
msgstr "Benutz ein kompakt Balken"
#: preferences.c:198
msgid "Reduce the size of the widget putting the nickname and personal message on one line."
msgstr "Reduziert die gröÃe des Widgets und setz den Spitzname und die persönliche Nachricht auf einer Linie."
#: preferences.c:201
msgid "_Reset status messages"
msgstr "_Rûcksetz Status Berichten"
#: preferences.c:202
msgid "Clear the status messages when Pidgin restart (except for personal message). By default these messages are saved in the preferences and reactivated when pidgin restart."
msgstr "Klar die Status nachrichten wenn pidgin neustart (auÃerhalb für persönliche Nacxhrichten). StandarmäÃig werden diese Nachrichten in die Präferenzen gespeichert und neuaktiviert wenn Pidgin neustart."
#. preferences
#. preference root
#. empty messages to display at first installation
#: preferences.h:33
msgid "<Enter nickname here>"
msgstr "<hier Spitzname einführen>"
#: preferences.h:34
msgid "<Enter personal message here>"
msgstr "<Hier persönlich nachricht einführen>"
#: actions.c:87
#: widget.c:309
msgid "Change nickname"
msgstr "ändernt Spitzname"
#: actions.c:88
msgid "Change personal message"
msgstr "Persönliche Nachricht ausrichten"
#: actions.c:89
msgid "Change status"
msgstr "ändernt Status Nachricht"
#: actions.c:90
msgid "Change mood"
msgstr "ändernt Stimmung"
#: actions.c:91
msgid "Change icon"
msgstr "ändernt Ikone"
#: widget.c:310
msgid "Enter your nickname here..."
msgstr "Hier Spitzname einführen..."
#: widget.c:311
msgid "This will change your nickname for every account which supports it."
msgstr "ändernt ihr Spitzname für jeder Account die es ertragen."
#: widget.c:317
#: widget.c:531
msgid "OK"
msgstr "OK"
#: widget.c:319
#: widget.c:533
msgid "Cancel"
msgstr "Annulieren"
#: widget.c:476
msgid "_Mood message"
msgstr "_Stimmung Nachricht"
#: widget.c:477
msgid "Current song"
msgstr "Aktuel lied"
#: widget.c:478
msgid "Song _title"
msgstr "lied _Titel"
#: widget.c:479
msgid "Song _artist"
msgstr "Lied _Künstler"
#: widget.c:480
msgid "Song al_bum"
msgstr "Lied Al_bum"
#: widget.c:481
msgid "MSN pecan extra attributes"
msgstr "MSN pecan extra Parameter"
#: widget.c:482
msgid "_Game name"
msgstr "_Spiel Name"
#: widget.c:483
msgid "_Office app name"
msgstr "_Office app Name"
#: widget.c:489
msgid "Status and mood message"
msgstr "Status und Stimmung Nachricht"
#: widget.c:494
msgid "_Personal message"
msgstr "_Persönliche Nachricht"
#: widget.c:525
msgid "Change status messages"
msgstr "ändernt Status Nachricht"
#: widget.c:526
msgid "Enter status message..."
msgstr "führt Status Nachricht ein..."
#: widget.c:527
msgid "This will change some status messages for every account which supports it, please be advised that some are inconsistent between each other."
msgstr "ändernt einige Status Nachrichten für jeder Account die es ertragt, Bitte beachten Sie dass einige inkonsistent sind untereinander."
diff --git a/fr.po b/fr.po
index 6954484..8035489 100644
--- a/fr.po
+++ b/fr.po
@@ -1,375 +1,375 @@
# Pidgin PBar French translation.
# Copyright (C) 2010, David Hauweele <[email protected]>
# This file is distributed under the same license as the Pidgin PBar package.
# David Hauweele <[email protected]>, 2010.
#
msgid ""
msgstr ""
"Project-Id-Version: fr\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-06-18 01:09+0200\n"
"PO-Revision-Date: 2011-06-18 01:13+0100\n"
"Last-Translator: David Hauweele <[email protected]>\n"
"Language-Team: French <[email protected]>\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. name
#. internal name
#: pbar.h:36
msgid "PBar"
msgstr "PBar"
#: pbar.h:48
msgid "A toolbar to update some account settings globally."
msgstr "Une barre d'outils pour mettre à jour certains paramètres de manière globale."
#: pbar.h:50
msgid "Adds a toolbar to the buddy list to quickly update nickname, personal message, icon, status and mood. It also allows updating of the current song and other parameters which are updated globally on all accounts that support them."
msgstr "Ajoute une barre d'outils à la liste de contacts pour rapidement mettre à jour le pseudonyme, le message personnel, l'icône, le status et l'humeur. Il permet également de mettre à jour le morceau actuel et d'autres paramètres qui sont mis à jours de manière globale sur tous les comptes qui les supportent."
#. widgets that can possibly be modified along dialog lifetime
#: protocol_features.c:63
#: actions.c:92
msgid "Protocol features"
msgstr "Fonctionnalités du protocole"
#. widgets that are not modified
#: protocol_features.c:83
#: acct_features.c:84
msgid "Available features..."
msgstr "Fonctionnalités disponibles..."
#: protocol_features.c:84
msgid "The following list shows the available features for each protocol."
msgstr "La liste suivante montre les fonctionnalités disponibles pour chaque protocole."
#: protocol_features.c:100
msgid "Protocol"
msgstr "Protocole"
#: protocol_features.c:116
#: acct_features.c:119
msgid "Nickname"
msgstr "Pseudonyme"
#: protocol_features.c:117
#: acct_features.c:120
msgid "Status message"
msgstr "Message personnel"
#: protocol_features.c:118
#: acct_features.c:121
msgid "Buddy icon"
msgstr "Icône"
#: protocol_features.c:119
#: acct_features.c:122
#: mood_dialog.c:133
msgid "Mood"
msgstr "Humeur"
#: protocol_features.c:120
#: acct_features.c:123
msgid "Mood message"
msgstr "Message pour l'humeur"
#: protocol_features.c:121
#: acct_features.c:124
msgid "Tune"
msgstr "Musique"
#: protocol_features.c:122
#: acct_features.c:125
msgid "Game"
msgstr "Jeu"
#: protocol_features.c:123
#: acct_features.c:126
msgid "App."
msgstr "Application"
#. widgets that can possibly be modified along dialog lifetime
#: acct_features.c:64
#: actions.c:93
msgid "Account features"
msgstr "Fonctionnalités du compte"
#: acct_features.c:85
msgid "The following list shows the available features for each activated account. The last line summarizes features that have an impact on at least one account."
msgstr "La liste suivante montre les fonctionnalités disponibles pour tous les comptes activés. La dernière ligne résume les fonctionnalités concernées par au moins un compte."
#: acct_features.c:103
msgid "Account"
msgstr "Compte"
#. widgets that can be modifier along dialog lifetime
#: status_dialog.c:100
msgid "Status selection"
msgstr "Choix du status"
#. widgets that are not modified
#: status_dialog.c:115
msgid "Select your status..."
msgstr "Choisissez votre status..."
#: status_dialog.c:116
msgid "This will change your current status for every account which supports it."
msgstr "Cela va changer votre status pour tous les comptes qui le supportent."
#: status_dialog.c:132
msgid "Status"
msgstr "Status"
#. widgets that can be modifier along dialog lifetime
#: mood_dialog.c:101
msgid "Mood selection"
msgstr "Choix de l'humeur"
#. widgets that are not modified
#: mood_dialog.c:116
msgid "Select your mood..."
msgstr "Choisissez votre humeur..."
#: mood_dialog.c:117
msgid "This will change your mood for every account which supports it."
msgstr "Cela va changer votre humeur pour tous les comptes qui le supportent."
#: mood_dialog.c:201
#: mood_dialog.c:203
#: widget_gtk.c:276
msgid "None"
msgstr "Aucun"
#: preferences.c:50
msgid "Left"
msgstr "Gauche"
#: preferences.c:51
msgid "Center"
msgstr "Centre"
#: preferences.c:52
msgid "Right"
msgstr "Droite"
#: preferences.c:58
msgid "Top"
msgstr "Haut"
#: preferences.c:59
msgid "Bottom"
msgstr "Bas"
#: preferences.c:131
msgid "_Nickname markup"
msgstr "Balise du _pseudonyme"
#: preferences.c:132
#, c-format
msgid "Change the markup used to display the nickname using the Pango Markup Language where %n is replaced with your nickname."
msgstr "Change la balise utilisée pour afficher le pseudo en utilisant le Pango Markup Language où %n qui est remplacé par votre pseudonyme."
#: preferences.c:135
msgid "Nickname markup _hovered"
msgstr "Balise du pseudonyme _survolé"
#: preferences.c:137
#, c-format
msgid "Change the markup used to display the nickname when hovered by the mouse using the Pango Markup Language where %n is replaced with your nickname."
msgstr "Change la balise utilisée pour afficher le pseudonyme quand il est survolé par la souris en utilisant le Pango Markup Language où %n est remplacé par votre pseudonyme."
#: preferences.c:141
msgid "Personal _message markup"
msgstr "Balise du _message personnel"
#: preferences.c:143
#, c-format
-msgid "Change the markup used to display the personal message using the Pango Markup Language where %m is replaced with your personal message."
-msgstr "Change la balise utilisée pour afficher le message personnel en utilisant le Pango Markup Language où %m est remplacé par votre message personnel."
+msgid "Change the markup used to display the personal message using the Pango Markup Language where %p is replaced with your personal message."
+msgstr "Change la balise utilisée pour afficher le message personnel en utilisant le Pango Markup Language où %p est remplacé par votre message personnel."
#: preferences.c:147
msgid "Personal message markup _hovered"
msgstr "Balise du message personnel _survolé"
#: preferences.c:149
#, c-format
-msgid "Change the markup used to display the personal message when hovered by the mouse using the Pango Markup Language where %m is replaced with your personal message."
-msgstr "Change la balise utilisée pour afficher le message personnel quand celui-ci est survolé par la souris en utilisant le Pango Markup Language où %m est remplacé par votre message personnel."
+msgid "Change the markup used to display the personal message when hovered by the mouse using the Pango Markup Language where %p is replaced with your personal message."
+msgstr "Change la balise utilisée pour afficher le message personnel quand celui-ci est survolé par la souris en utilisant le Pango Markup Language où %p est remplacé par votre message personnel."
#: preferences.c:164
msgid "Align _nickname"
msgstr "Aligner le _pseudonyme"
#: preferences.c:166
msgid "Alignment of the nickname into the bar."
msgstr "Alignement du pseudonyme dans la barre."
#: preferences.c:168
msgid "Align personal _message"
msgstr "Aligner le _message personnel"
#: preferences.c:170
msgid "Alignment of the personal message into the bar."
msgstr "Alignement du message personnel dans la barre."
#: preferences.c:172
msgid "Widget _position in the buddy list"
msgstr "_Position de la barre dans la liste de contacts"
#: preferences.c:174
msgid "Position of the widget into pidgin's buddy list."
msgstr "Position de la barre dans la liste de contacts de Pidgin."
#: preferences.c:181
msgid "Hide _statusbox"
msgstr "Cacher le sélecteur d'é_tats"
#: preferences.c:182
msgid "Show or hide the Pidgin's default statusbox."
msgstr "Affiche ou cache le sélecteur d'états par défaut de Pidgin."
#: preferences.c:184
msgid "_Ignore status changes"
msgstr "_Ignorer les changements d'états"
#: preferences.c:185
msgid "Ignore changes made to status from outside the widget. This include changes made in Pidgin's default statusbox and other plugins."
msgstr "Ignorer les changements d'états hors du plugin. Ceci inclut les changements apportés depuis le sélecteur d'états par défaut de Pidgin et d'autres plugins."
#: preferences.c:189
msgid "Use a frame for _entry"
msgstr "Utiliser un _cadre"
#: preferences.c:190
msgid "Enable or disable the use of a frame around the entries when editing the nickname or personal message from the bar."
msgstr "Active ou désactive l'utilisation d'un cadre autour des entrées lors de l'édition du pseudonyme ou du message personnel."
#: preferences.c:193
msgid "_Swap left and right click"
msgstr "_Inverser le clique gauche et droit"
#: preferences.c:194
msgid "Swap the role of left and right click to edit the nickname or personal message in the bar."
msgstr "Inverse les rôles du clique gauche et droit dans l'édition du pseudonyme et du message personnel."
#: preferences.c:197
msgid "Use a _compact bar"
msgstr "Utiliser une barre _compacte"
#: preferences.c:198
msgid "Reduce the size of the widget putting the nickname and personal message on one line."
msgstr "Réduit la taille de la barre en plaçant le pseudonyme et le message personnel sur une ligne."
#: preferences.c:201
msgid "_Reset status messages"
msgstr "Réinitialiser les messages d'état"
#: preferences.c:202
msgid "Clear the status messages when Pidgin restart (except for personal message). By default these messages are saved in the preferences and reactivated when pidgin restart."
msgstr "Efface les messages quand Pidgin redémarre (sauf pour le message personnel). Par défaut ces messages sont sauvegardés dans les préférences et activés de nouveau quand Pidgin se lance."
#. preferences
#. preference root
#. empty messages to display at first installation
#: preferences.h:33
msgid "<Enter nickname here>"
msgstr "<Entrez votre pseudonyme ici>"
#: preferences.h:34
msgid "<Enter personal message here>"
msgstr "<Entrez votre message personnel ici>"
#: actions.c:87
#: widget.c:309
msgid "Change nickname"
msgstr "Changer le pseudonyme"
#: actions.c:88
msgid "Change personal message"
msgstr "Changer le message personnel"
#: actions.c:89
msgid "Change status"
msgstr "Changer le status"
#: actions.c:90
msgid "Change mood"
msgstr "Changer l'humeur"
#: actions.c:91
msgid "Change icon"
msgstr "Changer l'icône"
#: widget.c:310
msgid "Enter your nickname here..."
msgstr "Entrez votre pseudonyme ici..."
#: widget.c:311
msgid "This will change your nickname for every account which supports it."
msgstr "Cela va changer votre pseudonyme pour tous les comptes qui le supportent."
#: widget.c:317
#: widget.c:531
msgid "OK"
msgstr "OK"
#: widget.c:319
#: widget.c:533
msgid "Cancel"
msgstr "_Annuler"
#: widget.c:476
msgid "_Mood message"
msgstr "Message pour l'_humeur"
#: widget.c:477
msgid "Current song"
msgstr "Morceau actuel"
#: widget.c:478
msgid "Song _title"
msgstr "_Titre"
#: widget.c:479
msgid "Song _artist"
msgstr "_Artiste"
#: widget.c:480
msgid "Song al_bum"
msgstr "_Album"
#: widget.c:481
msgid "MSN pecan extra attributes"
msgstr "Options supplémentaires pour MSN pecan"
#: widget.c:482
msgid "_Game name"
msgstr "_Jeu actuel"
#: widget.c:483
msgid "_Office app name"
msgstr "_Application"
#: widget.c:489
msgid "Status and mood message"
msgstr "Message d'états et d'humeur"
#: widget.c:494
msgid "_Personal message"
msgstr "Message _personnel"
#: widget.c:525
msgid "Change status messages"
msgstr "Changer le message d'état"
#: widget.c:526
msgid "Enter status message..."
msgstr "Entrez votre message d'état..."
#: widget.c:527
msgid "This will change some status messages for every account which supports it, please be advised that some are inconsistent between each other."
msgstr "Cela va changer certains messages d'états pour tous les comptes qui le supportent, notez toutefois que certains sont incompatibles entre eux."
diff --git a/nl.po b/nl.po
index 78365f8..9e66505 100644
--- a/nl.po
+++ b/nl.po
@@ -1,375 +1,375 @@
# Pidgin PBar Dutch translation
# Copyright (C) 2010, Marleen Bekaert <[email protected]>
# This file is distributed under the same license as the Pidgin PBar package.
# Marleen Bekaert <[email protected]>, 2010
#
msgid ""
msgstr ""
"Project-Id-Version: nl\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-06-21 21:21+0200\n"
"PO-Revision-Date: 2011-06-21 22:53+0100\n"
"Last-Translator: Bekaert Marleen <[email protected]>\n"
"Language-Team: Dutch <[email protected]>\n"
"Language: nl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. name
#. internal name
#: pbar.h:36
msgid "PBar"
msgstr "PBar"
#: pbar.h:48
msgid "A toolbar to update some account settings globally."
msgstr "Een werkbalk om sommige account instellingen globaal te actualiseren."
#: pbar.h:50
msgid "Adds a toolbar to the buddy list to quickly update nickname, personal message, icon, status and mood. It also allows updating of the current song and other parameters which are updated globally on all accounts that support them."
msgstr "Voegt een werkbalk aan de contact lijst om vlug bijnaam, persoonlijk bericht, icoon, status en humeur te actualiseren. Het laat ook toe om het huidig lied en andere parameters die globaal actualiseerd zijn op alle accounts die het verdragen."
#. widgets that can possibly be modified along dialog lifetime
#: protocol_features.c:63
#: actions.c:92
msgid "Protocol features"
msgstr "Protocol bekwaamheden"
#. widgets that are not modified
#: protocol_features.c:83
#: acct_features.c:84
msgid "Available features..."
msgstr "Beschikbaare bekwaamheden..."
#: protocol_features.c:84
msgid "The following list shows the available features for each protocol."
msgstr "De volgende lijst toont de beschikbaare bekwaamheden voor iedere protocol."
#: protocol_features.c:100
msgid "Protocol"
msgstr "Protocol"
#: protocol_features.c:116
#: acct_features.c:119
msgid "Nickname"
msgstr "Bijnaam"
#: protocol_features.c:117
#: acct_features.c:120
msgid "Status message"
msgstr "Status bericht"
#: protocol_features.c:118
#: acct_features.c:121
msgid "Buddy icon"
msgstr "Contacten icoon"
#: protocol_features.c:119
#: acct_features.c:122
#: mood_dialog.c:133
msgid "Mood"
msgstr "Humeur"
#: protocol_features.c:120
#: acct_features.c:123
msgid "Mood message"
msgstr "Humeur bericht"
#: protocol_features.c:121
#: acct_features.c:124
msgid "Tune"
msgstr "Lied"
#: protocol_features.c:122
#: acct_features.c:125
msgid "Game"
msgstr "Spel"
#: protocol_features.c:123
#: acct_features.c:126
msgid "App."
msgstr "App."
#. widgets that can possibly be modified along dialog lifetime
#: acct_features.c:64
#: actions.c:93
msgid "Account features"
msgstr "Account bekwaamheden"
#: acct_features.c:85
msgid "The following list shows the available features for each activated account. The last line summarizes features that have an impact on at least one account."
msgstr "De volgende lijst toont the beschikbaare bekwaamheden voor iedere geactiveerde account. De laatste lijn vat de bekwaamheden samen die een effect hebben op ten minste een account."
#: acct_features.c:103
msgid "Account"
msgstr "Account"
#. widgets that can be modifier along dialog lifetime
#: status_dialog.c:100
msgid "Status selection"
msgstr "Status selectie"
#. widgets that are not modified
#: status_dialog.c:115
msgid "Select your status..."
msgstr "Selecteer uw status..."
#: status_dialog.c:116
msgid "This will change your current status for every account which supports it."
msgstr "Dat zal U lopend status veranderen voor iedere account die het verdraagt."
#: status_dialog.c:132
msgid "Status"
msgstr "Status"
#. widgets that can be modifier along dialog lifetime
#: mood_dialog.c:101
msgid "Mood selection"
msgstr "Humeur selectie"
#. widgets that are not modified
#: mood_dialog.c:116
msgid "Select your mood..."
msgstr "Selecteer uw humeur..."
#: mood_dialog.c:117
msgid "This will change your mood for every account which supports it."
msgstr "Dat zal U humeur veranderen vor iedere account die het verdraagt."
#: mood_dialog.c:201
#: mood_dialog.c:203
#: widget_gtk.c:276
msgid "None"
msgstr "Niets"
#: preferences.c:50
msgid "Left"
msgstr "Links"
#: preferences.c:51
msgid "Center"
msgstr "Midden"
#: preferences.c:52
msgid "Right"
msgstr "Rechts"
#: preferences.c:58
msgid "Top"
msgstr "Boven"
#: preferences.c:59
msgid "Bottom"
msgstr "Beneden"
#: preferences.c:131
msgid "_Nickname markup"
msgstr "_Bijnaam baken"
#: preferences.c:132
#, c-format
msgid "Change the markup used to display the nickname using the Pango Markup Language where %n is replaced with your nickname."
msgstr "Veranderd het baken die gebruikt werd om de bijnaam te displayen, door het gebruiken van de Pango Markup Language waar %n vervangen word door uw bijnaam."
#: preferences.c:135
msgid "Nickname markup _hovered"
msgstr "Bijnaam baken _overgezweefd"
#: preferences.c:137
#, c-format
msgid "Change the markup used to display the nickname when hovered by the mouse using the Pango Markup Language where %n is replaced with your nickname."
msgstr "Veranderd het baken die gebruikt werd om de bijnaam te displayen wanneer men er met de muis overzweefd, door het gebruiken van de Pango Markup language waar %n vervangen word door uw bijnaam."
#: preferences.c:141
msgid "Personal _message markup"
msgstr "Persoonlijk _bericht baken"
#: preferences.c:143
#, c-format
-msgid "Change the markup used to display the personal message using the Pango Markup Language where %m is replaced with your personal message."
-msgstr "veranderd het baken die gebruikt werd om het persoonlijk bericht te displayen, door het gebruiken van de Pango Markup Language waar %m vervangen word door uw persoonlijk bericht."
+msgid "Change the markup used to display the personal message using the Pango Markup Language where %p is replaced with your personal message."
+msgstr "veranderd het baken die gebruikt werd om het persoonlijk bericht te displayen, door het gebruiken van de Pango Markup Language waar %p vervangen word door uw persoonlijk bericht."
#: preferences.c:147
msgid "Personal message markup _hovered"
msgstr "Persoonlijk bericht baken _overgezweefd"
#: preferences.c:149
#, c-format
-msgid "Change the markup used to display the personal message when hovered by the mouse using the Pango Markup Language where %m is replaced with your personal message."
-msgstr "Veranderd het baken die gebruikt werd om het persoonlijk bericht te displayen wanneer men er met de muis overzweefd, door het gebruiken van de Pango Markup Language waar %m vervangen word door uw persoonlijke bericht."
+msgid "Change the markup used to display the personal message when hovered by the mouse using the Pango Markup Language where %p is replaced with your personal message."
+msgstr "Veranderd het baken die gebruikt werd om het persoonlijk bericht te displayen wanneer men er met de muis overzweefd, door het gebruiken van de Pango Markup Language waar %p vervangen word door uw persoonlijke bericht."
#: preferences.c:164
msgid "Align _nickname"
msgstr "Richten _bijnaam"
#: preferences.c:166
msgid "Alignment of the nickname into the bar."
msgstr "Alignment of the nickname into the bar."
#: preferences.c:168
msgid "Align personal _message"
msgstr "Richten persoonlijk _bericht"
#: preferences.c:170
msgid "Alignment of the personal message into the bar."
msgstr "Het zetten van het persoonlijk bericht in de balk"
#: preferences.c:172
msgid "Widget _position in the buddy list"
msgstr "Werkbalk _positie in contactlijst"
#: preferences.c:174
msgid "Position of the widget into pidgin's buddy list."
msgstr "Positie van de werkbalk in Pidgin contactlijst."
#: preferences.c:181
msgid "Hide _statusbox"
msgstr "Verberg _statusbox"
#: preferences.c:182
msgid "Show or hide the Pidgin's default statusbox."
msgstr "Toon of verberg Pidgins bij verstek statusbox."
#: preferences.c:184
msgid "_Ignore status changes"
msgstr "_Negeren van status negeren"
#: preferences.c:185
msgid "Ignore changes made to status from outside the widget. This include changes made in Pidgin's default statusbox and other plugins."
msgstr "Negeer de veranderingen van de status als ze van buiten de balk gemaakt zijn, dit omvat veranderingen gemaakt in Pidgins bij verstek statusbox en andere plugins."
#: preferences.c:189
msgid "Use a frame for _entry"
msgstr "Gebruik een kader voor _textinvoer"
#: preferences.c:190
msgid "Enable or disable the use of a frame around the entries when editing the nickname or personal message from the bar."
msgstr "Stelt of schakelt het gebruik van een kader uit rond de invoer van de balk wanneer men de bijnaam of het persoolijk bericht bewerkt."
#: preferences.c:193
msgid "_Swap left and right click"
msgstr "_Keer linkse and rechtse klik om"
#: preferences.c:194
msgid "Swap the role of left and right click to edit the nickname or personal message in the bar."
msgstr "Keer de rol van linkse en rechtse klik om de bijnaam of persoonlijk bericht te bewerken in de balk."
#: preferences.c:197
msgid "Use a _compact bar"
msgstr "gebruikt een _compacte balk"
#: preferences.c:198
msgid "Reduce the size of the widget putting the nickname and personal message on one line."
msgstr "Verminderd de maat van de werkbalk door de bijnaam en persoonlijn bericht op een lijn te zetten."
#: preferences.c:201
msgid "_Reset status messages"
msgstr "_Opmaak status berichten"
#: preferences.c:202
msgid "Clear the status messages when Pidgin restart (except for personal message). By default these messages are saved in the preferences and reactivated when pidgin restart."
msgstr "Wiss de status berichten uit wanneer Pidgin herstart (uitgezonderd voor het persoonlijk bericht), bij verstek worden deze berichten opgeslagen in de voorkeuren en gereactiveerd als Pidgin terug opstart."
#. preferences
#. preference root
#. empty messages to display at first installation
#: preferences.h:33
msgid "<Enter nickname here>"
msgstr "<Hier bijnaam invoeren>"
#: preferences.h:34
msgid "<Enter personal message here>"
msgstr "<Hier persoonlijk bericht iuvoeren>"
#: actions.c:87
#: widget.c:309
msgid "Change nickname"
msgstr "Veranderd bijnaam"
#: actions.c:88
msgid "Change personal message"
msgstr "Richten persoonlijk bericht"
#: actions.c:89
msgid "Change status"
msgstr "Veranderd status"
#: actions.c:90
msgid "Change mood"
msgstr "Veranderd humeur"
#: actions.c:91
msgid "Change icon"
msgstr "Veranderd icoon"
#: widget.c:310
msgid "Enter your nickname here..."
msgstr "Hier U bijnaam invoeren..."
#: widget.c:311
msgid "This will change your nickname for every account which supports it."
msgstr "Dat zal U bijnaam veranderen vor iedere account die het verdraagt."
#: widget.c:317
#: widget.c:531
msgid "OK"
msgstr "OK"
#: widget.c:319
#: widget.c:533
msgid "Cancel"
msgstr "Annuleren"
#: widget.c:476
msgid "_Mood message"
msgstr "_Humeur bericht"
#: widget.c:477
msgid "Current song"
msgstr "Huidig lied"
#: widget.c:478
msgid "Song _title"
msgstr "Lied _tijtel"
#: widget.c:479
msgid "Song _artist"
msgstr "Lied _artiest"
#: widget.c:480
msgid "Song al_bum"
msgstr "Lied al_bum"
#: widget.c:481
msgid "MSN pecan extra attributes"
msgstr "MSN pecan extra parameters"
#: widget.c:482
msgid "_Game name"
msgstr "_Spelnaam"
#: widget.c:483
msgid "_Office app name"
msgstr "_Office app naam"
#: widget.c:489
msgid "Status and mood message"
msgstr "Status en humeur bericht"
#: widget.c:494
msgid "_Personal message"
msgstr "_Persoonlijk bericht"
#: widget.c:525
msgid "Change status messages"
msgstr "Veranderd status berichten"
#: widget.c:526
msgid "Enter status message..."
msgstr "Voert Status berichten in..."
#: widget.c:527
msgid "This will change some status messages for every account which supports it, please be advised that some are inconsistent between each other."
msgstr "Dat zal sommige status berichten veranderen voor iedere account die het verdraagt, houd er a.u.b rekening mee dat sommige inconsequent zijn tussen elkaar."
diff --git a/preferences.c b/preferences.c
index e25f7e9..debf7f1 100644
--- a/preferences.c
+++ b/preferences.c
@@ -1,425 +1,425 @@
/* File: prefs.c
Time-stamp: <2011-06-17 05:03:03 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "preferences.h"
#include "widget.h"
/* callback for preferences setting which set preferences and
update interface when needed */
static void cb_nickname_markup(GtkWidget *widget, gpointer data);
static void cb_nickname_markup_hover(GtkWidget *widget, gpointer data);
static void cb_personal_message_markup(GtkWidget *widget, gpointer data);
static void cb_personal_message_markup_hover(GtkWidget *widget, gpointer data);
static void cb_hide_statusbox(GtkWidget *widget, gpointer data);
static void cb_override_status(GtkWidget *widget, gpointer data);
static void cb_nickname_justify(GtkWidget *widget, gpointer data);
static void cb_personal_message_justify(GtkWidget *widget, gpointer data);
static void cb_compact(GtkWidget *widget, gpointer data);
static void cb_frame_entry(GtkWidget *widget, gpointer data);
static void cb_swap_click(GtkWidget *widget, gpointer data);
static void cb_reset_attrs(GtkWidget *widget, gpointer data);
static void cb_widget_position(GtkWidget *widget, gpointer data);
/* the following structures are defined here as global
since they are needed in combobox callback */
/* alias we will use for combobox */
static const struct i_alias {
const char *alias;
int value;
} alias_justify[] = {
{ N_("Left"), JUSTIFY_LEFT },
{ N_("Center"), JUSTIFY_CENTER },
{ N_("Right"), JUSTIFY_RIGHT },
{ NULL, 0 }
};
/* widget position in the buddy list */
static const struct i_alias alias_position[] = {
{ N_("Top"), POSITION_TOP },
{ N_("Bottom"), POSITION_BOTTOM },
{ NULL, 0 }
};
/* init preferences and set default values */
void init_prefs()
{
/* string preferences and default value */
const struct prefs_string {
const char *name;
const char *value;
} prefs_add_string[] = {
{ PREF "/personal-message-markup-hover", "<span color=\"DarkOliveGreen4\"><small><i>%p</i></small></span>" },
{ PREF "/personal-message-markup", "<small>%p</small>" },
{ PREF "/nickname-markup-hover", "<span color=\"DarkOliveGreen4\"><b>%n</b></span>" },
{ PREF "/nickname-markup", "<b>%n</b>" },
{ PREF "/personal-message", EMPTY_PM },
{ PREF "/tune-title", "" },
{ PREF "/tune-artist", "" },
{ PREF "/tune-album", "" },
{ PREF "/game-message", "" },
{ PREF "/office-message", "" },
{ PREF "/nickname", EMPTY_NAME },
{ PREF "/mood-message", "" },
{ PREF "/mood", "" },
{ NULL, NULL }
}; const struct prefs_string *s = prefs_add_string;
/* boolean preferences and default value */
const struct prefs_bool {
const char *name;
gboolean value;
} prefs_add_bool[] = {
{ PREF "/hide-statusbox", TRUE },
{ PREF "/override-status", FALSE },
{ PREF "/frame-entry", TRUE },
{ PREF "/swap-click", FALSE },
{ PREF "/reset-attrs", FALSE },
{ PREF "/compact", FALSE },
{ NULL, FALSE }
}; const struct prefs_bool *b = prefs_add_bool;
/* integer preferences and default value */
const struct prefs_int {
const char *name;
int value;
} prefs_add_int[] = {
{ PREF "/nickname-justify", JUSTIFY_LEFT },
{ PREF "/personal-message-justify", JUSTIFY_LEFT },
{ PREF "/widget-position", POSITION_TOP },
{ NULL, 0 }
}; const struct prefs_int *i = prefs_add_int;
/* add preferences */
purple_prefs_add_none(PREF);
for(; s->name ; s++)
purple_prefs_add_string(s->name, s->value);
for(; b->name ; b++)
purple_prefs_add_bool(b->name, b->value);
for(; i->name ; i++)
purple_prefs_add_int(i->name, i->value);
}
GtkWidget * get_config_frame(PurplePlugin *plugin)
{
/* entry widgets label, associated preference and callback */
const struct widget {
const char *name;
const char *prefs;
void (*callback)(GtkWidget *, gpointer);
const char *tooltip;
} entry[] = {
{ N_("_Nickname markup"), PREF "/nickname-markup", cb_nickname_markup,
N_("Change the markup used to display the nickname using the "
"Pango Markup Language where %n is replaced with your nickname.") },
{ N_("Nickname markup _hovered"), PREF "/nickname-markup-hover",
cb_nickname_markup_hover,
N_("Change the markup used to display the nickname when hovered "
"by the mouse using the Pango Markup Language where %n is replaced "
"with your nickname.") },
{ N_("Personal _message markup"), PREF "/personal-message-markup",
cb_personal_message_markup,
N_("Change the markup used to display the personal message using the "
- "Pango Markup Language where %m is replaced with your personal "
+ "Pango Markup Language where %p is replaced with your personal "
"message.") },
{ N_("Personal message markup _hovered"), PREF "/personal-message-markup-hover",
cb_personal_message_markup_hover,
N_("Change the markup used to display the personal message when hovered "
- "by the mouse using the Pango Markup Language where %m is replaced "
+ "by the mouse using the Pango Markup Language where %p is replaced "
"with your personal message.") },
{ NULL, NULL, NULL }
}; const struct widget *e = entry;
/* combobox widgets label, associated preference, alias and callback */
const struct i_widget {
const char *name;
const char *prefs;
const struct i_alias *alias;
void (*callback)(GtkWidget *, gpointer);
const char *tooltip;
} combobox[] = {
{ N_("Align _nickname"), PREF "/nickname-justify", alias_justify,
cb_nickname_justify,
N_("Alignment of the nickname into the bar.") },
{ N_("Align personal _message"), PREF "/personal-message-justify",
alias_justify, cb_personal_message_justify,
N_("Alignment of the personal message into the bar.") },
{ N_("Widget _position in the buddy list"), PREF "/widget-position",
alias_position, cb_widget_position,
N_("Position of the widget into pidgin's buddy list.") },
{ NULL, NULL, NULL, NULL }
}; const struct i_widget *cbx = combobox;
/* check button widgets label, associated preference and callback */
const struct widget check_button[] = {
{ N_("Hide _statusbox"), PREF "/hide-statusbox", cb_hide_statusbox,
N_("Show or hide the Pidgin's default statusbox.") },
{ N_("_Ignore status changes"), PREF "/override-status", cb_override_status,
N_("Ignore changes made to status from outside the widget. "
"This include changes made in Pidgin's default statusbox "
"and other plugins.") },
{ N_("Use a frame for _entry"), PREF "/frame-entry", cb_frame_entry,
N_("Enable or disable the use of a frame around the entries when "
"editing the nickname or personal message from the bar.") },
{ N_("_Swap left and right click"), PREF "/swap-click", cb_swap_click,
N_("Swap the role of left and right click to edit the nickname or "
"personal message in the bar.") },
{ N_("Use a _compact bar"), PREF "/compact", cb_compact,
N_("Reduce the size of the widget putting the nickname and personal "
"message on one line.") },
{ N_("_Reset status messages"), PREF "/reset-attrs", cb_reset_attrs,
N_("Clear the status messages when Pidgin restart (except for personal "
"message). By default these messages are saved in the preferences and "
"reactivated when pidgin restart.") },
{ NULL, NULL, NULL }
}; const struct widget *cb = check_button;
/* create table */
GtkWidget *table = gtk_table_new(((sizeof(entry) - 2) +
sizeof(check_button) / 2 - 1) /
sizeof(struct widget),
2, FALSE);
/* load table and connect signals */
int x = 0, y = 0;
for(; e->name ; e++, y++) {
/* entry widgets */
GtkWidget *widget_label = gtk_label_new_with_mnemonic(_(e->name));
GtkWidget *widget_entry = gtk_entry_new();
const gchar *prefs_value = purple_prefs_get_string(e->prefs);
gtk_label_set_mnemonic_widget(GTK_LABEL(widget_label), widget_entry);
gtk_entry_set_text(GTK_ENTRY(widget_entry), prefs_value);
gtk_widget_set_tooltip_text(widget_entry, _(e->tooltip));
gtk_misc_set_alignment(GTK_MISC(widget_label), 0., .5);
gtk_table_attach(GTK_TABLE(table), widget_label, 0, 1, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
gtk_table_attach(GTK_TABLE(table), widget_entry, 1, 2, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
g_signal_connect(G_OBJECT(widget_entry), "activate", G_CALLBACK(e->callback), NULL);
g_signal_connect(G_OBJECT(widget_entry), "focus-out-event", G_CALLBACK(e->callback), NULL);
}
for(; cbx->name ; cbx++, y++) {
/* combobox widgets */
const struct i_alias *j;
GtkWidget *widget_label = gtk_label_new_with_mnemonic(_(cbx->name));
GtkWidget *widget_combo = gtk_combo_box_new_text();
int prefs_value = purple_prefs_get_int(cbx->prefs);
int i;
gtk_label_set_mnemonic_widget(GTK_LABEL(widget_label), widget_combo);
gtk_misc_set_alignment(GTK_MISC(widget_label), 0., .5);
gtk_widget_set_tooltip_text(widget_label, _(cbx->tooltip));
gtk_table_attach(GTK_TABLE(table), widget_label, 0, 1, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
gtk_table_attach(GTK_TABLE(table), widget_combo, 1, 2, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
for(i = 0, j = cbx->alias ; j->alias ; j++, i++) {
gtk_combo_box_append_text(GTK_COMBO_BOX(widget_combo), _(j->alias));
if(j->value == prefs_value)
gtk_combo_box_set_active(GTK_COMBO_BOX(widget_combo), i);
}
g_signal_connect(G_OBJECT(widget_combo), "changed", G_CALLBACK(cbx->callback), (gpointer)cbx->alias);
}
for(; cb->name ; cb++, x = (x + 1) % 2) {
/* check button widgets */
GtkWidget *widget_cb = gtk_check_button_new_with_mnemonic(_(cb->name));
gboolean prefs_value = purple_prefs_get_bool(cb->prefs);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget_cb), prefs_value);
gtk_widget_set_tooltip_text(widget_cb, _(cb->tooltip));
gtk_table_attach(GTK_TABLE(table), widget_cb, x, x+1, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
g_signal_connect(G_OBJECT(widget_cb), "toggled", G_CALLBACK(cb->callback),NULL);
if(x % 2)
y++;
}
return table; /* pidgin destroy this when closed */
}
static void cb_nickname_markup(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget));
purple_prefs_set_string(PREF "/nickname-markup", value);
if(!get_widget_name_hover_state()) {
const gchar *name = purple_prefs_get_string(PREF "/nickname");
set_widget_name(value, name);
}
purple_debug_info(NAME, "nickname markup changed\n");
}
static void cb_nickname_markup_hover(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget));
purple_prefs_set_string(PREF "/nickname-markup-hover", value);
if(get_widget_name_hover_state()) {
const gchar *name = purple_prefs_get_string(PREF "/nickname");
set_widget_name(value, name);
}
purple_debug_info(NAME, "nickname markup hover changed\n");
}
static void cb_personal_message_markup(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget));
purple_prefs_set_string(PREF "/personal-message-markup", value);
if(!get_widget_pm_hover_state()) {
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
set_widget_pm(value, pm);
}
purple_debug_info(NAME, "personal message markup hover changed\n");
}
static void cb_personal_message_markup_hover(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget));
purple_prefs_set_string(PREF "/personal-message-markup-hover", value);
if(get_widget_pm_hover_state()) {
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
set_widget_pm(value, pm);
}
purple_debug_info(NAME, "personal message markup hover changed\n");
}
static void cb_hide_statusbox(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/hide-statusbox", state);
set_statusbox_visible(!state);
purple_debug_info(NAME, "status box state changed\n");
}
static void cb_override_status(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/override-status", state);
purple_debug_info(NAME, "override status state changed\n");
}
static void cb_nickname_justify(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget));
const struct i_alias *j;
for(j = (struct i_alias *)data ; j->alias ; j++) {
if(!strcmp(value, _(j->alias))) {
purple_prefs_set_int(PREF "/nickname-justify", j->value);
set_widget_name_justify(j->value);
break;
}
}
purple_debug_info(NAME, "nickname justification changed\n");
}
static void cb_personal_message_justify(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget));
const struct i_alias *j;
for(j = (struct i_alias *)data ; j->alias ; j++) {
if(!strcmp(value, _(j->alias))) {
purple_prefs_set_int(PREF "/personal-message-justify", j->value);
set_widget_pm_justify(j->value);
break;
}
}
purple_debug_info(NAME, "personal message justification changed\n");
}
static void cb_compact(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/compact", state);
/* recreate bar since we need to repack everything */
reset_widget();
init_widget();
purple_debug_info(NAME, "compact state changed\n");
}
static void cb_frame_entry(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/frame-entry", state);
set_widget_entry_frame(state);
purple_debug_info(NAME, "frame entry state changed\n");
}
static void cb_swap_click(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/swap-click", state);
purple_debug_info(NAME, "swap click state changed\n");
}
static void cb_reset_attrs(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/reset-attrs", state);
set_widget_entry_frame(state);
purple_debug_info(NAME, "reset attributes state changed\n");
}
static void cb_widget_position(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget));
const struct i_alias *j;
for(j = (struct i_alias *)data ; j->alias ; j++) {
if(!strcmp(value, _(j->alias))) {
purple_prefs_set_int(PREF "/widget-position", j->value);
/* recreate bar since we need to repack everything */
reset_widget();
init_widget();
break;
}
}
purple_debug_info(NAME, "personal message justification changed\n");
}
|
gawen947/pidgin-pbar
|
83befd4402c4dfcc582a11884133f7ce17cc4d56
|
Switch to dev. again
|
diff --git a/pbar.h b/pbar.h
index c6658ac..9543a0f 100644
--- a/pbar.h
+++ b/pbar.h
@@ -1,61 +1,61 @@
/* File: pbar.h
Time-stamp: <2010-11-15 23:55:36 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _PBAR_H_
#define _PBAR_H_
#include "common.h"
#ifndef G_GNUC_NULL_TERMINATED
# if __GNUC__ >= 4
# define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
# else
# define G_GNUC_NULL_TERMINATED
# endif /* __GNUC__ >= 4 */
#endif /* G_GNUC_NULL_TERMINATED */
/* name */
#define NAME "pbar" /* internal name */
#define DISP_NAME N_("PBar") /* displayed name */
-#define VERSION "0.2" /* current version */
+#define VERSION "0.3-git" /* current version */
/* plugin information */
#define PLUGIN_ID "gtk-" NAME /* gtk plugin id */
#define PLUGIN_NAME DISP_NAME
#ifndef COMMIT
# define PLUGIN_VERSION VERSION
#else
# define PLUGIN_VERSION VERSION " (commit:" COMMIT ")" /* add git commit
when available */
#endif
#define PLUGIN_SUMMARY N_("A toolbar to update some account settings " \
"globally.")
#define PLUGIN_DESCRIPTION N_("Adds a toolbar to the buddy list to quickly " \
"update nickname, personal message, icon, " \
"status and mood. It also allows updating of " \
"the current song and other parameters which " \
"are updated globally on all accounts that " \
"support them.")
#define PLUGIN_AUTHOR "David Hauweele <[email protected]>"
#define PLUGIN_WEBSITE "http://www.hauweele.net/~gawen/pidgin-pbar.html"
extern PurplePlugin *thisplugin;
#endif /* _PBAR_H_ */
|
gawen947/pidgin-pbar
|
d3b6671e6d28f92604365b8c6aee07179f5c3933
|
Release 0.2
|
diff --git a/ChangeLog b/ChangeLog
index 7e30913..20d7e75 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,13 +1,14 @@
* Wed Jun 22 2011 David Hauweele <[email protected]>
- Fix cursor bug
- Fix makefile to ease packaging
- Fix compilation against Gtk 2.12
- Add features dialogs
- Add dialogs to change attributes through Pidgin's tools menu
- Change contact addresses
- Add tooltips to preferences dialog
- Disable features when no connected account supporting them
- Clean code
+ - Release 0.2
* Wed Jan 5 2010 David Hauweele <[email protected]>
- Release 0.1
diff --git a/pbar.h b/pbar.h
index de63364..c6658ac 100644
--- a/pbar.h
+++ b/pbar.h
@@ -1,61 +1,61 @@
/* File: pbar.h
Time-stamp: <2010-11-15 23:55:36 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _PBAR_H_
#define _PBAR_H_
#include "common.h"
#ifndef G_GNUC_NULL_TERMINATED
# if __GNUC__ >= 4
# define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
# else
# define G_GNUC_NULL_TERMINATED
# endif /* __GNUC__ >= 4 */
#endif /* G_GNUC_NULL_TERMINATED */
/* name */
#define NAME "pbar" /* internal name */
#define DISP_NAME N_("PBar") /* displayed name */
-#define VERSION "0.2-git" /* current version */
+#define VERSION "0.2" /* current version */
/* plugin information */
#define PLUGIN_ID "gtk-" NAME /* gtk plugin id */
#define PLUGIN_NAME DISP_NAME
#ifndef COMMIT
# define PLUGIN_VERSION VERSION
#else
# define PLUGIN_VERSION VERSION " (commit:" COMMIT ")" /* add git commit
when available */
#endif
#define PLUGIN_SUMMARY N_("A toolbar to update some account settings " \
"globally.")
#define PLUGIN_DESCRIPTION N_("Adds a toolbar to the buddy list to quickly " \
"update nickname, personal message, icon, " \
"status and mood. It also allows updating of " \
"the current song and other parameters which " \
"are updated globally on all accounts that " \
"support them.")
#define PLUGIN_AUTHOR "David Hauweele <[email protected]>"
#define PLUGIN_WEBSITE "http://www.hauweele.net/~gawen/pidgin-pbar.html"
extern PurplePlugin *thisplugin;
#endif /* _PBAR_H_ */
|
gawen947/pidgin-pbar
|
bdcd420be4a688ab9092c1e16c3eff5e1568c024
|
Add changelog
|
diff --git a/ChangeLog b/ChangeLog
index ac7963f..7e30913 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,2 +1,13 @@
+* Wed Jun 22 2011 David Hauweele <[email protected]>
+ - Fix cursor bug
+ - Fix makefile to ease packaging
+ - Fix compilation against Gtk 2.12
+ - Add features dialogs
+ - Add dialogs to change attributes through Pidgin's tools menu
+ - Change contact addresses
+ - Add tooltips to preferences dialog
+ - Disable features when no connected account supporting them
+ - Clean code
+
* Wed Jan 5 2010 David Hauweele <[email protected]>
- Release 0.1
|
gawen947/pidgin-pbar
|
2b45344dee4b89c36067f0b28edc0dda8517ab20
|
Replace format specifications in German translation
|
diff --git a/de.po b/de.po
index a0f01b4..cb486ba 100644
--- a/de.po
+++ b/de.po
@@ -1,375 +1,375 @@
# Pidgin PBar German translation
# Copyright (C) 2010, Marleen Bekaert <[email protected]>
# This file is distributed under the same license as the Pidgin PBar package.
# Marleen Bekaert <[email protected]>, 2010
#
msgid ""
msgstr ""
"Project-Id-Version: nl\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-06-22 11:04+0200\n"
"PO-Revision-Date: 2011-06-22 12:40+0100\n"
"Last-Translator: Bekaert Marleen <[email protected]>\n"
"Language-Team: German <[email protected]>\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. name
#. internal name
#: pbar.h:36
msgid "PBar"
msgstr "PBar"
#: pbar.h:48
msgid "A toolbar to update some account settings globally."
msgstr "Eine Symbolleiste um manche Konto Einstellungen vollständig zu aktualisieren."
#: pbar.h:50
msgid "Adds a toolbar to the buddy list to quickly update nickname, personal message, icon, status and mood. It also allows updating of the current song and other parameters which are updated globally on all accounts that support them."
msgstr "Fügt eine Symbolleiste zu der Buddy-liste um schnell den Spitzname, den Persönlichen Bericht, die Ikone, den Status und die Stimmung schnell zu ändern. Erlaubt auch um das aktuelle Lied und anderen parameter die global aktualisiert werden auf alle Account die es ertragen ."
#. widgets that can possibly be modified along dialog lifetime
#: protocol_features.c:63
#: actions.c:92
msgid "Protocol features"
msgstr "Protokoll Funktionen"
#. widgets that are not modified
#: protocol_features.c:83
#: acct_features.c:84
msgid "Available features..."
msgstr "verfügbaren Funktionen..."
#: protocol_features.c:84
msgid "The following list shows the available features for each protocol."
msgstr "Die folgende Liste zeigt die verfügbaren Funktionen für jedes Protokoll."
#: protocol_features.c:100
msgid "Protocol"
msgstr "Protokoll"
#: protocol_features.c:116
#: acct_features.c:119
msgid "Nickname"
msgstr "Spitzname Tag"
#: protocol_features.c:117
#: acct_features.c:120
msgid "Status message"
msgstr "Status Nachricht"
#: protocol_features.c:118
#: acct_features.c:121
msgid "Buddy icon"
msgstr "Buddy Ikone"
#: protocol_features.c:119
#: acct_features.c:122
#: mood_dialog.c:133
msgid "Mood"
msgstr "Stimmung"
#: protocol_features.c:120
#: acct_features.c:123
msgid "Mood message"
msgstr "Stimmung Nachricht"
#: protocol_features.c:121
#: acct_features.c:124
msgid "Tune"
msgstr "Lied"
#: protocol_features.c:122
#: acct_features.c:125
msgid "Game"
msgstr "Spiel"
#: protocol_features.c:123
#: acct_features.c:126
msgid "App."
msgstr "App."
#. widgets that can possibly be modified along dialog lifetime
#: acct_features.c:64
#: actions.c:93
msgid "Account features"
msgstr "Konto Funktionen"
#: acct_features.c:85
msgid "The following list shows the available features for each activated account. The last line summarizes features that have an impact on at least one account."
msgstr "Die folgende Liste zeigt die verfügbaren Funktionen für jeden aktivierten Konto, die letzte Zeile fasst funktionen, die einen Einfluss auf mindestens ein konto haben."
#: acct_features.c:103
msgid "Account"
msgstr "Konto"
#. widgets that can be modifier along dialog lifetime
#: status_dialog.c:100
msgid "Status selection"
msgstr "Status Auswahl"
#. widgets that are not modified
#: status_dialog.c:115
msgid "Select your status..."
msgstr "Wählen Sie Ihren Satus ..."
#: status_dialog.c:116
msgid "This will change your current status for every account which supports it."
msgstr "ändernt ihr Spitzname für jedes Konto die es ertragt."
#: status_dialog.c:132
msgid "Status"
msgstr "Status"
#. widgets that can be modifier along dialog lifetime
#: mood_dialog.c:101
msgid "Mood selection"
msgstr "Stimmung Auswahl"
#. widgets that are not modified
#: mood_dialog.c:116
msgid "Select your mood..."
msgstr "Wählen Sie Ihre Stimmung..."
#: mood_dialog.c:117
msgid "This will change your mood for every account which supports it."
msgstr "ändernt ihre Stimmung für jedes Konto die es ertragt."
#: mood_dialog.c:201
#: mood_dialog.c:203
#: widget_gtk.c:276
msgid "None"
msgstr "Nichts"
#: preferences.c:50
msgid "Left"
msgstr "Linke"
#: preferences.c:51
msgid "Center"
msgstr "Mitte"
#: preferences.c:52
msgid "Right"
msgstr "Rechte"
#: preferences.c:58
msgid "Top"
msgstr "Oben"
#: preferences.c:59
msgid "Bottom"
msgstr "Unter"
#: preferences.c:131
msgid "_Nickname markup"
msgstr "_Spitzname Tag"
#: preferences.c:132
#, c-format
msgid "Change the markup used to display the nickname using the Pango Markup Language where %n is replaced with your nickname."
msgstr "ändert das Markup das verwendet wird um den Spitzname zu anzeigen mit der Pango Markup Language wo %n mit deinem Spitzname ersetzt ist."
#: preferences.c:135
msgid "Nickname markup _hovered"
msgstr "_Ãbergezwegt Spitzname Tag"
#: preferences.c:137
#, c-format
msgid "Change the markup used to display the nickname when hovered by the mouse using the Pango Markup Language where %n is replaced with your nickname."
msgstr "ändert das Markup das verwendet wird um den Spitzname zu anzeigen wenn überzwegt mit der Maus, mit der Pango Markup Language wo %n mit deinem Spitzname ersetzt ist."
#: preferences.c:141
msgid "Personal _message markup"
msgstr "Persönliche _Nachricht Tag"
#: preferences.c:143
#, c-format
msgid "Change the markup used to display the personal message using the Pango Markup Language where %m is replaced with your personal message."
-msgstr "ändert das markup das verwendet wird um die persönliche Nachricht zu anzeigen, mit der Pango Markup Language wo %n mit deiner persönliche Nachricht ersetzt ist."
+msgstr "ändert das markup das verwendet wird um die persönliche Nachricht zu anzeigen, mit der Pango Markup Language wo %m mit deiner persönliche Nachricht ersetzt ist."
#: preferences.c:147
msgid "Personal message markup _hovered"
msgstr "_Ãbergezwegd persönliche Nachricht Tag"
#: preferences.c:149
#, c-format
msgid "Change the markup used to display the personal message when hovered by the mouse using the Pango Markup Language where %m is replaced with your personal message."
-msgstr "ändert das Markup das verwendet wird um die persönliche Nachrict zu anzeigen wenn überzwegt mit der Maus, mit der Pango Markup Language wo %n mit deiner persönliche Nachricht."
+msgstr "ändert das Markup das verwendet wird um die persönliche Nachrict zu anzeigen wenn überzwegt mit der Maus, mit der Pango Markup Language wo %m mit deiner persönliche Nachricht."
#: preferences.c:164
msgid "Align _nickname"
msgstr "Spitzname_ausrichten"
#: preferences.c:166
msgid "Alignment of the nickname into the bar."
msgstr "Ausrichtung der Spitzname in der Bar."
#: preferences.c:168
msgid "Align personal _message"
msgstr "_Persönliche Nachricht ausrichten"
#: preferences.c:170
msgid "Alignment of the personal message into the bar."
msgstr "Aurichtung der persönliche Nachricht in die Bar."
#: preferences.c:172
msgid "Widget _position in the buddy list"
msgstr "Widget _Lage in den buddy-Liste"
#: preferences.c:174
msgid "Position of the widget into pidgin's buddy list."
msgstr "Lage des Widget in Pidgin-Buddy-Liste."
#: preferences.c:181
msgid "Hide _statusbox"
msgstr "_Statusbox verbergen"
#: preferences.c:182
msgid "Show or hide the Pidgin's default statusbox."
msgstr "Show or hide the Pidgin's default statusbox."
#: preferences.c:184
msgid "_Ignore status changes"
msgstr "_Ignoriert Status anderungen"
#: preferences.c:185
msgid "Ignore changes made to status from outside the widget. This include changes made in Pidgin's default statusbox and other plugins."
msgstr "Ignoriert änderungen zu Status von auÃerhalb des Widgets gemacht, inbegriffen änderungen in Pidgin standarmäÃige statusbox und andere Plugins gemacht."
#: preferences.c:189
msgid "Use a frame for _entry"
msgstr "Nutz ein ein Rahmen für Textinput"
#: preferences.c:190
msgid "Enable or disable the use of a frame around the entries when editing the nickname or personal message from the bar."
msgstr "Enable or disable the use of a frame around the entries when editing the nickname or personal message from the bar."
#: preferences.c:193
msgid "_Swap left and right click"
msgstr "_Dreht linke und rechte klik um"
#: preferences.c:194
msgid "Swap the role of left and right click to edit the nickname or personal message in the bar."
msgstr "Dreht die Rolle von links und rechts Klik um den Spitzname oder persönliche Nachricht in der Bar zu bearbeiten."
#: preferences.c:197
msgid "Use a _compact bar"
msgstr "Benutz ein kompakt Balken"
#: preferences.c:198
msgid "Reduce the size of the widget putting the nickname and personal message on one line."
msgstr "Reduziert die gröÃe des Widgets und setz den Spitzname und die persönliche Nachricht auf einer Linie."
#: preferences.c:201
msgid "_Reset status messages"
msgstr "_Rûcksetz Status Berichten"
#: preferences.c:202
msgid "Clear the status messages when Pidgin restart (except for personal message). By default these messages are saved in the preferences and reactivated when pidgin restart."
msgstr "Klar die Status nachrichten wenn pidgin neustart (auÃerhalb für persönliche Nacxhrichten). StandarmäÃig werden diese Nachrichten in die Präferenzen gespeichert und neuaktiviert wenn Pidgin neustart."
#. preferences
#. preference root
#. empty messages to display at first installation
#: preferences.h:33
msgid "<Enter nickname here>"
msgstr "<hier Spitzname einführen>"
#: preferences.h:34
msgid "<Enter personal message here>"
msgstr "<Hier persönlich nachricht einführen>"
#: actions.c:87
#: widget.c:309
msgid "Change nickname"
msgstr "ändernt Spitzname"
#: actions.c:88
msgid "Change personal message"
msgstr "Persönliche Nachricht ausrichten"
#: actions.c:89
msgid "Change status"
msgstr "ändernt Status Nachricht"
#: actions.c:90
msgid "Change mood"
msgstr "ändernt Stimmung"
#: actions.c:91
msgid "Change icon"
msgstr "ändernt Ikone"
#: widget.c:310
msgid "Enter your nickname here..."
msgstr "Hier Spitzname einführen..."
#: widget.c:311
msgid "This will change your nickname for every account which supports it."
msgstr "ändernt ihr Spitzname für jeder Account die es ertragen."
#: widget.c:317
#: widget.c:531
msgid "OK"
msgstr "OK"
#: widget.c:319
#: widget.c:533
msgid "Cancel"
msgstr "Annulieren"
#: widget.c:476
msgid "_Mood message"
msgstr "_Stimmung Nachricht"
#: widget.c:477
msgid "Current song"
msgstr "Aktuel lied"
#: widget.c:478
msgid "Song _title"
msgstr "lied _Titel"
#: widget.c:479
msgid "Song _artist"
msgstr "Lied _Künstler"
#: widget.c:480
msgid "Song al_bum"
msgstr "Lied Al_bum"
#: widget.c:481
msgid "MSN pecan extra attributes"
msgstr "MSN pecan extra Parameter"
#: widget.c:482
msgid "_Game name"
msgstr "_Spiel Name"
#: widget.c:483
msgid "_Office app name"
msgstr "_Office app Name"
#: widget.c:489
msgid "Status and mood message"
msgstr "Status und Stimmung Nachricht"
#: widget.c:494
msgid "_Personal message"
msgstr "_Persönliche Nachricht"
#: widget.c:525
msgid "Change status messages"
msgstr "ändernt Status Nachricht"
#: widget.c:526
msgid "Enter status message..."
msgstr "führt Status Nachricht ein..."
#: widget.c:527
msgid "This will change some status messages for every account which supports it, please be advised that some are inconsistent between each other."
msgstr "ändernt einige Status Nachrichten für jeder Account die es ertragt, Bitte beachten Sie dass einige inkonsistent sind untereinander."
|
gawen947/pidgin-pbar
|
2e1cb5dc890e7f001444619ca9d5553e29e2034a
|
Add German translation
|
diff --git a/de.po b/de.po
index 16bb1b7..4e9b0a6 100644
--- a/de.po
+++ b/de.po
@@ -1,190 +1,375 @@
# Pidgin PBar German translation
# Copyright (C) 2010, Marleen Bekaert <[email protected]>
# This file is distributed under the same license as the Pidgin PBar package.
# Marleen Bekaert <[email protected]>, 2010
#
-
msgid ""
msgstr ""
"Project-Id-Version: nl\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-01-04 20:23+0100\n"
-"PO-Revision-Date: 2011-01-04 23:19+0100\n"
-"Last-Translator: Marleen Bekaert <[email protected]>\n"
+"POT-Creation-Date: 2011-06-22 11:04+0200\n"
+"PO-Revision-Date: 2011-06-22 12:40+0100\n"
+"Last-Translator: David Hauweele <[email protected]>\n"
"Language-Team: German <[email protected]>\n"
+"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. name
#. internal name
#: pbar.h:36
msgid "PBar"
msgstr "PBar"
#: pbar.h:48
msgid "A toolbar to update some account settings globally."
-msgstr "Eine Symbolleiste um manche Account Einstellungen vollständig zu aktualisieren."
+msgstr "Eine Symbolleiste um manche Konto Einstellungen vollständig zu aktualisieren."
#: pbar.h:50
msgid "Adds a toolbar to the buddy list to quickly update nickname, personal message, icon, status and mood. It also allows updating of the current song and other parameters which are updated globally on all accounts that support them."
-msgstr "Fügt eine Symbolleiste zu der Buddy-liste um schnell den Spitzname, den Persönlichen Bericht, die Ikone, den Status und die Laune schnell zu ändern. Erlaubt auch um das aktuelle Lied und anderen parameter die global aktualisiert werden auf alle Account die es ertragen ."
+msgstr "Fügt eine Symbolleiste zu der Buddy-liste um schnell den Spitzname, den Persönlichen Bericht, die Ikone, den Status und die Stimmung schnell zu ändern. Erlaubt auch um das aktuelle Lied und anderen parameter die global aktualisiert werden auf alle Account die es ertragen ."
+
+#. widgets that can possibly be modified along dialog lifetime
+#: protocol_features.c:63
+#: actions.c:92
+msgid "Protocol features"
+msgstr "Protokoll Funktionen"
+
+#. widgets that are not modified
+#: protocol_features.c:83
+#: acct_features.c:84
+msgid "Available features..."
+msgstr "verfügbaren Funktionen..."
+
+#: protocol_features.c:84
+msgid "The following list shows the available features for each protocol."
+msgstr "Die folgende Liste zeigt die verfügbaren Funktionen für jedes Protokoll."
+
+#: protocol_features.c:100
+msgid "Protocol"
+msgstr "Protokoll"
+
+#: protocol_features.c:116
+#: acct_features.c:119
+msgid "Nickname"
+msgstr "Spitzname Tag"
+
+#: protocol_features.c:117
+#: acct_features.c:120
+msgid "Status message"
+msgstr "Status Nachricht"
+
+#: protocol_features.c:118
+#: acct_features.c:121
+msgid "Buddy icon"
+msgstr "Buddy Ikone"
+
+#: protocol_features.c:119
+#: acct_features.c:122
+#: mood_dialog.c:133
+msgid "Mood"
+msgstr "Stimmung"
+
+#: protocol_features.c:120
+#: acct_features.c:123
+msgid "Mood message"
+msgstr "Stimmung Nachricht"
+
+#: protocol_features.c:121
+#: acct_features.c:124
+msgid "Tune"
+msgstr "Lied"
+
+#: protocol_features.c:122
+#: acct_features.c:125
+msgid "Game"
+msgstr "Spiel"
+
+#: protocol_features.c:123
+#: acct_features.c:126
+msgid "App."
+msgstr "App."
+
+#. widgets that can possibly be modified along dialog lifetime
+#: acct_features.c:64
+#: actions.c:93
+msgid "Account features"
+msgstr "Konto Funktionen"
+
+#: acct_features.c:85
+msgid "The following list shows the available features for each activated account. The last line summarizes features that have an impact on at least one account."
+msgstr "Die folgende Liste zeigt die verfügbaren Funktionen für jeden aktivierten Konto, die letzte Zeile fasst funktionen, die einen Einfluss auf mindestens ein konto haben."
+
+#: acct_features.c:103
+msgid "Account"
+msgstr "Konto"
+
+#. widgets that can be modifier along dialog lifetime
+#: status_dialog.c:100
+msgid "Status selection"
+msgstr "Status Auswahl"
+
+#. widgets that are not modified
+#: status_dialog.c:115
+msgid "Select your status..."
+msgstr "Wählen Sie Ihren Satus ..."
+
+#: status_dialog.c:116
+msgid "This will change your current status for every account which supports it."
+msgstr "ändernt ihr Spitzname für jedes Konto die es ertragt."
+
+#: status_dialog.c:132
+msgid "Status"
+msgstr "Status"
+
+#. widgets that can be modifier along dialog lifetime
+#: mood_dialog.c:101
+msgid "Mood selection"
+msgstr "Stimmung Auswahl"
+
+#. widgets that are not modified
+#: mood_dialog.c:116
+msgid "Select your mood..."
+msgstr "Wählen Sie Ihre Stimmung..."
+
+#: mood_dialog.c:117
+msgid "This will change your mood for every account which supports it."
+msgstr "ändernt ihre Stimmung für jedes Konto die es ertragt."
+
+#: mood_dialog.c:201
+#: mood_dialog.c:203
+#: widget_gtk.c:276
+msgid "None"
+msgstr "Nichts"
#: preferences.c:50
msgid "Left"
msgstr "Linke"
#: preferences.c:51
msgid "Center"
msgstr "Mitte"
#: preferences.c:52
msgid "Right"
msgstr "Rechte"
#: preferences.c:58
msgid "Top"
msgstr "Oben"
#: preferences.c:59
msgid "Bottom"
msgstr "Unter"
-#: preferences.c:130
+#: preferences.c:131
msgid "_Nickname markup"
msgstr "_Spitzname Tag"
-#: preferences.c:131
+#: preferences.c:132
+#, c-format
+msgid "Change the markup used to display the nickname using the Pango Markup Language where %n is replaced with your nickname."
+msgstr "ändert das Markup das verwendet wird um den Spitzname zu anzeigen mit der Pango Markup Language wo %n mit deinem Spitzname ersetzt ist."
+
+#: preferences.c:135
msgid "Nickname markup _hovered"
-msgstr "_Ãbergezwegd Spitzname Tag"
+msgstr "_Ãbergezwegt Spitzname Tag"
-#: preferences.c:132
+#: preferences.c:137
+#, c-format
+msgid "Change the markup used to display the nickname when hovered by the mouse using the Pango Markup Language where %n is replaced with your nickname."
+msgstr "ändert das Markup das verwendet wird um den Spitzname zu anzeigen wenn überzwegt mit der Maus, mit der Pango Markup Language wo %n mit deinem Spitzname ersetzt ist."
+
+#: preferences.c:141
msgid "Personal _message markup"
msgstr "Persönliche _Nachricht Tag"
-#: preferences.c:133
+#: preferences.c:143
+#, c-format
+msgid "Change the markup used to display the personal message using the Pango Markup Language where %m is replaced with your personal message."
+msgstr "ändert das markup das verwendet wird um die persönliche Nachricht zu anzeigen, mit der Pango Markup Language wo %n mit deiner persönliche Nachricht ersetzt ist."
+
+#: preferences.c:147
msgid "Personal message markup _hovered"
msgstr "_Ãbergezwegd persönliche Nachricht Tag"
-#: preferences.c:144
+#: preferences.c:149
+#, c-format
+msgid "Change the markup used to display the personal message when hovered by the mouse using the Pango Markup Language where %m is replaced with your personal message."
+msgstr "ändert das Markup das verwendet wird um die persönliche Nachrict zu anzeigen wenn überzwegt mit der Maus, mit der Pango Markup Language wo %n mit deiner persönliche Nachricht."
+
+#: preferences.c:164
msgid "Align _nickname"
msgstr "Spitzname_ausrichten"
-#: preferences.c:145
+#: preferences.c:166
+msgid "Alignment of the nickname into the bar."
+msgstr "Ausrichtung der Spitzname in der Bar."
+
+#: preferences.c:168
msgid "Align personal _message"
msgstr "_Persönliche Nachricht ausrichten"
-#: preferences.c:146
+#: preferences.c:170
+msgid "Alignment of the personal message into the bar."
+msgstr "Aurichtung der persönliche Nachricht in die Bar."
+
+#: preferences.c:172
msgid "Widget _position in the buddy list"
msgstr "Widget _Lage in den buddy-Liste"
-#: preferences.c:152
+#: preferences.c:174
+msgid "Position of the widget into pidgin's buddy list."
+msgstr "Lage des Widget in Pidgin-Buddy-Liste."
+
+#: preferences.c:181
msgid "Hide _statusbox"
msgstr "_Statusbox verbergen"
-#: preferences.c:153
+#: preferences.c:182
+msgid "Show or hide the Pidgin's default statusbox."
+msgstr "Show or hide the Pidgin's default statusbox."
+
+#: preferences.c:184
msgid "_Ignore status changes"
msgstr "_Ignoriert Status anderungen"
-#: preferences.c:154
+#: preferences.c:185
+msgid "Ignore changes made to status from outside the widget. This include changes made in Pidgin's default statusbox and other plugins."
+msgstr "Ignoriert änderungen zu Status von auÃerhalb des Widgets gemacht, inbegriffen änderungen in Pidgin standarmäÃige statusbox und andere Plugins gemacht."
+
+#: preferences.c:189
msgid "Use a frame for _entry"
msgstr "Nutz ein ein Rahmen für Textinput"
-#: preferences.c:155
+#: preferences.c:190
+msgid "Enable or disable the use of a frame around the entries when editing the nickname or personal message from the bar."
+msgstr "Enable or disable the use of a frame around the entries when editing the nickname or personal message from the bar."
+
+#: preferences.c:193
msgid "_Swap left and right click"
msgstr "_Dreht linke und rechte klik um"
-#: preferences.c:156
+#: preferences.c:194
+msgid "Swap the role of left and right click to edit the nickname or personal message in the bar."
+msgstr "Dreht die Rolle von links und rechts Klik um den Spitzname oder persönliche Nachricht in der Bar zu bearbeiten."
+
+#: preferences.c:197
msgid "Use a _compact bar"
msgstr "Benutz ein kompakt Balken"
-#: preferences.c:157
+#: preferences.c:198
+msgid "Reduce the size of the widget putting the nickname and personal message on one line."
+msgstr "Reduziert die gröÃe des Widgets und setz den Spitzname und die persönliche Nachricht auf einer Linie."
+
+#: preferences.c:201
msgid "_Reset status messages"
msgstr "_Rûcksetz Status Berichten"
+#: preferences.c:202
+msgid "Clear the status messages when Pidgin restart (except for personal message). By default these messages are saved in the preferences and reactivated when pidgin restart."
+msgstr "Klar die Status nachrichten wenn pidgin neustart (auÃerhalb für persönliche Nacxhrichten). StandarmäÃig werden diese Nachrichten in die Präferenzen gespeichert und neuaktiviert wenn Pidgin neustart."
+
#. preferences
#. preference root
#. empty messages to display at first installation
#: preferences.h:33
msgid "<Enter nickname here>"
msgstr "<hier Spitzname einführen>"
#: preferences.h:34
msgid "<Enter personal message here>"
msgstr "<Hier persönlich nachricht einführen>"
-#: widget_gtk.c:94
+#: actions.c:87
+#: widget.c:309
msgid "Change nickname"
msgstr "ändernt Spitzname"
-#: widget_gtk.c:95
+#: actions.c:88
+msgid "Change personal message"
+msgstr "Persönliche Nachricht ausrichten"
+
+#: actions.c:89
+msgid "Change status"
+msgstr "ändernt Status Nachricht"
+
+#: actions.c:90
+msgid "Change mood"
+msgstr "ändernt Stimmung"
+
+#: actions.c:91
+msgid "Change icon"
+msgstr "ändernt Ikone"
+
+#: widget.c:310
msgid "Enter your nickname here..."
msgstr "Hier Spitzname einführen..."
-#: widget_gtk.c:96
+#: widget.c:311
msgid "This will change your nickname for every account which supports it."
-msgstr "ändernt ihr Spitzname für jeder Account die es ertragen ."
+msgstr "ändernt ihr Spitzname für jeder Account die es ertragen."
-#: widget_gtk.c:102 widget_gtk.c:246
+#: widget.c:317
+#: widget.c:531
msgid "OK"
msgstr "OK"
-#: widget_gtk.c:104 widget_gtk.c:248
+#: widget.c:319
+#: widget.c:533
msgid "Cancel"
msgstr "Annulieren"
-#: widget_gtk.c:197
+#: widget.c:476
msgid "_Mood message"
-msgstr "_Laune Nachricht"
+msgstr "_Stimmung Nachricht"
-#: widget_gtk.c:198
+#: widget.c:477
msgid "Current song"
msgstr "Aktuel lied"
-#: widget_gtk.c:199
+#: widget.c:478
msgid "Song _title"
msgstr "lied _Titel"
-#: widget_gtk.c:200
+#: widget.c:479
msgid "Song _artist"
msgstr "Lied _Künstler"
-#: widget_gtk.c:201
+#: widget.c:480
msgid "Song al_bum"
msgstr "Lied Al_bum"
-#: widget_gtk.c:202
+#: widget.c:481
msgid "MSN pecan extra attributes"
msgstr "MSN pecan extra Parameter"
-#: widget_gtk.c:203
+#: widget.c:482
msgid "_Game name"
msgstr "_Spiel Name"
-#: widget_gtk.c:204
+#: widget.c:483
msgid "_Office app name"
msgstr "_Office app Name"
-#: widget_gtk.c:210
+#: widget.c:489
msgid "Status and mood message"
-msgstr "Status und Laune Nachricht"
+msgstr "Status und Stimmung Nachricht"
-#: widget_gtk.c:214
+#: widget.c:494
msgid "_Personal message"
msgstr "_Persönliche Nachricht"
-#: widget_gtk.c:240
+#: widget.c:525
msgid "Change status messages"
msgstr "ändernt Status Nachricht"
-#: widget_gtk.c:241
+#: widget.c:526
msgid "Enter status message..."
msgstr "führt Status Nachricht ein..."
-#: widget_gtk.c:242
+#: widget.c:527
msgid "This will change some status messages for every account which supports it, please be advised that some are inconsistent between each other."
msgstr "ändernt einige Status Nachrichten für jeder Account die es ertragt, Bitte beachten Sie dass einige inkonsistent sind untereinander."
-#: widget_gtk.c:361
-msgid "None"
-msgstr "Nichts"
|
gawen947/pidgin-pbar
|
75febd8c3c8ce2db4b376abd38079f2ddc30179f
|
Change mail addr.
|
diff --git a/nl.po b/nl.po
index 88ef912..78365f8 100644
--- a/nl.po
+++ b/nl.po
@@ -1,375 +1,375 @@
# Pidgin PBar Dutch translation
# Copyright (C) 2010, Marleen Bekaert <[email protected]>
# This file is distributed under the same license as the Pidgin PBar package.
# Marleen Bekaert <[email protected]>, 2010
#
msgid ""
msgstr ""
"Project-Id-Version: nl\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-06-21 21:21+0200\n"
"PO-Revision-Date: 2011-06-21 22:53+0100\n"
-"Last-Translator: David Hauweele <[email protected]>\n"
+"Last-Translator: Bekaert Marleen <[email protected]>\n"
"Language-Team: Dutch <[email protected]>\n"
"Language: nl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. name
#. internal name
#: pbar.h:36
msgid "PBar"
msgstr "PBar"
#: pbar.h:48
msgid "A toolbar to update some account settings globally."
msgstr "Een werkbalk om sommige account instellingen globaal te actualiseren."
#: pbar.h:50
msgid "Adds a toolbar to the buddy list to quickly update nickname, personal message, icon, status and mood. It also allows updating of the current song and other parameters which are updated globally on all accounts that support them."
msgstr "Voegt een werkbalk aan de contact lijst om vlug bijnaam, persoonlijk bericht, icoon, status en humeur te actualiseren. Het laat ook toe om het huidig lied en andere parameters die globaal actualiseerd zijn op alle accounts die het verdragen."
#. widgets that can possibly be modified along dialog lifetime
#: protocol_features.c:63
#: actions.c:92
msgid "Protocol features"
msgstr "Protocol bekwaamheden"
#. widgets that are not modified
#: protocol_features.c:83
#: acct_features.c:84
msgid "Available features..."
msgstr "Beschikbaare bekwaamheden..."
#: protocol_features.c:84
msgid "The following list shows the available features for each protocol."
msgstr "De volgende lijst toont de beschikbaare bekwaamheden voor iedere protocol."
#: protocol_features.c:100
msgid "Protocol"
msgstr "Protocol"
#: protocol_features.c:116
#: acct_features.c:119
msgid "Nickname"
msgstr "Bijnaam"
#: protocol_features.c:117
#: acct_features.c:120
msgid "Status message"
msgstr "Status bericht"
#: protocol_features.c:118
#: acct_features.c:121
msgid "Buddy icon"
msgstr "Contacten icoon"
#: protocol_features.c:119
#: acct_features.c:122
#: mood_dialog.c:133
msgid "Mood"
msgstr "Humeur"
#: protocol_features.c:120
#: acct_features.c:123
msgid "Mood message"
msgstr "Humeur bericht"
#: protocol_features.c:121
#: acct_features.c:124
msgid "Tune"
msgstr "Lied"
#: protocol_features.c:122
#: acct_features.c:125
msgid "Game"
msgstr "Spel"
#: protocol_features.c:123
#: acct_features.c:126
msgid "App."
msgstr "App."
#. widgets that can possibly be modified along dialog lifetime
#: acct_features.c:64
#: actions.c:93
msgid "Account features"
msgstr "Account bekwaamheden"
#: acct_features.c:85
msgid "The following list shows the available features for each activated account. The last line summarizes features that have an impact on at least one account."
msgstr "De volgende lijst toont the beschikbaare bekwaamheden voor iedere geactiveerde account. De laatste lijn vat de bekwaamheden samen die een effect hebben op ten minste een account."
#: acct_features.c:103
msgid "Account"
msgstr "Account"
#. widgets that can be modifier along dialog lifetime
#: status_dialog.c:100
msgid "Status selection"
msgstr "Status selectie"
#. widgets that are not modified
#: status_dialog.c:115
msgid "Select your status..."
msgstr "Selecteer uw status..."
#: status_dialog.c:116
msgid "This will change your current status for every account which supports it."
msgstr "Dat zal U lopend status veranderen voor iedere account die het verdraagt."
#: status_dialog.c:132
msgid "Status"
msgstr "Status"
#. widgets that can be modifier along dialog lifetime
#: mood_dialog.c:101
msgid "Mood selection"
msgstr "Humeur selectie"
#. widgets that are not modified
#: mood_dialog.c:116
msgid "Select your mood..."
msgstr "Selecteer uw humeur..."
#: mood_dialog.c:117
msgid "This will change your mood for every account which supports it."
msgstr "Dat zal U humeur veranderen vor iedere account die het verdraagt."
#: mood_dialog.c:201
#: mood_dialog.c:203
#: widget_gtk.c:276
msgid "None"
msgstr "Niets"
#: preferences.c:50
msgid "Left"
msgstr "Links"
#: preferences.c:51
msgid "Center"
msgstr "Midden"
#: preferences.c:52
msgid "Right"
msgstr "Rechts"
#: preferences.c:58
msgid "Top"
msgstr "Boven"
#: preferences.c:59
msgid "Bottom"
msgstr "Beneden"
#: preferences.c:131
msgid "_Nickname markup"
msgstr "_Bijnaam baken"
#: preferences.c:132
#, c-format
msgid "Change the markup used to display the nickname using the Pango Markup Language where %n is replaced with your nickname."
msgstr "Veranderd het baken die gebruikt werd om de bijnaam te displayen, door het gebruiken van de Pango Markup Language waar %n vervangen word door uw bijnaam."
#: preferences.c:135
msgid "Nickname markup _hovered"
msgstr "Bijnaam baken _overgezweefd"
#: preferences.c:137
#, c-format
msgid "Change the markup used to display the nickname when hovered by the mouse using the Pango Markup Language where %n is replaced with your nickname."
msgstr "Veranderd het baken die gebruikt werd om de bijnaam te displayen wanneer men er met de muis overzweefd, door het gebruiken van de Pango Markup language waar %n vervangen word door uw bijnaam."
#: preferences.c:141
msgid "Personal _message markup"
msgstr "Persoonlijk _bericht baken"
#: preferences.c:143
#, c-format
msgid "Change the markup used to display the personal message using the Pango Markup Language where %m is replaced with your personal message."
msgstr "veranderd het baken die gebruikt werd om het persoonlijk bericht te displayen, door het gebruiken van de Pango Markup Language waar %m vervangen word door uw persoonlijk bericht."
#: preferences.c:147
msgid "Personal message markup _hovered"
msgstr "Persoonlijk bericht baken _overgezweefd"
#: preferences.c:149
#, c-format
msgid "Change the markup used to display the personal message when hovered by the mouse using the Pango Markup Language where %m is replaced with your personal message."
msgstr "Veranderd het baken die gebruikt werd om het persoonlijk bericht te displayen wanneer men er met de muis overzweefd, door het gebruiken van de Pango Markup Language waar %m vervangen word door uw persoonlijke bericht."
#: preferences.c:164
msgid "Align _nickname"
msgstr "Richten _bijnaam"
#: preferences.c:166
msgid "Alignment of the nickname into the bar."
msgstr "Alignment of the nickname into the bar."
#: preferences.c:168
msgid "Align personal _message"
msgstr "Richten persoonlijk _bericht"
#: preferences.c:170
msgid "Alignment of the personal message into the bar."
msgstr "Het zetten van het persoonlijk bericht in de balk"
#: preferences.c:172
msgid "Widget _position in the buddy list"
msgstr "Werkbalk _positie in contactlijst"
#: preferences.c:174
msgid "Position of the widget into pidgin's buddy list."
msgstr "Positie van de werkbalk in Pidgin contactlijst."
#: preferences.c:181
msgid "Hide _statusbox"
msgstr "Verberg _statusbox"
#: preferences.c:182
msgid "Show or hide the Pidgin's default statusbox."
msgstr "Toon of verberg Pidgins bij verstek statusbox."
#: preferences.c:184
msgid "_Ignore status changes"
msgstr "_Negeren van status negeren"
#: preferences.c:185
msgid "Ignore changes made to status from outside the widget. This include changes made in Pidgin's default statusbox and other plugins."
msgstr "Negeer de veranderingen van de status als ze van buiten de balk gemaakt zijn, dit omvat veranderingen gemaakt in Pidgins bij verstek statusbox en andere plugins."
#: preferences.c:189
msgid "Use a frame for _entry"
msgstr "Gebruik een kader voor _textinvoer"
#: preferences.c:190
msgid "Enable or disable the use of a frame around the entries when editing the nickname or personal message from the bar."
msgstr "Stelt of schakelt het gebruik van een kader uit rond de invoer van de balk wanneer men de bijnaam of het persoolijk bericht bewerkt."
#: preferences.c:193
msgid "_Swap left and right click"
msgstr "_Keer linkse and rechtse klik om"
#: preferences.c:194
msgid "Swap the role of left and right click to edit the nickname or personal message in the bar."
msgstr "Keer de rol van linkse en rechtse klik om de bijnaam of persoonlijk bericht te bewerken in de balk."
#: preferences.c:197
msgid "Use a _compact bar"
msgstr "gebruikt een _compacte balk"
#: preferences.c:198
msgid "Reduce the size of the widget putting the nickname and personal message on one line."
msgstr "Verminderd de maat van de werkbalk door de bijnaam en persoonlijn bericht op een lijn te zetten."
#: preferences.c:201
msgid "_Reset status messages"
msgstr "_Opmaak status berichten"
#: preferences.c:202
msgid "Clear the status messages when Pidgin restart (except for personal message). By default these messages are saved in the preferences and reactivated when pidgin restart."
msgstr "Wiss de status berichten uit wanneer Pidgin herstart (uitgezonderd voor het persoonlijk bericht), bij verstek worden deze berichten opgeslagen in de voorkeuren en gereactiveerd als Pidgin terug opstart."
#. preferences
#. preference root
#. empty messages to display at first installation
#: preferences.h:33
msgid "<Enter nickname here>"
msgstr "<Hier bijnaam invoeren>"
#: preferences.h:34
msgid "<Enter personal message here>"
msgstr "<Hier persoonlijk bericht iuvoeren>"
#: actions.c:87
#: widget.c:309
msgid "Change nickname"
msgstr "Veranderd bijnaam"
#: actions.c:88
msgid "Change personal message"
msgstr "Richten persoonlijk bericht"
#: actions.c:89
msgid "Change status"
msgstr "Veranderd status"
#: actions.c:90
msgid "Change mood"
msgstr "Veranderd humeur"
#: actions.c:91
msgid "Change icon"
msgstr "Veranderd icoon"
#: widget.c:310
msgid "Enter your nickname here..."
msgstr "Hier U bijnaam invoeren..."
#: widget.c:311
msgid "This will change your nickname for every account which supports it."
msgstr "Dat zal U bijnaam veranderen vor iedere account die het verdraagt."
#: widget.c:317
#: widget.c:531
msgid "OK"
msgstr "OK"
#: widget.c:319
#: widget.c:533
msgid "Cancel"
msgstr "Annuleren"
#: widget.c:476
msgid "_Mood message"
msgstr "_Humeur bericht"
#: widget.c:477
msgid "Current song"
msgstr "Huidig lied"
#: widget.c:478
msgid "Song _title"
msgstr "Lied _tijtel"
#: widget.c:479
msgid "Song _artist"
msgstr "Lied _artiest"
#: widget.c:480
msgid "Song al_bum"
msgstr "Lied al_bum"
#: widget.c:481
msgid "MSN pecan extra attributes"
msgstr "MSN pecan extra parameters"
#: widget.c:482
msgid "_Game name"
msgstr "_Spelnaam"
#: widget.c:483
msgid "_Office app name"
msgstr "_Office app naam"
#: widget.c:489
msgid "Status and mood message"
msgstr "Status en humeur bericht"
#: widget.c:494
msgid "_Personal message"
msgstr "_Persoonlijk bericht"
#: widget.c:525
msgid "Change status messages"
msgstr "Veranderd status berichten"
#: widget.c:526
msgid "Enter status message..."
msgstr "Voert Status berichten in..."
#: widget.c:527
msgid "This will change some status messages for every account which supports it, please be advised that some are inconsistent between each other."
msgstr "Dat zal sommige status berichten veranderen voor iedere account die het verdraagt, houd er a.u.b rekening mee dat sommige inconsequent zijn tussen elkaar."
|
gawen947/pidgin-pbar
|
23e94d8f29fa45e90a3f54e053d042ca45cca91e
|
Add Dutch translation
|
diff --git a/nl.po b/nl.po
index 4d7dba8..88ef912 100644
--- a/nl.po
+++ b/nl.po
@@ -1,190 +1,375 @@
# Pidgin PBar Dutch translation
# Copyright (C) 2010, Marleen Bekaert <[email protected]>
# This file is distributed under the same license as the Pidgin PBar package.
# Marleen Bekaert <[email protected]>, 2010
#
-
msgid ""
msgstr ""
"Project-Id-Version: nl\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-12-19 19:13+0100\n"
-"PO-Revision-Date: 2010-12-19 19:20+0100\n"
-"Last-Translator: Marleen Bekaert <[email protected]>\n"
+"POT-Creation-Date: 2011-06-21 21:21+0200\n"
+"PO-Revision-Date: 2011-06-21 22:53+0100\n"
+"Last-Translator: David Hauweele <[email protected]>\n"
"Language-Team: Dutch <[email protected]>\n"
+"Language: nl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. name
#. internal name
#: pbar.h:36
msgid "PBar"
msgstr "PBar"
#: pbar.h:48
msgid "A toolbar to update some account settings globally."
msgstr "Een werkbalk om sommige account instellingen globaal te actualiseren."
#: pbar.h:50
msgid "Adds a toolbar to the buddy list to quickly update nickname, personal message, icon, status and mood. It also allows updating of the current song and other parameters which are updated globally on all accounts that support them."
-msgstr "Voegt een werkbalk aan de contact list om vlug bijnaam, persoonlijk bericht, icoon, status en humeur te actualiseren. Het laat ook toe om het huidig lied en andere parameters die globaal actualiseerd zijn op alle accounts die het verdragen."
+msgstr "Voegt een werkbalk aan de contact lijst om vlug bijnaam, persoonlijk bericht, icoon, status en humeur te actualiseren. Het laat ook toe om het huidig lied en andere parameters die globaal actualiseerd zijn op alle accounts die het verdragen."
+
+#. widgets that can possibly be modified along dialog lifetime
+#: protocol_features.c:63
+#: actions.c:92
+msgid "Protocol features"
+msgstr "Protocol bekwaamheden"
+
+#. widgets that are not modified
+#: protocol_features.c:83
+#: acct_features.c:84
+msgid "Available features..."
+msgstr "Beschikbaare bekwaamheden..."
+
+#: protocol_features.c:84
+msgid "The following list shows the available features for each protocol."
+msgstr "De volgende lijst toont de beschikbaare bekwaamheden voor iedere protocol."
+
+#: protocol_features.c:100
+msgid "Protocol"
+msgstr "Protocol"
+
+#: protocol_features.c:116
+#: acct_features.c:119
+msgid "Nickname"
+msgstr "Bijnaam"
+
+#: protocol_features.c:117
+#: acct_features.c:120
+msgid "Status message"
+msgstr "Status bericht"
+
+#: protocol_features.c:118
+#: acct_features.c:121
+msgid "Buddy icon"
+msgstr "Contacten icoon"
+
+#: protocol_features.c:119
+#: acct_features.c:122
+#: mood_dialog.c:133
+msgid "Mood"
+msgstr "Humeur"
+
+#: protocol_features.c:120
+#: acct_features.c:123
+msgid "Mood message"
+msgstr "Humeur bericht"
+
+#: protocol_features.c:121
+#: acct_features.c:124
+msgid "Tune"
+msgstr "Lied"
+
+#: protocol_features.c:122
+#: acct_features.c:125
+msgid "Game"
+msgstr "Spel"
+
+#: protocol_features.c:123
+#: acct_features.c:126
+msgid "App."
+msgstr "App."
+
+#. widgets that can possibly be modified along dialog lifetime
+#: acct_features.c:64
+#: actions.c:93
+msgid "Account features"
+msgstr "Account bekwaamheden"
+
+#: acct_features.c:85
+msgid "The following list shows the available features for each activated account. The last line summarizes features that have an impact on at least one account."
+msgstr "De volgende lijst toont the beschikbaare bekwaamheden voor iedere geactiveerde account. De laatste lijn vat de bekwaamheden samen die een effect hebben op ten minste een account."
+
+#: acct_features.c:103
+msgid "Account"
+msgstr "Account"
+
+#. widgets that can be modifier along dialog lifetime
+#: status_dialog.c:100
+msgid "Status selection"
+msgstr "Status selectie"
+
+#. widgets that are not modified
+#: status_dialog.c:115
+msgid "Select your status..."
+msgstr "Selecteer uw status..."
+
+#: status_dialog.c:116
+msgid "This will change your current status for every account which supports it."
+msgstr "Dat zal U lopend status veranderen voor iedere account die het verdraagt."
+
+#: status_dialog.c:132
+msgid "Status"
+msgstr "Status"
+
+#. widgets that can be modifier along dialog lifetime
+#: mood_dialog.c:101
+msgid "Mood selection"
+msgstr "Humeur selectie"
+
+#. widgets that are not modified
+#: mood_dialog.c:116
+msgid "Select your mood..."
+msgstr "Selecteer uw humeur..."
+
+#: mood_dialog.c:117
+msgid "This will change your mood for every account which supports it."
+msgstr "Dat zal U humeur veranderen vor iedere account die het verdraagt."
+
+#: mood_dialog.c:201
+#: mood_dialog.c:203
+#: widget_gtk.c:276
+msgid "None"
+msgstr "Niets"
#: preferences.c:50
msgid "Left"
msgstr "Links"
#: preferences.c:51
msgid "Center"
msgstr "Midden"
#: preferences.c:52
msgid "Right"
msgstr "Rechts"
#: preferences.c:58
msgid "Top"
msgstr "Boven"
#: preferences.c:59
msgid "Bottom"
msgstr "Beneden"
-#: preferences.c:130
+#: preferences.c:131
msgid "_Nickname markup"
msgstr "_Bijnaam baken"
-#: preferences.c:131
+#: preferences.c:132
+#, c-format
+msgid "Change the markup used to display the nickname using the Pango Markup Language where %n is replaced with your nickname."
+msgstr "Veranderd het baken die gebruikt werd om de bijnaam te displayen, door het gebruiken van de Pango Markup Language waar %n vervangen word door uw bijnaam."
+
+#: preferences.c:135
msgid "Nickname markup _hovered"
msgstr "Bijnaam baken _overgezweefd"
-#: preferences.c:132
+#: preferences.c:137
+#, c-format
+msgid "Change the markup used to display the nickname when hovered by the mouse using the Pango Markup Language where %n is replaced with your nickname."
+msgstr "Veranderd het baken die gebruikt werd om de bijnaam te displayen wanneer men er met de muis overzweefd, door het gebruiken van de Pango Markup language waar %n vervangen word door uw bijnaam."
+
+#: preferences.c:141
msgid "Personal _message markup"
msgstr "Persoonlijk _bericht baken"
-#: preferences.c:133
+#: preferences.c:143
+#, c-format
+msgid "Change the markup used to display the personal message using the Pango Markup Language where %m is replaced with your personal message."
+msgstr "veranderd het baken die gebruikt werd om het persoonlijk bericht te displayen, door het gebruiken van de Pango Markup Language waar %m vervangen word door uw persoonlijk bericht."
+
+#: preferences.c:147
msgid "Personal message markup _hovered"
msgstr "Persoonlijk bericht baken _overgezweefd"
-#: preferences.c:144
+#: preferences.c:149
+#, c-format
+msgid "Change the markup used to display the personal message when hovered by the mouse using the Pango Markup Language where %m is replaced with your personal message."
+msgstr "Veranderd het baken die gebruikt werd om het persoonlijk bericht te displayen wanneer men er met de muis overzweefd, door het gebruiken van de Pango Markup Language waar %m vervangen word door uw persoonlijke bericht."
+
+#: preferences.c:164
msgid "Align _nickname"
msgstr "Richten _bijnaam"
-#: preferences.c:145
+#: preferences.c:166
+msgid "Alignment of the nickname into the bar."
+msgstr "Alignment of the nickname into the bar."
+
+#: preferences.c:168
msgid "Align personal _message"
msgstr "Richten persoonlijk _bericht"
-#: preferences.c:146
+#: preferences.c:170
+msgid "Alignment of the personal message into the bar."
+msgstr "Het zetten van het persoonlijk bericht in de balk"
+
+#: preferences.c:172
msgid "Widget _position in the buddy list"
msgstr "Werkbalk _positie in contactlijst"
-#: preferences.c:152
+#: preferences.c:174
+msgid "Position of the widget into pidgin's buddy list."
+msgstr "Positie van de werkbalk in Pidgin contactlijst."
+
+#: preferences.c:181
msgid "Hide _statusbox"
msgstr "Verberg _statusbox"
-#: preferences.c:153
+#: preferences.c:182
+msgid "Show or hide the Pidgin's default statusbox."
+msgstr "Toon of verberg Pidgins bij verstek statusbox."
+
+#: preferences.c:184
msgid "_Ignore status changes"
msgstr "_Negeren van status negeren"
-#: preferences.c:154
+#: preferences.c:185
+msgid "Ignore changes made to status from outside the widget. This include changes made in Pidgin's default statusbox and other plugins."
+msgstr "Negeer de veranderingen van de status als ze van buiten de balk gemaakt zijn, dit omvat veranderingen gemaakt in Pidgins bij verstek statusbox en andere plugins."
+
+#: preferences.c:189
msgid "Use a frame for _entry"
msgstr "Gebruik een kader voor _textinvoer"
-#: preferences.c:155
+#: preferences.c:190
+msgid "Enable or disable the use of a frame around the entries when editing the nickname or personal message from the bar."
+msgstr "Stelt of schakelt het gebruik van een kader uit rond de invoer van de balk wanneer men de bijnaam of het persoolijk bericht bewerkt."
+
+#: preferences.c:193
msgid "_Swap left and right click"
msgstr "_Keer linkse and rechtse klik om"
-#: preferences.c:156
+#: preferences.c:194
+msgid "Swap the role of left and right click to edit the nickname or personal message in the bar."
+msgstr "Keer de rol van linkse en rechtse klik om de bijnaam of persoonlijk bericht te bewerken in de balk."
+
+#: preferences.c:197
msgid "Use a _compact bar"
msgstr "gebruikt een _compacte balk"
-#: preferences.c:157
+#: preferences.c:198
+msgid "Reduce the size of the widget putting the nickname and personal message on one line."
+msgstr "Verminderd de maat van de werkbalk door de bijnaam en persoonlijn bericht op een lijn te zetten."
+
+#: preferences.c:201
msgid "_Reset status messages"
msgstr "_Opmaak status berichten"
+#: preferences.c:202
+msgid "Clear the status messages when Pidgin restart (except for personal message). By default these messages are saved in the preferences and reactivated when pidgin restart."
+msgstr "Wiss de status berichten uit wanneer Pidgin herstart (uitgezonderd voor het persoonlijk bericht), bij verstek worden deze berichten opgeslagen in de voorkeuren en gereactiveerd als Pidgin terug opstart."
+
#. preferences
#. preference root
#. empty messages to display at first installation
#: preferences.h:33
msgid "<Enter nickname here>"
msgstr "<Hier bijnaam invoeren>"
#: preferences.h:34
msgid "<Enter personal message here>"
msgstr "<Hier persoonlijk bericht iuvoeren>"
-#: widget_gtk.c:94
+#: actions.c:87
+#: widget.c:309
msgid "Change nickname"
msgstr "Veranderd bijnaam"
-#: widget_gtk.c:95
+#: actions.c:88
+msgid "Change personal message"
+msgstr "Richten persoonlijk bericht"
+
+#: actions.c:89
+msgid "Change status"
+msgstr "Veranderd status"
+
+#: actions.c:90
+msgid "Change mood"
+msgstr "Veranderd humeur"
+
+#: actions.c:91
+msgid "Change icon"
+msgstr "Veranderd icoon"
+
+#: widget.c:310
msgid "Enter your nickname here..."
msgstr "Hier U bijnaam invoeren..."
-#: widget_gtk.c:96
+#: widget.c:311
msgid "This will change your nickname for every account which supports it."
msgstr "Dat zal U bijnaam veranderen vor iedere account die het verdraagt."
-#: widget_gtk.c:102 widget_gtk.c:246
+#: widget.c:317
+#: widget.c:531
msgid "OK"
msgstr "OK"
-#: widget_gtk.c:104 widget_gtk.c:248
+#: widget.c:319
+#: widget.c:533
msgid "Cancel"
msgstr "Annuleren"
-#: widget_gtk.c:197
+#: widget.c:476
msgid "_Mood message"
msgstr "_Humeur bericht"
-#: widget_gtk.c:198
+#: widget.c:477
msgid "Current song"
msgstr "Huidig lied"
-#: widget_gtk.c:199
+#: widget.c:478
msgid "Song _title"
msgstr "Lied _tijtel"
-#: widget_gtk.c:200
+#: widget.c:479
msgid "Song _artist"
msgstr "Lied _artiest"
-#: widget_gtk.c:201
+#: widget.c:480
msgid "Song al_bum"
msgstr "Lied al_bum"
-#: widget_gtk.c:202
+#: widget.c:481
msgid "MSN pecan extra attributes"
msgstr "MSN pecan extra parameters"
-#: widget_gtk.c:203
+#: widget.c:482
msgid "_Game name"
msgstr "_Spelnaam"
-#: widget_gtk.c:204
+#: widget.c:483
msgid "_Office app name"
msgstr "_Office app naam"
-#: widget_gtk.c:210
+#: widget.c:489
msgid "Status and mood message"
msgstr "Status en humeur bericht"
-#: widget_gtk.c:214
+#: widget.c:494
msgid "_Personal message"
msgstr "_Persoonlijk bericht"
-#: widget_gtk.c:240
+#: widget.c:525
msgid "Change status messages"
msgstr "Veranderd status berichten"
-#: widget_gtk.c:241
+#: widget.c:526
msgid "Enter status message..."
msgstr "Voert Status berichten in..."
-#: widget_gtk.c:242
+#: widget.c:527
msgid "This will change some status messages for every account which supports it, please be advised that some are inconsistent between each other."
-msgstr"Dat zal sommige status berichten voor iedere account die het verdraagt veranderen, Gelieve nota te nemen dat sommige inconsequent zijn onder elkaar."
+msgstr "Dat zal sommige status berichten veranderen voor iedere account die het verdraagt, houd er a.u.b rekening mee dat sommige inconsequent zijn tussen elkaar."
-#: widget_gtk.c:361
-msgid "None"
-msgstr "Niets"
|
gawen947/pidgin-pbar
|
c665685a592da785b4eaa50ae6c94dd297dcc9f2
|
Factorisation
|
diff --git a/widget.c b/widget.c
index 8b8c5e6..8d66fea 100644
--- a/widget.c
+++ b/widget.c
@@ -1,677 +1,692 @@
/* File: widget.c
- Time-stamp: <2011-06-17 17:49:04 gawen>
+ Time-stamp: <2011-06-17 19:38:35 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "pbar.h"
#include "widget.h"
#include "widget_gtk.h"
#include "widget_prpl.h"
#include "preferences.h"
#include "purple.h"
#include "gtk.h"
/* we only have one widget per plugin
but this might change in the future */
struct widget *bar;
void create_widget()
{
/* we need this when the bar is reset for example
using the preferences dialog */
if(!bar) {
bar = g_malloc(sizeof(struct widget));
memset(bar, 0, sizeof(struct widget));
check_available_features();
}
/* widgets that can possibly be modified along plugin's execution */
bar->icon = gtk_image_new();
bar->status = gtk_button_new_from_stock(NULL);
bar->mood = gtk_button_new_from_stock(NULL);
bar->name_label = gtk_label_new(NULL);
bar->name_eventbox = gtk_event_box_new();
bar->name_entry = gtk_entry_new();
bar->pm_label = gtk_label_new(NULL);
bar->pm_eventbox = gtk_event_box_new();
bar->pm_entry = gtk_entry_new();
bar->hbox = gtk_hbox_new(FALSE, 2);
bar->icon_eventbox = gtk_event_box_new();
bar->status_menu = gtk_menu_new();
bar->mood_menu = gtk_menu_new();
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(bar), bar->hbox);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->status_menu);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->mood_menu);
/* widgets that are not modified */
GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
GtkWidget *hbox1 = gtk_hbox_new(FALSE, 2);
GtkWidget *hbox2 = gtk_hbox_new(FALSE, 2);
/* setup widgets */
gtk_label_set_ellipsize(GTK_LABEL(bar->name_label), PANGO_ELLIPSIZE_END);
gtk_label_set_ellipsize(GTK_LABEL(bar->pm_label), PANGO_ELLIPSIZE_END);
gtk_label_set_max_width_chars(GTK_LABEL(bar->name_label), 50);
gtk_button_set_relief(GTK_BUTTON(bar->status), GTK_RELIEF_NONE);
gtk_button_set_relief(GTK_BUTTON(bar->mood), GTK_RELIEF_NONE);
gtk_widget_set_can_focus(bar->name_eventbox, FALSE);
gtk_widget_set_can_focus(bar->pm_eventbox, FALSE);
gtk_widget_set_can_focus(bar->status, FALSE);
gtk_widget_set_can_focus(bar->mood, FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->icon_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->name_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->pm_eventbox), FALSE);
/* pack widgets */
gtk_container_add(GTK_CONTAINER(bar->name_eventbox), bar->name_label);
gtk_container_add(GTK_CONTAINER(bar->pm_eventbox), bar->pm_label);
gtk_container_add(GTK_CONTAINER(bar->icon_eventbox), bar->icon);
if(purple_prefs_get_bool(PREF "/compact")) {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
}
else {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0);
}
gtk_box_pack_start(GTK_BOX(bar->hbox), bar->icon_eventbox, FALSE, FALSE, 5);
gtk_box_pack_start(GTK_BOX(bar->hbox), vbox, TRUE, TRUE, 0);
/* pack at top of the buddy list and fallback to top
if the position option is unknown */
void (*gtk_box_pack)(GtkBox *, GtkWidget *, gboolean, gboolean, guint) = gtk_box_pack_start;
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
switch(purple_prefs_get_int(PREF "/widget-position")) {
case(POSITION_TOP):
gtk_box_pack = gtk_box_pack_start;
break;
case(POSITION_BOTTOM):
gtk_box_pack = gtk_box_pack_end;
break;
};
gtk_box_pack(GTK_BOX(blist->vbox), bar->hbox, FALSE, TRUE, 2);
gtk_box_reorder_child(GTK_BOX(blist->vbox), bar->hbox, 0);
/* setup initial states */
bar->gtk_hnd = NULL;
bar->gtk_inst = NULL;
bar->hover_name = FALSE;
bar->hover_pm = FALSE;
bar->name_entry_activated = FALSE;
bar->pm_entry_activated = FALSE;
bar->name_dialog = FALSE;
bar->pm_dialog = FALSE;
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ bar->icon_eventbox, "button-press-event", cb_buddy_icon },
{ bar->icon_eventbox, "enter-notify-event", cb_buddy_icon_enter },
{ bar->icon_eventbox, "leave-notify-event", cb_buddy_icon_leave },
{ bar->name_eventbox, "button-press-event", cb_name },
{ bar->name_eventbox, "enter-notify-event", cb_name_enter },
{ bar->name_eventbox, "leave-notify-event", cb_name_leave },
{ bar->name_entry, "activate", cb_name_entry },
{ bar->name_entry, "focus-out-event", cb_name_entry_focus_out },
{ bar->pm_eventbox, "button-press-event", cb_pm },
{ bar->pm_eventbox, "enter-notify-event", cb_pm_enter },
{ bar->pm_eventbox, "leave-notify-event", cb_pm_leave },
{ bar->pm_entry, "activate", cb_pm_entry },
{ bar->pm_entry, "focus-out-event", cb_pm_entry_focus_out },
{ bar->status, "clicked", cb_status_button },
{ bar->mood, "clicked", cb_mood_button },
{ NULL, NULL, NULL }
};
/* purple signals and callback */
const struct pbar_prpl_signal p_signal_connections[] = {
{ purple_accounts_get_handle(), "account-status-changed", cb_status },
{ purple_connections_get_handle(), "signed-on", cb_signed_on },
{ purple_connections_get_handle(), "signed-off", cb_signed_off },
{ NULL, NULL, NULL }
};
/* purple preferences signals and callback */
const struct pbar_prpl_signal pp_signal_connections[] = {
{ bar, PIDGIN_PREFS_ROOT "/accounts/buddyicon", cb_buddy_icon_update },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(bar), g_signal_connections, NULL);
prpl_connect_signals(PBAR_WIDGET(bar), p_signal_connections, NULL);
prpl_prefs_connect_signals(PBAR_WIDGET(bar), pp_signal_connections, NULL);
/* show everything */
gtk_widget_show_all(bar->hbox);
gtk_widget_hide(bar->name_entry);
gtk_widget_hide(bar->pm_entry);
/* inform that the bar is installed */
widget_set_all_sensitive(FALSE);
update_available_widgets();
bar->installed = TRUE;
}
static void free_inner_widget()
{
g_return_if_fail(bar->installed);
bar->installed = FALSE;
/* disconnect purple and prefs signals */
prpl_disconnect_signals(PBAR_WIDGET(bar));
prpl_prefs_disconnect_signals(PBAR_WIDGET(bar));
gtk_destroy(PBAR_WIDGET(bar)); /* destroy widgets */
}
void reset_widget()
{
free_inner_widget();
/* create widget but do not free the structure itself
to save references for available features */
create_widget();
}
void destroy_widget()
{
free_inner_widget();
g_free(bar); /* free widget */
bar = NULL;
}
/* load preferences into our widget */
void init_widget()
{
g_return_if_fail(bar->installed);
/* entry frame */
gboolean state = purple_prefs_get_bool(PREF "/frame-entry");
set_widget_entry_frame(state);
/* nickname */
const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup");
const gchar *value = purple_prefs_get_string(PREF "/nickname");
int jtype = purple_prefs_get_int(PREF "/nickname-justify");
set_widget_name(markup, value);
set_widget_name_justify(jtype);
/* personal message */
markup = purple_prefs_get_string(PREF "/personal-message-markup");
value = purple_prefs_get_string(PREF "/personal-message");
jtype = purple_prefs_get_int(PREF "/personal-message-justify");
set_widget_pm(markup, value);
set_widget_pm_justify(jtype);
/* buddy icon */
GdkPixbuf *icon = get_buddy_icon();
set_widget_icon(icon);
/* mood image */
const gchar *current_mood = purple_prefs_get_string(PREF "/mood");
gchar *path = get_mood_icon_path(current_mood);
set_widget_mood(path);
g_free(path);
/* status image */
const gchar *stock = get_status_stock_id();
set_widget_status(stock);
/* fill status menu */
GList *accts = purple_accounts_get_all_active();
GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = (PurpleAccount *)accts->data;
GList *types = purple_account_get_status_types(account);
for(; types ; types = types->next) {
PurpleStatusType *type = (PurpleStatusType *)types->data;
PurpleStatusPrimitive prim;
const gchar *stock, *status_name;
GtkWidget *menu_item, *icon;
if(!purple_status_type_is_user_settable(type) ||
purple_status_type_is_independent(type))
continue;
prim = purple_status_type_get_primitive(type);
stock = pidgin_stock_id_from_status_primitive(prim);
if(g_hash_table_lookup(global_status, stock))
continue;
else
g_hash_table_insert(global_status, (gpointer)stock,
GINT_TO_POINTER(TRUE));
status_name = purple_status_type_get_name(type);
menu_item = gtk_image_menu_item_new_with_label(status_name);
icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), icon);
gtk_menu_shell_append(GTK_MENU_SHELL(bar->status_menu), menu_item);
g_signal_connect_swapped(menu_item, "activate",
G_CALLBACK(cb_status_menu),
(gpointer)type);
gtk_widget_show(menu_item);
}
}
g_hash_table_destroy(global_status);
/* statusbox hiding */
state = purple_prefs_get_bool(PREF "/hide-statusbox");
set_statusbox_visible(!state);
}
/* create a change name dialog */
void create_name_dialog()
{
const gchar *name = purple_prefs_get_string(PREF "/nickname");
if(!name || !strcmp(name, EMPTY_NAME))
name = "";
purple_request_input(thisplugin,
_("Change nickname"),
_("Enter your nickname here..."),
_("This will change your nickname "
"for every account which supports it."),
name,
FALSE,
FALSE,
NULL,
_("OK"),
G_CALLBACK(cb_name_apply),
_("Cancel"),
G_CALLBACK(cb_name_cancel),
NULL,
NULL,
NULL,
NULL);
bar->name_dialog = TRUE;
}
/* disable every features of the widget */
void widget_set_all_sensitive(gboolean sensitive)
{
GtkWidget *widgets[] = {
bar->icon,
bar->icon_eventbox,
bar->status,
bar->status_menu,
bar->mood,
bar->mood_menu,
bar->name_label,
bar->name_eventbox,
bar->name_entry,
bar->pm_label,
bar->pm_eventbox,
bar->pm_entry,
NULL
}; GtkWidget **w = widgets;
gboolean *attrs[] = {
&bar->mood_message,
&bar->current_song,
&bar->song_title,
&bar->song_album,
&bar->game_name,
&bar->office_app,
NULL
}; gboolean **a = attrs;
for(; *w ; w++)
gtk_widget_set_sensitive(*w, sensitive);
for(; *a ; a++)
**a = sensitive;
}
#define assert_ref(count, inc) (bar->count > 0 || inc > 0)
void check_available_features()
{
GList *a = purple_accounts_get_all_active();
for(; a ; a = a->next) {
PurpleAccount *acct = (PurpleAccount *)a->data;
if(purple_account_is_connected(acct))
update_available_features(acct, TRUE);
}
}
/* enable/disable features when an account changes */
void update_available_features(PurpleAccount *acct, gboolean enable)
{
int inc = 1;
PurplePlugin *plugin = purple_find_prpl(acct->protocol_id);
PurplePluginProtocolInfo *protocol = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
GHashTable *attrs = get_account_attrs(acct);
if(!enable)
inc = -1;
/* update references */
if(g_hash_table_lookup(attrs, "mood") &&
assert_ref(mood_ref, inc))
bar->mood_ref += inc;
if(g_hash_table_lookup(attrs, "moodtext") &&
assert_ref(mood_message_ref, inc))
bar->mood_message_ref += inc;
if(g_hash_table_lookup(attrs, "game") && assert_ref(game_name_ref, inc))
bar->game_name_ref += inc;
if(g_hash_table_lookup(attrs, "office") && assert_ref(office_app_ref, inc))
bar->office_app_ref += inc;
if(g_hash_table_lookup(attrs, "tune_title") &&
g_hash_table_lookup(attrs, "tune_artist") &&
g_hash_table_lookup(attrs, "tune_album") &&
assert_ref(current_song_ref, inc))
bar->current_song_ref += inc;
if(protocol->set_status && assert_ref(pm_ref, inc))
bar->pm_ref += inc;
if(protocol->set_buddy_icon && assert_ref(icon_ref, inc))
bar->icon_ref += inc;
if((!strcmp(acct->protocol_id, "prpl-jabber") || protocol->set_public_alias)&&
assert_ref(name_ref, inc))
bar->name_ref += inc;
if(assert_ref(status_ref, inc))
bar->status_ref += inc;
}
void update_available_widgets()
{
PurpleMood *mood = get_global_moods();
- gtk_widget_set_sensitive(bar->icon, bar->icon_ref);
- gtk_widget_set_sensitive(bar->icon_eventbox, bar->icon_ref);
- gtk_widget_set_sensitive(bar->status, bar->status_ref);
- gtk_widget_set_sensitive(bar->status_menu, bar->status_ref);
- gtk_widget_set_sensitive(bar->mood, bar->mood_ref && mood->mood);
- gtk_widget_set_sensitive(bar->mood_menu, bar->mood_ref && mood->mood);
- gtk_widget_set_sensitive(bar->name_label, bar->name_ref);
- gtk_widget_set_sensitive(bar->name_eventbox, bar->name_ref);
- gtk_widget_set_sensitive(bar->name_entry, bar->name_ref);
- gtk_widget_set_sensitive(bar->pm_label, bar->pm_ref + bar->mood_message_ref +\
- bar->game_name_ref + bar->office_app_ref +\
- bar->current_song_ref);
- gtk_widget_set_sensitive(bar->pm_eventbox, bar->pm_ref +
- bar->mood_message_ref + bar->game_name_ref +
- bar->office_app_ref + bar->current_song_ref);
- gtk_widget_set_sensitive(bar->pm_entry, bar->pm_ref +
- bar->mood_message_ref + bar->game_name_ref +
- bar->office_app_ref + bar->current_song_ref);
- bar->pm_message = bar->pm_ref;
- bar->mood_message = bar->mood_message_ref && mood->mood;
- bar->current_song = bar->current_song_ref;
- bar->song_title = bar->current_song_ref;
- bar->song_album = bar->current_song_ref;
- bar->game_name = bar->game_name;
- bar->office_app = bar->office_app;
+ const struct s_widget {
+ GtkWidget *widget;
+ gboolean sensitive;
+ } widgets[] = {
+ { bar->icon, bar->icon_ref },
+ { bar->icon_eventbox, bar->icon_ref },
+ { bar->status, bar->status_ref },
+ { bar->status_menu, bar->status_ref },
+ { bar->mood, bar->mood_ref && mood->mood },
+ { bar->mood_menu, bar->mood_ref && mood->mood },
+ { bar->name_label, bar->name_ref },
+ { bar->name_eventbox, bar->name_ref },
+ { bar->name_entry, bar->name_ref },
+ { bar->pm_label, bar->pm_ref + bar->mood_message_ref + bar->game_name_ref +\
+ bar->office_app_ref + bar->current_song_ref },
+ { bar->pm_eventbox, bar->pm_ref + bar->mood_message_ref+bar->game_name_ref+\
+ bar->office_app_ref + bar->current_song_ref },
+ { bar->pm_entry, bar->pm_ref + bar->mood_message_ref + bar->game_name_ref +\
+ bar->office_app_ref + bar->current_song_ref },
+ { NULL, FALSE }
+ }; const struct s_widget *w = widgets;
+
+ const struct s_attr {
+ gboolean *attr;
+ gboolean sensitive;
+ } attrs[] = {
+ { &bar->pm_message, bar->pm_ref },
+ { &bar->mood_message, bar->mood_message_ref && mood->mood },
+ { &bar->current_song, bar->current_song_ref },
+ { &bar->song_title, bar->current_song_ref },
+ { &bar->song_album, bar->current_song_ref },
+ { &bar->game_name, bar->game_name },
+ { &bar->office_app, bar->office_app },
+ { NULL, FALSE }
+ }; const struct s_attr *a = attrs;
+
+ for(; w->widget ; w++)
+ gtk_widget_set_sensitive(w->widget, w->sensitive);
+ for(; a->attr ; a++)
+ *a->attr = a->sensitive;
}
/* create a personal message dialog */
void create_pm_dialog()
{
PurpleRequestFields *fields;
PurpleRequestFieldGroup *group;
PurpleRequestField *field;
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
if(!pm || !strcmp(pm, EMPTY_PM))
pm = "";
const struct s_field {
const gchar *text;
const gchar *pref;
gboolean enable;
} groups[] = {
{ N_("_Mood message"), PREF "/mood-message", bar->mood_message },
{ N_("Current song"), NULL, bar->current_song },
{ N_("Song _title"), PREF "/tune-title", bar->current_song },
{ N_("Song _artist"), PREF "/tune-artist", bar->song_title },
{ N_("Song al_bum"), PREF "/tune-album", bar->song_album },
{ N_("MSN pecan extra attributes"), NULL, bar->game_name && bar->office_app },
{ N_("_Game name"), PREF "/game-message", bar->game_name },
{ N_("_Office app name"), PREF "/office-message", bar->office_app },
{ NULL, NULL },
{ NULL, NULL }
}; const struct s_field *g = groups;
fields = purple_request_fields_new();
group = purple_request_field_group_new(_("Status and mood message"));
purple_request_fields_add_group(fields, group);
if(bar->pm_message) {
field = purple_request_field_string_new(PREF "/personal-message",
_("_Personal message"),
pm,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
for(; g->pref ; g++) {
for(; g->pref ; g++) {
const gchar *message;
if(!g->enable)
continue;
else if(purple_prefs_get_bool(PREF "/reset-attrs"))
message = "";
else
message = purple_prefs_get_string(g->pref);
field = purple_request_field_string_new(g->pref,
_(g->text),
message,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
if(g->enable) {
group = purple_request_field_group_new(_(g->text));
purple_request_fields_add_group(fields, group);
}
}
purple_request_fields(thisplugin,
_("Change status messages"),
_("Enter status message..."),
_("This will change some status messages for every "
"account which supports it, please be advised "
"that some are inconsistent between each other."),
fields,
_("OK"),
G_CALLBACK(cb_pm_apply),
_("Cancel"),
G_CALLBACK(cb_pm_cancel),
NULL, NULL, NULL, NULL);
bar->pm_dialog = TRUE;
}
/* replace format character <c><r> with <n> string and escape with <c><c> */
static gchar * g_strreplacefmt(const gchar *s, gchar c, gchar r, const gchar *n)
{
int sn = strlen(n);
int sr = strlen(s);
int index = 0;
gchar *ret = g_malloc(sr);
for(; *s != '\0' ; s++) {
if(*s == c) {
s++;
if(*s == r) {
const gchar *i = n;
sr += sn;
ret = g_realloc(ret, sr);
for(; *i != '\0' ; i++, index++)
ret[index] = *i;
continue;
}
else if(*s != c || *s == '\0')
s--;
}
ret[index] = *s;
index++;
}
ret[index] = '\0';
return ret;
}
void set_widget_name(const gchar *markup, const gchar *name)
{
g_return_if_fail(markup && name && bar->installed);
gchar *escaped_name, *new;
/* translate name if needed */
if(!strcmp(name, EMPTY_NAME))
name = _(EMPTY_NAME);
escaped_name = g_markup_printf_escaped("%s", name);
new = g_strreplacefmt(markup, '%', 'n', escaped_name);
g_free(escaped_name);
gtk_label_set_markup(GTK_LABEL(bar->name_label), new);
g_free(new);
}
void set_widget_pm(const gchar *markup, const gchar *pm)
{
g_return_if_fail(markup && pm && bar->installed);
gchar *escaped_pm, *new;
/* translate pm if needed */
if(!strcmp(pm, EMPTY_PM))
pm = _(EMPTY_PM);
escaped_pm = g_markup_printf_escaped("%s", pm);
new = g_strreplacefmt(markup, '%', 'p', escaped_pm);
g_free(escaped_pm);
gtk_label_set_markup(GTK_LABEL(bar->pm_label), new);
g_free(new);
}
void set_widget_status(const gchar *stock)
{
g_return_if_fail(stock && bar->installed);
GtkWidget *icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_button_set_image(GTK_BUTTON(bar->status), icon);
gtk_button_set_label(GTK_BUTTON(bar->status), "");
}
void set_widget_mood(const gchar *path)
{
g_return_if_fail(path && bar->installed);
GtkWidget *mood = gtk_image_new_from_file(path);
gtk_button_set_image(GTK_BUTTON(bar->mood), mood);
gtk_button_set_label(GTK_BUTTON(bar->mood), "");
}
void set_widget_icon(GdkPixbuf *icon)
{
g_return_if_fail(bar->installed);
if(icon)
gtk_image_set_from_pixbuf(GTK_IMAGE(bar->icon), icon);
else
gtk_image_set_from_stock(GTK_IMAGE(bar->icon), GTK_STOCK_MISSING_IMAGE, 48);
}
/* convertion of int justification
to float justification for
gtk_misc_set_alignment */
static float int_jtype_to_float_jtype(int justify)
{
float ret = 0.; /* default to left */
switch(justify) {
case(JUSTIFY_LEFT):
ret = 0.;
break;
case(JUSTIFY_CENTER):
ret = .5;
break;
case(JUSTIFY_RIGHT):
ret = 1.;
break;
}
return ret;
}
void set_widget_name_justify(int justify)
{
g_return_if_fail(bar->installed);
float jtype = int_jtype_to_float_jtype(justify);
gtk_misc_set_alignment(GTK_MISC(bar->name_label), jtype, .5);
}
void set_widget_pm_justify(int justify)
{
g_return_if_fail(bar->installed);
float jtype = int_jtype_to_float_jtype(justify);
gtk_misc_set_alignment(GTK_MISC(bar->pm_label), jtype, .5);
}
void set_widget_entry_frame(gboolean use_frame)
{
g_return_if_fail(bar->installed);
gtk_entry_set_has_frame(GTK_ENTRY(bar->name_entry), use_frame);
gtk_entry_set_has_frame(GTK_ENTRY(bar->pm_entry), use_frame);
}
void set_statusbox_visible(gboolean visible)
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
GtkWidget *statusbox = blist->statusbox;
if(statusbox)
gtk_widget_set_visible(statusbox, visible);
}
gboolean get_widget_name_hover_state() { return bar->hover_name; }
gboolean get_widget_pm_hover_state() { return bar->hover_pm; }
|
gawen947/pidgin-pbar
|
c411c2b62d9b2c0449b042b52ec70fa7b2453e89
|
Code clean
|
diff --git a/widget.c b/widget.c
index a121a7b..8b8c5e6 100644
--- a/widget.c
+++ b/widget.c
@@ -1,689 +1,677 @@
/* File: widget.c
- Time-stamp: <2011-06-17 17:39:17 gawen>
+ Time-stamp: <2011-06-17 17:49:04 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "pbar.h"
#include "widget.h"
#include "widget_gtk.h"
#include "widget_prpl.h"
#include "preferences.h"
#include "purple.h"
#include "gtk.h"
/* we only have one widget per plugin
but this might change in the future */
struct widget *bar;
void create_widget()
{
/* we need this when the bar is reset for example
using the preferences dialog */
if(!bar) {
bar = g_malloc(sizeof(struct widget));
memset(bar, 0, sizeof(struct widget));
check_available_features();
}
/* widgets that can possibly be modified along plugin's execution */
bar->icon = gtk_image_new();
bar->status = gtk_button_new_from_stock(NULL);
bar->mood = gtk_button_new_from_stock(NULL);
bar->name_label = gtk_label_new(NULL);
bar->name_eventbox = gtk_event_box_new();
bar->name_entry = gtk_entry_new();
bar->pm_label = gtk_label_new(NULL);
bar->pm_eventbox = gtk_event_box_new();
bar->pm_entry = gtk_entry_new();
bar->hbox = gtk_hbox_new(FALSE, 2);
bar->icon_eventbox = gtk_event_box_new();
bar->status_menu = gtk_menu_new();
bar->mood_menu = gtk_menu_new();
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(bar), bar->hbox);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->status_menu);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->mood_menu);
/* widgets that are not modified */
GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
GtkWidget *hbox1 = gtk_hbox_new(FALSE, 2);
GtkWidget *hbox2 = gtk_hbox_new(FALSE, 2);
/* setup widgets */
gtk_label_set_ellipsize(GTK_LABEL(bar->name_label), PANGO_ELLIPSIZE_END);
gtk_label_set_ellipsize(GTK_LABEL(bar->pm_label), PANGO_ELLIPSIZE_END);
gtk_label_set_max_width_chars(GTK_LABEL(bar->name_label), 50);
gtk_button_set_relief(GTK_BUTTON(bar->status), GTK_RELIEF_NONE);
gtk_button_set_relief(GTK_BUTTON(bar->mood), GTK_RELIEF_NONE);
gtk_widget_set_can_focus(bar->name_eventbox, FALSE);
gtk_widget_set_can_focus(bar->pm_eventbox, FALSE);
gtk_widget_set_can_focus(bar->status, FALSE);
gtk_widget_set_can_focus(bar->mood, FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->icon_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->name_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->pm_eventbox), FALSE);
/* pack widgets */
gtk_container_add(GTK_CONTAINER(bar->name_eventbox), bar->name_label);
gtk_container_add(GTK_CONTAINER(bar->pm_eventbox), bar->pm_label);
gtk_container_add(GTK_CONTAINER(bar->icon_eventbox), bar->icon);
if(purple_prefs_get_bool(PREF "/compact")) {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
}
else {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0);
}
gtk_box_pack_start(GTK_BOX(bar->hbox), bar->icon_eventbox, FALSE, FALSE, 5);
gtk_box_pack_start(GTK_BOX(bar->hbox), vbox, TRUE, TRUE, 0);
/* pack at top of the buddy list and fallback to top
if the position option is unknown */
void (*gtk_box_pack)(GtkBox *, GtkWidget *, gboolean, gboolean, guint) = gtk_box_pack_start;
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
switch(purple_prefs_get_int(PREF "/widget-position")) {
case(POSITION_TOP):
gtk_box_pack = gtk_box_pack_start;
break;
case(POSITION_BOTTOM):
gtk_box_pack = gtk_box_pack_end;
break;
};
gtk_box_pack(GTK_BOX(blist->vbox), bar->hbox, FALSE, TRUE, 2);
gtk_box_reorder_child(GTK_BOX(blist->vbox), bar->hbox, 0);
/* setup initial states */
bar->gtk_hnd = NULL;
bar->gtk_inst = NULL;
bar->hover_name = FALSE;
bar->hover_pm = FALSE;
bar->name_entry_activated = FALSE;
bar->pm_entry_activated = FALSE;
bar->name_dialog = FALSE;
bar->pm_dialog = FALSE;
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ bar->icon_eventbox, "button-press-event", cb_buddy_icon },
{ bar->icon_eventbox, "enter-notify-event", cb_buddy_icon_enter },
{ bar->icon_eventbox, "leave-notify-event", cb_buddy_icon_leave },
{ bar->name_eventbox, "button-press-event", cb_name },
{ bar->name_eventbox, "enter-notify-event", cb_name_enter },
{ bar->name_eventbox, "leave-notify-event", cb_name_leave },
{ bar->name_entry, "activate", cb_name_entry },
{ bar->name_entry, "focus-out-event", cb_name_entry_focus_out },
{ bar->pm_eventbox, "button-press-event", cb_pm },
{ bar->pm_eventbox, "enter-notify-event", cb_pm_enter },
{ bar->pm_eventbox, "leave-notify-event", cb_pm_leave },
{ bar->pm_entry, "activate", cb_pm_entry },
{ bar->pm_entry, "focus-out-event", cb_pm_entry_focus_out },
{ bar->status, "clicked", cb_status_button },
{ bar->mood, "clicked", cb_mood_button },
{ NULL, NULL, NULL }
};
/* purple signals and callback */
const struct pbar_prpl_signal p_signal_connections[] = {
{ purple_accounts_get_handle(), "account-status-changed", cb_status },
{ purple_connections_get_handle(), "signed-on", cb_signed_on },
{ purple_connections_get_handle(), "signed-off", cb_signed_off },
{ NULL, NULL, NULL }
};
/* purple preferences signals and callback */
const struct pbar_prpl_signal pp_signal_connections[] = {
{ bar, PIDGIN_PREFS_ROOT "/accounts/buddyicon", cb_buddy_icon_update },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(bar), g_signal_connections, NULL);
prpl_connect_signals(PBAR_WIDGET(bar), p_signal_connections, NULL);
prpl_prefs_connect_signals(PBAR_WIDGET(bar), pp_signal_connections, NULL);
/* show everything */
gtk_widget_show_all(bar->hbox);
gtk_widget_hide(bar->name_entry);
gtk_widget_hide(bar->pm_entry);
/* inform that the bar is installed */
widget_set_all_sensitive(FALSE);
update_available_widgets();
bar->installed = TRUE;
}
static void free_inner_widget()
{
g_return_if_fail(bar->installed);
bar->installed = FALSE;
/* disconnect purple and prefs signals */
prpl_disconnect_signals(PBAR_WIDGET(bar));
prpl_prefs_disconnect_signals(PBAR_WIDGET(bar));
gtk_destroy(PBAR_WIDGET(bar)); /* destroy widgets */
}
void reset_widget()
{
free_inner_widget();
/* create widget but do not free the structure itself
to save references for available features */
create_widget();
}
void destroy_widget()
{
free_inner_widget();
g_free(bar); /* free widget */
bar = NULL;
}
/* load preferences into our widget */
void init_widget()
{
g_return_if_fail(bar->installed);
/* entry frame */
gboolean state = purple_prefs_get_bool(PREF "/frame-entry");
set_widget_entry_frame(state);
/* nickname */
const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup");
const gchar *value = purple_prefs_get_string(PREF "/nickname");
int jtype = purple_prefs_get_int(PREF "/nickname-justify");
set_widget_name(markup, value);
set_widget_name_justify(jtype);
/* personal message */
markup = purple_prefs_get_string(PREF "/personal-message-markup");
value = purple_prefs_get_string(PREF "/personal-message");
jtype = purple_prefs_get_int(PREF "/personal-message-justify");
set_widget_pm(markup, value);
set_widget_pm_justify(jtype);
/* buddy icon */
GdkPixbuf *icon = get_buddy_icon();
set_widget_icon(icon);
/* mood image */
const gchar *current_mood = purple_prefs_get_string(PREF "/mood");
gchar *path = get_mood_icon_path(current_mood);
set_widget_mood(path);
g_free(path);
/* status image */
const gchar *stock = get_status_stock_id();
set_widget_status(stock);
/* fill status menu */
GList *accts = purple_accounts_get_all_active();
GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = (PurpleAccount *)accts->data;
GList *types = purple_account_get_status_types(account);
for(; types ; types = types->next) {
PurpleStatusType *type = (PurpleStatusType *)types->data;
PurpleStatusPrimitive prim;
const gchar *stock, *status_name;
GtkWidget *menu_item, *icon;
if(!purple_status_type_is_user_settable(type) ||
purple_status_type_is_independent(type))
continue;
prim = purple_status_type_get_primitive(type);
stock = pidgin_stock_id_from_status_primitive(prim);
if(g_hash_table_lookup(global_status, stock))
continue;
else
g_hash_table_insert(global_status, (gpointer)stock,
GINT_TO_POINTER(TRUE));
status_name = purple_status_type_get_name(type);
menu_item = gtk_image_menu_item_new_with_label(status_name);
icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), icon);
gtk_menu_shell_append(GTK_MENU_SHELL(bar->status_menu), menu_item);
g_signal_connect_swapped(menu_item, "activate",
G_CALLBACK(cb_status_menu),
(gpointer)type);
gtk_widget_show(menu_item);
}
}
g_hash_table_destroy(global_status);
/* statusbox hiding */
state = purple_prefs_get_bool(PREF "/hide-statusbox");
set_statusbox_visible(!state);
}
/* create a change name dialog */
void create_name_dialog()
{
const gchar *name = purple_prefs_get_string(PREF "/nickname");
if(!name || !strcmp(name, EMPTY_NAME))
name = "";
purple_request_input(thisplugin,
_("Change nickname"),
_("Enter your nickname here..."),
_("This will change your nickname "
"for every account which supports it."),
name,
FALSE,
FALSE,
NULL,
_("OK"),
G_CALLBACK(cb_name_apply),
_("Cancel"),
G_CALLBACK(cb_name_cancel),
NULL,
NULL,
NULL,
NULL);
bar->name_dialog = TRUE;
}
/* disable every features of the widget */
void widget_set_all_sensitive(gboolean sensitive)
{
GtkWidget *widgets[] = {
bar->icon,
bar->icon_eventbox,
bar->status,
bar->status_menu,
bar->mood,
bar->mood_menu,
bar->name_label,
bar->name_eventbox,
bar->name_entry,
bar->pm_label,
bar->pm_eventbox,
bar->pm_entry,
NULL
}; GtkWidget **w = widgets;
gboolean *attrs[] = {
&bar->mood_message,
&bar->current_song,
&bar->song_title,
&bar->song_album,
&bar->game_name,
&bar->office_app,
NULL
}; gboolean **a = attrs;
for(; *w ; w++)
gtk_widget_set_sensitive(*w, sensitive);
for(; *a ; a++)
**a = sensitive;
}
#define assert_ref(count, inc) (bar->count > 0 || inc > 0)
void check_available_features()
{
GList *a = purple_accounts_get_all_active();
for(; a ; a = a->next) {
PurpleAccount *acct = (PurpleAccount *)a->data;
if(purple_account_is_connected(acct))
update_available_features(acct, TRUE);
}
}
/* enable/disable features when an account changes */
void update_available_features(PurpleAccount *acct, gboolean enable)
{
int inc = 1;
PurplePlugin *plugin = purple_find_prpl(acct->protocol_id);
PurplePluginProtocolInfo *protocol = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
GHashTable *attrs = get_account_attrs(acct);
if(!enable)
inc = -1;
/* update references */
if(g_hash_table_lookup(attrs, "mood") &&
assert_ref(mood_ref, inc))
bar->mood_ref += inc;
if(g_hash_table_lookup(attrs, "moodtext") &&
assert_ref(mood_message_ref, inc))
bar->mood_message_ref += inc;
if(g_hash_table_lookup(attrs, "game") && assert_ref(game_name_ref, inc))
bar->game_name_ref += inc;
if(g_hash_table_lookup(attrs, "office") && assert_ref(office_app_ref, inc))
bar->office_app_ref += inc;
if(g_hash_table_lookup(attrs, "tune_title") &&
g_hash_table_lookup(attrs, "tune_artist") &&
g_hash_table_lookup(attrs, "tune_album") &&
assert_ref(current_song_ref, inc))
bar->current_song_ref += inc;
if(protocol->set_status && assert_ref(pm_ref, inc))
bar->pm_ref += inc;
if(protocol->set_buddy_icon && assert_ref(icon_ref, inc))
bar->icon_ref += inc;
if((!strcmp(acct->protocol_id, "prpl-jabber") || protocol->set_public_alias)&&
assert_ref(name_ref, inc))
bar->name_ref += inc;
if(assert_ref(status_ref, inc))
bar->status_ref += inc;
-
- printf("account ref : %d %d %d %d %d %d %d %d %d %d\n",
- bar->icon_ref,
- bar->status_ref,
- bar->mood_ref,
- bar->name_ref,
- bar->pm_ref,
- bar->mood_message_ref,
- bar->current_song_ref,
- bar->song_title_ref,
- bar->game_name_ref,
- bar->office_app_ref);
}
void update_available_widgets()
{
PurpleMood *mood = get_global_moods();
gtk_widget_set_sensitive(bar->icon, bar->icon_ref);
gtk_widget_set_sensitive(bar->icon_eventbox, bar->icon_ref);
gtk_widget_set_sensitive(bar->status, bar->status_ref);
gtk_widget_set_sensitive(bar->status_menu, bar->status_ref);
gtk_widget_set_sensitive(bar->mood, bar->mood_ref && mood->mood);
gtk_widget_set_sensitive(bar->mood_menu, bar->mood_ref && mood->mood);
gtk_widget_set_sensitive(bar->name_label, bar->name_ref);
gtk_widget_set_sensitive(bar->name_eventbox, bar->name_ref);
gtk_widget_set_sensitive(bar->name_entry, bar->name_ref);
gtk_widget_set_sensitive(bar->pm_label, bar->pm_ref + bar->mood_message_ref +\
bar->game_name_ref + bar->office_app_ref +\
bar->current_song_ref);
gtk_widget_set_sensitive(bar->pm_eventbox, bar->pm_ref +
bar->mood_message_ref + bar->game_name_ref +
bar->office_app_ref + bar->current_song_ref);
gtk_widget_set_sensitive(bar->pm_entry, bar->pm_ref +
bar->mood_message_ref + bar->game_name_ref +
bar->office_app_ref + bar->current_song_ref);
bar->pm_message = bar->pm_ref;
bar->mood_message = bar->mood_message_ref && mood->mood;
bar->current_song = bar->current_song_ref;
bar->song_title = bar->current_song_ref;
bar->song_album = bar->current_song_ref;
bar->game_name = bar->game_name;
bar->office_app = bar->office_app;
}
/* create a personal message dialog */
void create_pm_dialog()
{
PurpleRequestFields *fields;
PurpleRequestFieldGroup *group;
PurpleRequestField *field;
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
if(!pm || !strcmp(pm, EMPTY_PM))
pm = "";
const struct s_field {
const gchar *text;
const gchar *pref;
gboolean enable;
} groups[] = {
{ N_("_Mood message"), PREF "/mood-message", bar->mood_message },
{ N_("Current song"), NULL, bar->current_song },
{ N_("Song _title"), PREF "/tune-title", bar->current_song },
{ N_("Song _artist"), PREF "/tune-artist", bar->song_title },
{ N_("Song al_bum"), PREF "/tune-album", bar->song_album },
{ N_("MSN pecan extra attributes"), NULL, bar->game_name && bar->office_app },
{ N_("_Game name"), PREF "/game-message", bar->game_name },
{ N_("_Office app name"), PREF "/office-message", bar->office_app },
{ NULL, NULL },
{ NULL, NULL }
}; const struct s_field *g = groups;
fields = purple_request_fields_new();
group = purple_request_field_group_new(_("Status and mood message"));
purple_request_fields_add_group(fields, group);
if(bar->pm_message) {
field = purple_request_field_string_new(PREF "/personal-message",
_("_Personal message"),
pm,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
for(; g->pref ; g++) {
for(; g->pref ; g++) {
const gchar *message;
if(!g->enable)
continue;
else if(purple_prefs_get_bool(PREF "/reset-attrs"))
message = "";
else
message = purple_prefs_get_string(g->pref);
field = purple_request_field_string_new(g->pref,
_(g->text),
message,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
if(g->enable) {
group = purple_request_field_group_new(_(g->text));
purple_request_fields_add_group(fields, group);
}
}
purple_request_fields(thisplugin,
_("Change status messages"),
_("Enter status message..."),
_("This will change some status messages for every "
"account which supports it, please be advised "
"that some are inconsistent between each other."),
fields,
_("OK"),
G_CALLBACK(cb_pm_apply),
_("Cancel"),
G_CALLBACK(cb_pm_cancel),
NULL, NULL, NULL, NULL);
bar->pm_dialog = TRUE;
}
/* replace format character <c><r> with <n> string and escape with <c><c> */
static gchar * g_strreplacefmt(const gchar *s, gchar c, gchar r, const gchar *n)
{
int sn = strlen(n);
int sr = strlen(s);
int index = 0;
gchar *ret = g_malloc(sr);
for(; *s != '\0' ; s++) {
if(*s == c) {
s++;
if(*s == r) {
const gchar *i = n;
sr += sn;
ret = g_realloc(ret, sr);
for(; *i != '\0' ; i++, index++)
ret[index] = *i;
continue;
}
else if(*s != c || *s == '\0')
s--;
}
ret[index] = *s;
index++;
}
ret[index] = '\0';
return ret;
}
void set_widget_name(const gchar *markup, const gchar *name)
{
g_return_if_fail(markup && name && bar->installed);
gchar *escaped_name, *new;
/* translate name if needed */
if(!strcmp(name, EMPTY_NAME))
name = _(EMPTY_NAME);
escaped_name = g_markup_printf_escaped("%s", name);
new = g_strreplacefmt(markup, '%', 'n', escaped_name);
g_free(escaped_name);
gtk_label_set_markup(GTK_LABEL(bar->name_label), new);
g_free(new);
}
void set_widget_pm(const gchar *markup, const gchar *pm)
{
g_return_if_fail(markup && pm && bar->installed);
gchar *escaped_pm, *new;
/* translate pm if needed */
if(!strcmp(pm, EMPTY_PM))
pm = _(EMPTY_PM);
escaped_pm = g_markup_printf_escaped("%s", pm);
new = g_strreplacefmt(markup, '%', 'p', escaped_pm);
g_free(escaped_pm);
gtk_label_set_markup(GTK_LABEL(bar->pm_label), new);
g_free(new);
}
void set_widget_status(const gchar *stock)
{
g_return_if_fail(stock && bar->installed);
GtkWidget *icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_button_set_image(GTK_BUTTON(bar->status), icon);
gtk_button_set_label(GTK_BUTTON(bar->status), "");
}
void set_widget_mood(const gchar *path)
{
g_return_if_fail(path && bar->installed);
GtkWidget *mood = gtk_image_new_from_file(path);
gtk_button_set_image(GTK_BUTTON(bar->mood), mood);
gtk_button_set_label(GTK_BUTTON(bar->mood), "");
}
void set_widget_icon(GdkPixbuf *icon)
{
g_return_if_fail(bar->installed);
if(icon)
gtk_image_set_from_pixbuf(GTK_IMAGE(bar->icon), icon);
else
gtk_image_set_from_stock(GTK_IMAGE(bar->icon), GTK_STOCK_MISSING_IMAGE, 48);
}
/* convertion of int justification
to float justification for
gtk_misc_set_alignment */
static float int_jtype_to_float_jtype(int justify)
{
float ret = 0.; /* default to left */
switch(justify) {
case(JUSTIFY_LEFT):
ret = 0.;
break;
case(JUSTIFY_CENTER):
ret = .5;
break;
case(JUSTIFY_RIGHT):
ret = 1.;
break;
}
return ret;
}
void set_widget_name_justify(int justify)
{
g_return_if_fail(bar->installed);
float jtype = int_jtype_to_float_jtype(justify);
gtk_misc_set_alignment(GTK_MISC(bar->name_label), jtype, .5);
}
void set_widget_pm_justify(int justify)
{
g_return_if_fail(bar->installed);
float jtype = int_jtype_to_float_jtype(justify);
gtk_misc_set_alignment(GTK_MISC(bar->pm_label), jtype, .5);
}
void set_widget_entry_frame(gboolean use_frame)
{
g_return_if_fail(bar->installed);
gtk_entry_set_has_frame(GTK_ENTRY(bar->name_entry), use_frame);
gtk_entry_set_has_frame(GTK_ENTRY(bar->pm_entry), use_frame);
}
void set_statusbox_visible(gboolean visible)
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
GtkWidget *statusbox = blist->statusbox;
if(statusbox)
gtk_widget_set_visible(statusbox, visible);
}
gboolean get_widget_name_hover_state() { return bar->hover_name; }
gboolean get_widget_pm_hover_state() { return bar->hover_pm; }
|
gawen947/pidgin-pbar
|
beabc9cbd78989fc22438a7359612aa6069f2d7c
|
Fix a bug with mood features not updated
|
diff --git a/widget.c b/widget.c
index b193c0c..a121a7b 100644
--- a/widget.c
+++ b/widget.c
@@ -1,676 +1,689 @@
/* File: widget.c
- Time-stamp: <2011-06-17 17:26:35 gawen>
+ Time-stamp: <2011-06-17 17:39:17 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "pbar.h"
#include "widget.h"
#include "widget_gtk.h"
#include "widget_prpl.h"
#include "preferences.h"
#include "purple.h"
#include "gtk.h"
/* we only have one widget per plugin
but this might change in the future */
struct widget *bar;
void create_widget()
{
/* we need this when the bar is reset for example
using the preferences dialog */
if(!bar) {
bar = g_malloc(sizeof(struct widget));
memset(bar, 0, sizeof(struct widget));
check_available_features();
}
/* widgets that can possibly be modified along plugin's execution */
bar->icon = gtk_image_new();
bar->status = gtk_button_new_from_stock(NULL);
bar->mood = gtk_button_new_from_stock(NULL);
bar->name_label = gtk_label_new(NULL);
bar->name_eventbox = gtk_event_box_new();
bar->name_entry = gtk_entry_new();
bar->pm_label = gtk_label_new(NULL);
bar->pm_eventbox = gtk_event_box_new();
bar->pm_entry = gtk_entry_new();
bar->hbox = gtk_hbox_new(FALSE, 2);
bar->icon_eventbox = gtk_event_box_new();
bar->status_menu = gtk_menu_new();
bar->mood_menu = gtk_menu_new();
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(bar), bar->hbox);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->status_menu);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->mood_menu);
/* widgets that are not modified */
GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
GtkWidget *hbox1 = gtk_hbox_new(FALSE, 2);
GtkWidget *hbox2 = gtk_hbox_new(FALSE, 2);
/* setup widgets */
gtk_label_set_ellipsize(GTK_LABEL(bar->name_label), PANGO_ELLIPSIZE_END);
gtk_label_set_ellipsize(GTK_LABEL(bar->pm_label), PANGO_ELLIPSIZE_END);
gtk_label_set_max_width_chars(GTK_LABEL(bar->name_label), 50);
gtk_button_set_relief(GTK_BUTTON(bar->status), GTK_RELIEF_NONE);
gtk_button_set_relief(GTK_BUTTON(bar->mood), GTK_RELIEF_NONE);
gtk_widget_set_can_focus(bar->name_eventbox, FALSE);
gtk_widget_set_can_focus(bar->pm_eventbox, FALSE);
gtk_widget_set_can_focus(bar->status, FALSE);
gtk_widget_set_can_focus(bar->mood, FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->icon_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->name_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->pm_eventbox), FALSE);
/* pack widgets */
gtk_container_add(GTK_CONTAINER(bar->name_eventbox), bar->name_label);
gtk_container_add(GTK_CONTAINER(bar->pm_eventbox), bar->pm_label);
gtk_container_add(GTK_CONTAINER(bar->icon_eventbox), bar->icon);
if(purple_prefs_get_bool(PREF "/compact")) {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
}
else {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0);
}
gtk_box_pack_start(GTK_BOX(bar->hbox), bar->icon_eventbox, FALSE, FALSE, 5);
gtk_box_pack_start(GTK_BOX(bar->hbox), vbox, TRUE, TRUE, 0);
/* pack at top of the buddy list and fallback to top
if the position option is unknown */
void (*gtk_box_pack)(GtkBox *, GtkWidget *, gboolean, gboolean, guint) = gtk_box_pack_start;
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
switch(purple_prefs_get_int(PREF "/widget-position")) {
case(POSITION_TOP):
gtk_box_pack = gtk_box_pack_start;
break;
case(POSITION_BOTTOM):
gtk_box_pack = gtk_box_pack_end;
break;
};
gtk_box_pack(GTK_BOX(blist->vbox), bar->hbox, FALSE, TRUE, 2);
gtk_box_reorder_child(GTK_BOX(blist->vbox), bar->hbox, 0);
/* setup initial states */
bar->gtk_hnd = NULL;
bar->gtk_inst = NULL;
bar->hover_name = FALSE;
bar->hover_pm = FALSE;
bar->name_entry_activated = FALSE;
bar->pm_entry_activated = FALSE;
bar->name_dialog = FALSE;
bar->pm_dialog = FALSE;
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ bar->icon_eventbox, "button-press-event", cb_buddy_icon },
{ bar->icon_eventbox, "enter-notify-event", cb_buddy_icon_enter },
{ bar->icon_eventbox, "leave-notify-event", cb_buddy_icon_leave },
{ bar->name_eventbox, "button-press-event", cb_name },
{ bar->name_eventbox, "enter-notify-event", cb_name_enter },
{ bar->name_eventbox, "leave-notify-event", cb_name_leave },
{ bar->name_entry, "activate", cb_name_entry },
{ bar->name_entry, "focus-out-event", cb_name_entry_focus_out },
{ bar->pm_eventbox, "button-press-event", cb_pm },
{ bar->pm_eventbox, "enter-notify-event", cb_pm_enter },
{ bar->pm_eventbox, "leave-notify-event", cb_pm_leave },
{ bar->pm_entry, "activate", cb_pm_entry },
{ bar->pm_entry, "focus-out-event", cb_pm_entry_focus_out },
{ bar->status, "clicked", cb_status_button },
{ bar->mood, "clicked", cb_mood_button },
{ NULL, NULL, NULL }
};
/* purple signals and callback */
const struct pbar_prpl_signal p_signal_connections[] = {
{ purple_accounts_get_handle(), "account-status-changed", cb_status },
{ purple_connections_get_handle(), "signed-on", cb_signed_on },
{ purple_connections_get_handle(), "signed-off", cb_signed_off },
{ NULL, NULL, NULL }
};
/* purple preferences signals and callback */
const struct pbar_prpl_signal pp_signal_connections[] = {
{ bar, PIDGIN_PREFS_ROOT "/accounts/buddyicon", cb_buddy_icon_update },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(bar), g_signal_connections, NULL);
prpl_connect_signals(PBAR_WIDGET(bar), p_signal_connections, NULL);
prpl_prefs_connect_signals(PBAR_WIDGET(bar), pp_signal_connections, NULL);
/* show everything */
gtk_widget_show_all(bar->hbox);
gtk_widget_hide(bar->name_entry);
gtk_widget_hide(bar->pm_entry);
/* inform that the bar is installed */
widget_set_all_sensitive(FALSE);
update_available_widgets();
bar->installed = TRUE;
}
static void free_inner_widget()
{
g_return_if_fail(bar->installed);
bar->installed = FALSE;
/* disconnect purple and prefs signals */
prpl_disconnect_signals(PBAR_WIDGET(bar));
prpl_prefs_disconnect_signals(PBAR_WIDGET(bar));
gtk_destroy(PBAR_WIDGET(bar)); /* destroy widgets */
}
void reset_widget()
{
free_inner_widget();
/* create widget but do not free the structure itself
to save references for available features */
create_widget();
}
void destroy_widget()
{
free_inner_widget();
g_free(bar); /* free widget */
bar = NULL;
}
/* load preferences into our widget */
void init_widget()
{
g_return_if_fail(bar->installed);
/* entry frame */
gboolean state = purple_prefs_get_bool(PREF "/frame-entry");
set_widget_entry_frame(state);
/* nickname */
const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup");
const gchar *value = purple_prefs_get_string(PREF "/nickname");
int jtype = purple_prefs_get_int(PREF "/nickname-justify");
set_widget_name(markup, value);
set_widget_name_justify(jtype);
/* personal message */
markup = purple_prefs_get_string(PREF "/personal-message-markup");
value = purple_prefs_get_string(PREF "/personal-message");
jtype = purple_prefs_get_int(PREF "/personal-message-justify");
set_widget_pm(markup, value);
set_widget_pm_justify(jtype);
/* buddy icon */
GdkPixbuf *icon = get_buddy_icon();
set_widget_icon(icon);
/* mood image */
const gchar *current_mood = purple_prefs_get_string(PREF "/mood");
gchar *path = get_mood_icon_path(current_mood);
set_widget_mood(path);
g_free(path);
/* status image */
const gchar *stock = get_status_stock_id();
set_widget_status(stock);
/* fill status menu */
GList *accts = purple_accounts_get_all_active();
GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = (PurpleAccount *)accts->data;
GList *types = purple_account_get_status_types(account);
for(; types ; types = types->next) {
PurpleStatusType *type = (PurpleStatusType *)types->data;
PurpleStatusPrimitive prim;
const gchar *stock, *status_name;
GtkWidget *menu_item, *icon;
if(!purple_status_type_is_user_settable(type) ||
purple_status_type_is_independent(type))
continue;
prim = purple_status_type_get_primitive(type);
stock = pidgin_stock_id_from_status_primitive(prim);
if(g_hash_table_lookup(global_status, stock))
continue;
else
g_hash_table_insert(global_status, (gpointer)stock,
GINT_TO_POINTER(TRUE));
status_name = purple_status_type_get_name(type);
menu_item = gtk_image_menu_item_new_with_label(status_name);
icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), icon);
gtk_menu_shell_append(GTK_MENU_SHELL(bar->status_menu), menu_item);
g_signal_connect_swapped(menu_item, "activate",
G_CALLBACK(cb_status_menu),
(gpointer)type);
gtk_widget_show(menu_item);
}
}
g_hash_table_destroy(global_status);
/* statusbox hiding */
state = purple_prefs_get_bool(PREF "/hide-statusbox");
set_statusbox_visible(!state);
}
/* create a change name dialog */
void create_name_dialog()
{
const gchar *name = purple_prefs_get_string(PREF "/nickname");
if(!name || !strcmp(name, EMPTY_NAME))
name = "";
purple_request_input(thisplugin,
_("Change nickname"),
_("Enter your nickname here..."),
_("This will change your nickname "
"for every account which supports it."),
name,
FALSE,
FALSE,
NULL,
_("OK"),
G_CALLBACK(cb_name_apply),
_("Cancel"),
G_CALLBACK(cb_name_cancel),
NULL,
NULL,
NULL,
NULL);
bar->name_dialog = TRUE;
}
/* disable every features of the widget */
void widget_set_all_sensitive(gboolean sensitive)
{
GtkWidget *widgets[] = {
bar->icon,
bar->icon_eventbox,
bar->status,
bar->status_menu,
bar->mood,
bar->mood_menu,
bar->name_label,
bar->name_eventbox,
bar->name_entry,
bar->pm_label,
bar->pm_eventbox,
bar->pm_entry,
NULL
}; GtkWidget **w = widgets;
gboolean *attrs[] = {
&bar->mood_message,
&bar->current_song,
&bar->song_title,
&bar->song_album,
&bar->game_name,
&bar->office_app,
NULL
}; gboolean **a = attrs;
for(; *w ; w++)
gtk_widget_set_sensitive(*w, sensitive);
for(; *a ; a++)
**a = sensitive;
}
#define assert_ref(count, inc) (bar->count > 0 || inc > 0)
void check_available_features()
{
GList *a = purple_accounts_get_all_active();
for(; a ; a = a->next) {
PurpleAccount *acct = (PurpleAccount *)a->data;
if(purple_account_is_connected(acct))
update_available_features(acct, TRUE);
}
}
/* enable/disable features when an account changes */
void update_available_features(PurpleAccount *acct, gboolean enable)
{
int inc = 1;
PurplePlugin *plugin = purple_find_prpl(acct->protocol_id);
PurplePluginProtocolInfo *protocol = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
- PurpleMood *mood = get_global_moods();
GHashTable *attrs = get_account_attrs(acct);
if(!enable)
inc = -1;
/* update references */
- if(g_hash_table_lookup(attrs, "mood") && mood->mood &&
+ if(g_hash_table_lookup(attrs, "mood") &&
assert_ref(mood_ref, inc))
bar->mood_ref += inc;
- if(g_hash_table_lookup(attrs, "moodtext") && mood->mood &&
+ if(g_hash_table_lookup(attrs, "moodtext") &&
assert_ref(mood_message_ref, inc))
bar->mood_message_ref += inc;
if(g_hash_table_lookup(attrs, "game") && assert_ref(game_name_ref, inc))
bar->game_name_ref += inc;
if(g_hash_table_lookup(attrs, "office") && assert_ref(office_app_ref, inc))
bar->office_app_ref += inc;
if(g_hash_table_lookup(attrs, "tune_title") &&
g_hash_table_lookup(attrs, "tune_artist") &&
g_hash_table_lookup(attrs, "tune_album") &&
assert_ref(current_song_ref, inc))
bar->current_song_ref += inc;
if(protocol->set_status && assert_ref(pm_ref, inc))
bar->pm_ref += inc;
if(protocol->set_buddy_icon && assert_ref(icon_ref, inc))
bar->icon_ref += inc;
if((!strcmp(acct->protocol_id, "prpl-jabber") || protocol->set_public_alias)&&
assert_ref(name_ref, inc))
bar->name_ref += inc;
if(assert_ref(status_ref, inc))
bar->status_ref += inc;
+
+ printf("account ref : %d %d %d %d %d %d %d %d %d %d\n",
+ bar->icon_ref,
+ bar->status_ref,
+ bar->mood_ref,
+ bar->name_ref,
+ bar->pm_ref,
+ bar->mood_message_ref,
+ bar->current_song_ref,
+ bar->song_title_ref,
+ bar->game_name_ref,
+ bar->office_app_ref);
}
void update_available_widgets()
{
+ PurpleMood *mood = get_global_moods();
+
gtk_widget_set_sensitive(bar->icon, bar->icon_ref);
gtk_widget_set_sensitive(bar->icon_eventbox, bar->icon_ref);
gtk_widget_set_sensitive(bar->status, bar->status_ref);
gtk_widget_set_sensitive(bar->status_menu, bar->status_ref);
- gtk_widget_set_sensitive(bar->mood, bar->mood_ref);
- gtk_widget_set_sensitive(bar->mood_menu, bar->mood_ref);
+ gtk_widget_set_sensitive(bar->mood, bar->mood_ref && mood->mood);
+ gtk_widget_set_sensitive(bar->mood_menu, bar->mood_ref && mood->mood);
gtk_widget_set_sensitive(bar->name_label, bar->name_ref);
gtk_widget_set_sensitive(bar->name_eventbox, bar->name_ref);
gtk_widget_set_sensitive(bar->name_entry, bar->name_ref);
gtk_widget_set_sensitive(bar->pm_label, bar->pm_ref + bar->mood_message_ref +\
bar->game_name_ref + bar->office_app_ref +\
bar->current_song_ref);
gtk_widget_set_sensitive(bar->pm_eventbox, bar->pm_ref +
bar->mood_message_ref + bar->game_name_ref +
bar->office_app_ref + bar->current_song_ref);
gtk_widget_set_sensitive(bar->pm_entry, bar->pm_ref +
bar->mood_message_ref + bar->game_name_ref +
bar->office_app_ref + bar->current_song_ref);
bar->pm_message = bar->pm_ref;
- bar->mood_message = bar->mood_message_ref;
+ bar->mood_message = bar->mood_message_ref && mood->mood;
bar->current_song = bar->current_song_ref;
bar->song_title = bar->current_song_ref;
bar->song_album = bar->current_song_ref;
bar->game_name = bar->game_name;
bar->office_app = bar->office_app;
}
/* create a personal message dialog */
void create_pm_dialog()
{
PurpleRequestFields *fields;
PurpleRequestFieldGroup *group;
PurpleRequestField *field;
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
if(!pm || !strcmp(pm, EMPTY_PM))
pm = "";
const struct s_field {
const gchar *text;
const gchar *pref;
gboolean enable;
} groups[] = {
{ N_("_Mood message"), PREF "/mood-message", bar->mood_message },
{ N_("Current song"), NULL, bar->current_song },
{ N_("Song _title"), PREF "/tune-title", bar->current_song },
{ N_("Song _artist"), PREF "/tune-artist", bar->song_title },
{ N_("Song al_bum"), PREF "/tune-album", bar->song_album },
{ N_("MSN pecan extra attributes"), NULL, bar->game_name && bar->office_app },
{ N_("_Game name"), PREF "/game-message", bar->game_name },
{ N_("_Office app name"), PREF "/office-message", bar->office_app },
{ NULL, NULL },
{ NULL, NULL }
}; const struct s_field *g = groups;
fields = purple_request_fields_new();
group = purple_request_field_group_new(_("Status and mood message"));
purple_request_fields_add_group(fields, group);
if(bar->pm_message) {
field = purple_request_field_string_new(PREF "/personal-message",
_("_Personal message"),
pm,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
for(; g->pref ; g++) {
for(; g->pref ; g++) {
const gchar *message;
if(!g->enable)
continue;
else if(purple_prefs_get_bool(PREF "/reset-attrs"))
message = "";
else
message = purple_prefs_get_string(g->pref);
field = purple_request_field_string_new(g->pref,
_(g->text),
message,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
if(g->enable) {
group = purple_request_field_group_new(_(g->text));
purple_request_fields_add_group(fields, group);
}
}
purple_request_fields(thisplugin,
_("Change status messages"),
_("Enter status message..."),
_("This will change some status messages for every "
"account which supports it, please be advised "
"that some are inconsistent between each other."),
fields,
_("OK"),
G_CALLBACK(cb_pm_apply),
_("Cancel"),
G_CALLBACK(cb_pm_cancel),
NULL, NULL, NULL, NULL);
bar->pm_dialog = TRUE;
}
/* replace format character <c><r> with <n> string and escape with <c><c> */
static gchar * g_strreplacefmt(const gchar *s, gchar c, gchar r, const gchar *n)
{
int sn = strlen(n);
int sr = strlen(s);
int index = 0;
gchar *ret = g_malloc(sr);
for(; *s != '\0' ; s++) {
if(*s == c) {
s++;
if(*s == r) {
const gchar *i = n;
sr += sn;
ret = g_realloc(ret, sr);
for(; *i != '\0' ; i++, index++)
ret[index] = *i;
continue;
}
else if(*s != c || *s == '\0')
s--;
}
ret[index] = *s;
index++;
}
ret[index] = '\0';
return ret;
}
void set_widget_name(const gchar *markup, const gchar *name)
{
g_return_if_fail(markup && name && bar->installed);
gchar *escaped_name, *new;
/* translate name if needed */
if(!strcmp(name, EMPTY_NAME))
name = _(EMPTY_NAME);
escaped_name = g_markup_printf_escaped("%s", name);
new = g_strreplacefmt(markup, '%', 'n', escaped_name);
g_free(escaped_name);
gtk_label_set_markup(GTK_LABEL(bar->name_label), new);
g_free(new);
}
void set_widget_pm(const gchar *markup, const gchar *pm)
{
g_return_if_fail(markup && pm && bar->installed);
gchar *escaped_pm, *new;
/* translate pm if needed */
if(!strcmp(pm, EMPTY_PM))
pm = _(EMPTY_PM);
escaped_pm = g_markup_printf_escaped("%s", pm);
new = g_strreplacefmt(markup, '%', 'p', escaped_pm);
g_free(escaped_pm);
gtk_label_set_markup(GTK_LABEL(bar->pm_label), new);
g_free(new);
}
void set_widget_status(const gchar *stock)
{
g_return_if_fail(stock && bar->installed);
GtkWidget *icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_button_set_image(GTK_BUTTON(bar->status), icon);
gtk_button_set_label(GTK_BUTTON(bar->status), "");
}
void set_widget_mood(const gchar *path)
{
g_return_if_fail(path && bar->installed);
GtkWidget *mood = gtk_image_new_from_file(path);
gtk_button_set_image(GTK_BUTTON(bar->mood), mood);
gtk_button_set_label(GTK_BUTTON(bar->mood), "");
}
void set_widget_icon(GdkPixbuf *icon)
{
g_return_if_fail(bar->installed);
if(icon)
gtk_image_set_from_pixbuf(GTK_IMAGE(bar->icon), icon);
else
gtk_image_set_from_stock(GTK_IMAGE(bar->icon), GTK_STOCK_MISSING_IMAGE, 48);
}
/* convertion of int justification
to float justification for
gtk_misc_set_alignment */
static float int_jtype_to_float_jtype(int justify)
{
float ret = 0.; /* default to left */
switch(justify) {
case(JUSTIFY_LEFT):
ret = 0.;
break;
case(JUSTIFY_CENTER):
ret = .5;
break;
case(JUSTIFY_RIGHT):
ret = 1.;
break;
}
return ret;
}
void set_widget_name_justify(int justify)
{
g_return_if_fail(bar->installed);
float jtype = int_jtype_to_float_jtype(justify);
gtk_misc_set_alignment(GTK_MISC(bar->name_label), jtype, .5);
}
void set_widget_pm_justify(int justify)
{
g_return_if_fail(bar->installed);
float jtype = int_jtype_to_float_jtype(justify);
gtk_misc_set_alignment(GTK_MISC(bar->pm_label), jtype, .5);
}
void set_widget_entry_frame(gboolean use_frame)
{
g_return_if_fail(bar->installed);
gtk_entry_set_has_frame(GTK_ENTRY(bar->name_entry), use_frame);
gtk_entry_set_has_frame(GTK_ENTRY(bar->pm_entry), use_frame);
}
void set_statusbox_visible(gboolean visible)
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
GtkWidget *statusbox = blist->statusbox;
if(statusbox)
gtk_widget_set_visible(statusbox, visible);
}
gboolean get_widget_name_hover_state() { return bar->hover_name; }
gboolean get_widget_pm_hover_state() { return bar->hover_pm; }
|
gawen947/pidgin-pbar
|
287298e9b6e901a5e2c323c37cfb68bd2df34c2b
|
Clean code
|
diff --git a/widget.c b/widget.c
index 185dfc0..b193c0c 100644
--- a/widget.c
+++ b/widget.c
@@ -1,688 +1,676 @@
/* File: widget.c
- Time-stamp: <2011-06-17 17:23:39 gawen>
+ Time-stamp: <2011-06-17 17:26:35 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "pbar.h"
#include "widget.h"
#include "widget_gtk.h"
#include "widget_prpl.h"
#include "preferences.h"
#include "purple.h"
#include "gtk.h"
/* we only have one widget per plugin
but this might change in the future */
struct widget *bar;
void create_widget()
{
/* we need this when the bar is reset for example
using the preferences dialog */
if(!bar) {
bar = g_malloc(sizeof(struct widget));
memset(bar, 0, sizeof(struct widget));
check_available_features();
}
/* widgets that can possibly be modified along plugin's execution */
bar->icon = gtk_image_new();
bar->status = gtk_button_new_from_stock(NULL);
bar->mood = gtk_button_new_from_stock(NULL);
bar->name_label = gtk_label_new(NULL);
bar->name_eventbox = gtk_event_box_new();
bar->name_entry = gtk_entry_new();
bar->pm_label = gtk_label_new(NULL);
bar->pm_eventbox = gtk_event_box_new();
bar->pm_entry = gtk_entry_new();
bar->hbox = gtk_hbox_new(FALSE, 2);
bar->icon_eventbox = gtk_event_box_new();
bar->status_menu = gtk_menu_new();
bar->mood_menu = gtk_menu_new();
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(bar), bar->hbox);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->status_menu);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->mood_menu);
/* widgets that are not modified */
GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
GtkWidget *hbox1 = gtk_hbox_new(FALSE, 2);
GtkWidget *hbox2 = gtk_hbox_new(FALSE, 2);
/* setup widgets */
gtk_label_set_ellipsize(GTK_LABEL(bar->name_label), PANGO_ELLIPSIZE_END);
gtk_label_set_ellipsize(GTK_LABEL(bar->pm_label), PANGO_ELLIPSIZE_END);
gtk_label_set_max_width_chars(GTK_LABEL(bar->name_label), 50);
gtk_button_set_relief(GTK_BUTTON(bar->status), GTK_RELIEF_NONE);
gtk_button_set_relief(GTK_BUTTON(bar->mood), GTK_RELIEF_NONE);
gtk_widget_set_can_focus(bar->name_eventbox, FALSE);
gtk_widget_set_can_focus(bar->pm_eventbox, FALSE);
gtk_widget_set_can_focus(bar->status, FALSE);
gtk_widget_set_can_focus(bar->mood, FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->icon_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->name_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->pm_eventbox), FALSE);
/* pack widgets */
gtk_container_add(GTK_CONTAINER(bar->name_eventbox), bar->name_label);
gtk_container_add(GTK_CONTAINER(bar->pm_eventbox), bar->pm_label);
gtk_container_add(GTK_CONTAINER(bar->icon_eventbox), bar->icon);
if(purple_prefs_get_bool(PREF "/compact")) {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
}
else {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0);
}
gtk_box_pack_start(GTK_BOX(bar->hbox), bar->icon_eventbox, FALSE, FALSE, 5);
gtk_box_pack_start(GTK_BOX(bar->hbox), vbox, TRUE, TRUE, 0);
/* pack at top of the buddy list and fallback to top
if the position option is unknown */
void (*gtk_box_pack)(GtkBox *, GtkWidget *, gboolean, gboolean, guint) = gtk_box_pack_start;
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
switch(purple_prefs_get_int(PREF "/widget-position")) {
case(POSITION_TOP):
gtk_box_pack = gtk_box_pack_start;
break;
case(POSITION_BOTTOM):
gtk_box_pack = gtk_box_pack_end;
break;
};
gtk_box_pack(GTK_BOX(blist->vbox), bar->hbox, FALSE, TRUE, 2);
gtk_box_reorder_child(GTK_BOX(blist->vbox), bar->hbox, 0);
/* setup initial states */
bar->gtk_hnd = NULL;
bar->gtk_inst = NULL;
bar->hover_name = FALSE;
bar->hover_pm = FALSE;
bar->name_entry_activated = FALSE;
bar->pm_entry_activated = FALSE;
bar->name_dialog = FALSE;
bar->pm_dialog = FALSE;
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ bar->icon_eventbox, "button-press-event", cb_buddy_icon },
{ bar->icon_eventbox, "enter-notify-event", cb_buddy_icon_enter },
{ bar->icon_eventbox, "leave-notify-event", cb_buddy_icon_leave },
{ bar->name_eventbox, "button-press-event", cb_name },
{ bar->name_eventbox, "enter-notify-event", cb_name_enter },
{ bar->name_eventbox, "leave-notify-event", cb_name_leave },
{ bar->name_entry, "activate", cb_name_entry },
{ bar->name_entry, "focus-out-event", cb_name_entry_focus_out },
{ bar->pm_eventbox, "button-press-event", cb_pm },
{ bar->pm_eventbox, "enter-notify-event", cb_pm_enter },
{ bar->pm_eventbox, "leave-notify-event", cb_pm_leave },
{ bar->pm_entry, "activate", cb_pm_entry },
{ bar->pm_entry, "focus-out-event", cb_pm_entry_focus_out },
{ bar->status, "clicked", cb_status_button },
{ bar->mood, "clicked", cb_mood_button },
{ NULL, NULL, NULL }
};
/* purple signals and callback */
const struct pbar_prpl_signal p_signal_connections[] = {
{ purple_accounts_get_handle(), "account-status-changed", cb_status },
{ purple_connections_get_handle(), "signed-on", cb_signed_on },
{ purple_connections_get_handle(), "signed-off", cb_signed_off },
{ NULL, NULL, NULL }
};
/* purple preferences signals and callback */
const struct pbar_prpl_signal pp_signal_connections[] = {
{ bar, PIDGIN_PREFS_ROOT "/accounts/buddyicon", cb_buddy_icon_update },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(bar), g_signal_connections, NULL);
prpl_connect_signals(PBAR_WIDGET(bar), p_signal_connections, NULL);
prpl_prefs_connect_signals(PBAR_WIDGET(bar), pp_signal_connections, NULL);
/* show everything */
gtk_widget_show_all(bar->hbox);
gtk_widget_hide(bar->name_entry);
gtk_widget_hide(bar->pm_entry);
/* inform that the bar is installed */
widget_set_all_sensitive(FALSE);
update_available_widgets();
bar->installed = TRUE;
}
static void free_inner_widget()
{
g_return_if_fail(bar->installed);
bar->installed = FALSE;
/* disconnect purple and prefs signals */
prpl_disconnect_signals(PBAR_WIDGET(bar));
prpl_prefs_disconnect_signals(PBAR_WIDGET(bar));
gtk_destroy(PBAR_WIDGET(bar)); /* destroy widgets */
}
void reset_widget()
{
free_inner_widget();
/* create widget but do not free the structure itself
to save references for available features */
create_widget();
}
void destroy_widget()
{
free_inner_widget();
g_free(bar); /* free widget */
bar = NULL;
}
/* load preferences into our widget */
void init_widget()
{
g_return_if_fail(bar->installed);
/* entry frame */
gboolean state = purple_prefs_get_bool(PREF "/frame-entry");
set_widget_entry_frame(state);
/* nickname */
const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup");
const gchar *value = purple_prefs_get_string(PREF "/nickname");
int jtype = purple_prefs_get_int(PREF "/nickname-justify");
set_widget_name(markup, value);
set_widget_name_justify(jtype);
/* personal message */
markup = purple_prefs_get_string(PREF "/personal-message-markup");
value = purple_prefs_get_string(PREF "/personal-message");
jtype = purple_prefs_get_int(PREF "/personal-message-justify");
set_widget_pm(markup, value);
set_widget_pm_justify(jtype);
/* buddy icon */
GdkPixbuf *icon = get_buddy_icon();
set_widget_icon(icon);
/* mood image */
const gchar *current_mood = purple_prefs_get_string(PREF "/mood");
gchar *path = get_mood_icon_path(current_mood);
set_widget_mood(path);
g_free(path);
/* status image */
const gchar *stock = get_status_stock_id();
set_widget_status(stock);
/* fill status menu */
GList *accts = purple_accounts_get_all_active();
GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = (PurpleAccount *)accts->data;
GList *types = purple_account_get_status_types(account);
for(; types ; types = types->next) {
PurpleStatusType *type = (PurpleStatusType *)types->data;
PurpleStatusPrimitive prim;
const gchar *stock, *status_name;
GtkWidget *menu_item, *icon;
if(!purple_status_type_is_user_settable(type) ||
purple_status_type_is_independent(type))
continue;
prim = purple_status_type_get_primitive(type);
stock = pidgin_stock_id_from_status_primitive(prim);
if(g_hash_table_lookup(global_status, stock))
continue;
else
g_hash_table_insert(global_status, (gpointer)stock,
GINT_TO_POINTER(TRUE));
status_name = purple_status_type_get_name(type);
menu_item = gtk_image_menu_item_new_with_label(status_name);
icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), icon);
gtk_menu_shell_append(GTK_MENU_SHELL(bar->status_menu), menu_item);
g_signal_connect_swapped(menu_item, "activate",
G_CALLBACK(cb_status_menu),
(gpointer)type);
gtk_widget_show(menu_item);
}
}
g_hash_table_destroy(global_status);
/* statusbox hiding */
state = purple_prefs_get_bool(PREF "/hide-statusbox");
set_statusbox_visible(!state);
}
/* create a change name dialog */
void create_name_dialog()
{
const gchar *name = purple_prefs_get_string(PREF "/nickname");
if(!name || !strcmp(name, EMPTY_NAME))
name = "";
purple_request_input(thisplugin,
_("Change nickname"),
_("Enter your nickname here..."),
_("This will change your nickname "
"for every account which supports it."),
name,
FALSE,
FALSE,
NULL,
_("OK"),
G_CALLBACK(cb_name_apply),
_("Cancel"),
G_CALLBACK(cb_name_cancel),
NULL,
NULL,
NULL,
NULL);
bar->name_dialog = TRUE;
}
/* disable every features of the widget */
void widget_set_all_sensitive(gboolean sensitive)
{
GtkWidget *widgets[] = {
bar->icon,
bar->icon_eventbox,
bar->status,
bar->status_menu,
bar->mood,
bar->mood_menu,
bar->name_label,
bar->name_eventbox,
bar->name_entry,
bar->pm_label,
bar->pm_eventbox,
bar->pm_entry,
NULL
}; GtkWidget **w = widgets;
gboolean *attrs[] = {
&bar->mood_message,
&bar->current_song,
&bar->song_title,
&bar->song_album,
&bar->game_name,
&bar->office_app,
NULL
}; gboolean **a = attrs;
for(; *w ; w++)
gtk_widget_set_sensitive(*w, sensitive);
for(; *a ; a++)
**a = sensitive;
}
#define assert_ref(count, inc) (bar->count > 0 || inc > 0)
void check_available_features()
{
GList *a = purple_accounts_get_all_active();
for(; a ; a = a->next) {
PurpleAccount *acct = (PurpleAccount *)a->data;
if(purple_account_is_connected(acct))
update_available_features(acct, TRUE);
}
}
/* enable/disable features when an account changes */
void update_available_features(PurpleAccount *acct, gboolean enable)
{
int inc = 1;
PurplePlugin *plugin = purple_find_prpl(acct->protocol_id);
PurplePluginProtocolInfo *protocol = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
PurpleMood *mood = get_global_moods();
GHashTable *attrs = get_account_attrs(acct);
if(!enable)
inc = -1;
/* update references */
if(g_hash_table_lookup(attrs, "mood") && mood->mood &&
assert_ref(mood_ref, inc))
bar->mood_ref += inc;
if(g_hash_table_lookup(attrs, "moodtext") && mood->mood &&
assert_ref(mood_message_ref, inc))
bar->mood_message_ref += inc;
if(g_hash_table_lookup(attrs, "game") && assert_ref(game_name_ref, inc))
bar->game_name_ref += inc;
if(g_hash_table_lookup(attrs, "office") && assert_ref(office_app_ref, inc))
bar->office_app_ref += inc;
if(g_hash_table_lookup(attrs, "tune_title") &&
g_hash_table_lookup(attrs, "tune_artist") &&
g_hash_table_lookup(attrs, "tune_album") &&
assert_ref(current_song_ref, inc))
bar->current_song_ref += inc;
if(protocol->set_status && assert_ref(pm_ref, inc))
bar->pm_ref += inc;
if(protocol->set_buddy_icon && assert_ref(icon_ref, inc))
bar->icon_ref += inc;
if((!strcmp(acct->protocol_id, "prpl-jabber") || protocol->set_public_alias)&&
assert_ref(name_ref, inc))
bar->name_ref += inc;
if(assert_ref(status_ref, inc))
bar->status_ref += inc;
-
- printf("account ref : %d %d %d %d %d %d %d %d %d %d\n",
- bar->icon_ref,
- bar->status_ref,
- bar->mood_ref,
- bar->name_ref,
- bar->pm_ref,
- bar->mood_message_ref,
- bar->current_song_ref,
- bar->song_title_ref,
- bar->game_name_ref,
- bar->office_app_ref);
}
void update_available_widgets()
{
gtk_widget_set_sensitive(bar->icon, bar->icon_ref);
gtk_widget_set_sensitive(bar->icon_eventbox, bar->icon_ref);
gtk_widget_set_sensitive(bar->status, bar->status_ref);
gtk_widget_set_sensitive(bar->status_menu, bar->status_ref);
gtk_widget_set_sensitive(bar->mood, bar->mood_ref);
gtk_widget_set_sensitive(bar->mood_menu, bar->mood_ref);
gtk_widget_set_sensitive(bar->name_label, bar->name_ref);
gtk_widget_set_sensitive(bar->name_eventbox, bar->name_ref);
gtk_widget_set_sensitive(bar->name_entry, bar->name_ref);
gtk_widget_set_sensitive(bar->pm_label, bar->pm_ref + bar->mood_message_ref +\
bar->game_name_ref + bar->office_app_ref +\
bar->current_song_ref);
gtk_widget_set_sensitive(bar->pm_eventbox, bar->pm_ref +
bar->mood_message_ref + bar->game_name_ref +
bar->office_app_ref + bar->current_song_ref);
gtk_widget_set_sensitive(bar->pm_entry, bar->pm_ref +
bar->mood_message_ref + bar->game_name_ref +
bar->office_app_ref + bar->current_song_ref);
bar->pm_message = bar->pm_ref;
bar->mood_message = bar->mood_message_ref;
bar->current_song = bar->current_song_ref;
bar->song_title = bar->current_song_ref;
bar->song_album = bar->current_song_ref;
bar->game_name = bar->game_name;
bar->office_app = bar->office_app;
}
/* create a personal message dialog */
void create_pm_dialog()
{
PurpleRequestFields *fields;
PurpleRequestFieldGroup *group;
PurpleRequestField *field;
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
if(!pm || !strcmp(pm, EMPTY_PM))
pm = "";
const struct s_field {
const gchar *text;
const gchar *pref;
gboolean enable;
} groups[] = {
{ N_("_Mood message"), PREF "/mood-message", bar->mood_message },
{ N_("Current song"), NULL, bar->current_song },
{ N_("Song _title"), PREF "/tune-title", bar->current_song },
{ N_("Song _artist"), PREF "/tune-artist", bar->song_title },
{ N_("Song al_bum"), PREF "/tune-album", bar->song_album },
{ N_("MSN pecan extra attributes"), NULL, bar->game_name && bar->office_app },
{ N_("_Game name"), PREF "/game-message", bar->game_name },
{ N_("_Office app name"), PREF "/office-message", bar->office_app },
{ NULL, NULL },
{ NULL, NULL }
}; const struct s_field *g = groups;
fields = purple_request_fields_new();
group = purple_request_field_group_new(_("Status and mood message"));
purple_request_fields_add_group(fields, group);
if(bar->pm_message) {
field = purple_request_field_string_new(PREF "/personal-message",
_("_Personal message"),
pm,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
for(; g->pref ; g++) {
for(; g->pref ; g++) {
const gchar *message;
if(!g->enable)
continue;
else if(purple_prefs_get_bool(PREF "/reset-attrs"))
message = "";
else
message = purple_prefs_get_string(g->pref);
field = purple_request_field_string_new(g->pref,
_(g->text),
message,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
if(g->enable) {
group = purple_request_field_group_new(_(g->text));
purple_request_fields_add_group(fields, group);
}
}
purple_request_fields(thisplugin,
_("Change status messages"),
_("Enter status message..."),
_("This will change some status messages for every "
"account which supports it, please be advised "
"that some are inconsistent between each other."),
fields,
_("OK"),
G_CALLBACK(cb_pm_apply),
_("Cancel"),
G_CALLBACK(cb_pm_cancel),
NULL, NULL, NULL, NULL);
bar->pm_dialog = TRUE;
}
/* replace format character <c><r> with <n> string and escape with <c><c> */
static gchar * g_strreplacefmt(const gchar *s, gchar c, gchar r, const gchar *n)
{
int sn = strlen(n);
int sr = strlen(s);
int index = 0;
gchar *ret = g_malloc(sr);
for(; *s != '\0' ; s++) {
if(*s == c) {
s++;
if(*s == r) {
const gchar *i = n;
sr += sn;
ret = g_realloc(ret, sr);
for(; *i != '\0' ; i++, index++)
ret[index] = *i;
continue;
}
else if(*s != c || *s == '\0')
s--;
}
ret[index] = *s;
index++;
}
ret[index] = '\0';
return ret;
}
void set_widget_name(const gchar *markup, const gchar *name)
{
g_return_if_fail(markup && name && bar->installed);
gchar *escaped_name, *new;
/* translate name if needed */
if(!strcmp(name, EMPTY_NAME))
name = _(EMPTY_NAME);
escaped_name = g_markup_printf_escaped("%s", name);
new = g_strreplacefmt(markup, '%', 'n', escaped_name);
g_free(escaped_name);
gtk_label_set_markup(GTK_LABEL(bar->name_label), new);
g_free(new);
}
void set_widget_pm(const gchar *markup, const gchar *pm)
{
g_return_if_fail(markup && pm && bar->installed);
gchar *escaped_pm, *new;
/* translate pm if needed */
if(!strcmp(pm, EMPTY_PM))
pm = _(EMPTY_PM);
escaped_pm = g_markup_printf_escaped("%s", pm);
new = g_strreplacefmt(markup, '%', 'p', escaped_pm);
g_free(escaped_pm);
gtk_label_set_markup(GTK_LABEL(bar->pm_label), new);
g_free(new);
}
void set_widget_status(const gchar *stock)
{
g_return_if_fail(stock && bar->installed);
GtkWidget *icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_button_set_image(GTK_BUTTON(bar->status), icon);
gtk_button_set_label(GTK_BUTTON(bar->status), "");
}
void set_widget_mood(const gchar *path)
{
g_return_if_fail(path && bar->installed);
GtkWidget *mood = gtk_image_new_from_file(path);
gtk_button_set_image(GTK_BUTTON(bar->mood), mood);
gtk_button_set_label(GTK_BUTTON(bar->mood), "");
}
void set_widget_icon(GdkPixbuf *icon)
{
g_return_if_fail(bar->installed);
if(icon)
gtk_image_set_from_pixbuf(GTK_IMAGE(bar->icon), icon);
else
gtk_image_set_from_stock(GTK_IMAGE(bar->icon), GTK_STOCK_MISSING_IMAGE, 48);
}
/* convertion of int justification
to float justification for
gtk_misc_set_alignment */
static float int_jtype_to_float_jtype(int justify)
{
float ret = 0.; /* default to left */
switch(justify) {
case(JUSTIFY_LEFT):
ret = 0.;
break;
case(JUSTIFY_CENTER):
ret = .5;
break;
case(JUSTIFY_RIGHT):
ret = 1.;
break;
}
return ret;
}
void set_widget_name_justify(int justify)
{
g_return_if_fail(bar->installed);
float jtype = int_jtype_to_float_jtype(justify);
gtk_misc_set_alignment(GTK_MISC(bar->name_label), jtype, .5);
}
void set_widget_pm_justify(int justify)
{
g_return_if_fail(bar->installed);
float jtype = int_jtype_to_float_jtype(justify);
gtk_misc_set_alignment(GTK_MISC(bar->pm_label), jtype, .5);
}
void set_widget_entry_frame(gboolean use_frame)
{
g_return_if_fail(bar->installed);
gtk_entry_set_has_frame(GTK_ENTRY(bar->name_entry), use_frame);
gtk_entry_set_has_frame(GTK_ENTRY(bar->pm_entry), use_frame);
}
void set_statusbox_visible(gboolean visible)
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
GtkWidget *statusbox = blist->statusbox;
if(statusbox)
gtk_widget_set_visible(statusbox, visible);
}
gboolean get_widget_name_hover_state() { return bar->hover_name; }
gboolean get_widget_pm_hover_state() { return bar->hover_pm; }
|
gawen947/pidgin-pbar
|
28954c607d0ba6d336a1a82ca49bc5502464b7ac
|
Fix bug when using a compact bar and features which will not disable after that
|
diff --git a/widget.c b/widget.c
index 9ce5ae7..185dfc0 100644
--- a/widget.c
+++ b/widget.c
@@ -1,688 +1,688 @@
/* File: widget.c
- Time-stamp: <2011-06-17 17:15:13 gawen>
+ Time-stamp: <2011-06-17 17:23:39 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "pbar.h"
#include "widget.h"
#include "widget_gtk.h"
#include "widget_prpl.h"
#include "preferences.h"
#include "purple.h"
#include "gtk.h"
/* we only have one widget per plugin
but this might change in the future */
struct widget *bar;
void create_widget()
{
/* we need this when the bar is reset for example
using the preferences dialog */
if(!bar) {
bar = g_malloc(sizeof(struct widget));
memset(bar, 0, sizeof(struct widget));
+ check_available_features();
}
/* widgets that can possibly be modified along plugin's execution */
bar->icon = gtk_image_new();
bar->status = gtk_button_new_from_stock(NULL);
bar->mood = gtk_button_new_from_stock(NULL);
bar->name_label = gtk_label_new(NULL);
bar->name_eventbox = gtk_event_box_new();
bar->name_entry = gtk_entry_new();
bar->pm_label = gtk_label_new(NULL);
bar->pm_eventbox = gtk_event_box_new();
bar->pm_entry = gtk_entry_new();
bar->hbox = gtk_hbox_new(FALSE, 2);
bar->icon_eventbox = gtk_event_box_new();
bar->status_menu = gtk_menu_new();
bar->mood_menu = gtk_menu_new();
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(bar), bar->hbox);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->status_menu);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->mood_menu);
/* widgets that are not modified */
GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
GtkWidget *hbox1 = gtk_hbox_new(FALSE, 2);
GtkWidget *hbox2 = gtk_hbox_new(FALSE, 2);
/* setup widgets */
gtk_label_set_ellipsize(GTK_LABEL(bar->name_label), PANGO_ELLIPSIZE_END);
gtk_label_set_ellipsize(GTK_LABEL(bar->pm_label), PANGO_ELLIPSIZE_END);
gtk_label_set_max_width_chars(GTK_LABEL(bar->name_label), 50);
gtk_button_set_relief(GTK_BUTTON(bar->status), GTK_RELIEF_NONE);
gtk_button_set_relief(GTK_BUTTON(bar->mood), GTK_RELIEF_NONE);
gtk_widget_set_can_focus(bar->name_eventbox, FALSE);
gtk_widget_set_can_focus(bar->pm_eventbox, FALSE);
gtk_widget_set_can_focus(bar->status, FALSE);
gtk_widget_set_can_focus(bar->mood, FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->icon_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->name_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->pm_eventbox), FALSE);
/* pack widgets */
gtk_container_add(GTK_CONTAINER(bar->name_eventbox), bar->name_label);
gtk_container_add(GTK_CONTAINER(bar->pm_eventbox), bar->pm_label);
gtk_container_add(GTK_CONTAINER(bar->icon_eventbox), bar->icon);
if(purple_prefs_get_bool(PREF "/compact")) {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
}
else {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0);
}
gtk_box_pack_start(GTK_BOX(bar->hbox), bar->icon_eventbox, FALSE, FALSE, 5);
gtk_box_pack_start(GTK_BOX(bar->hbox), vbox, TRUE, TRUE, 0);
/* pack at top of the buddy list and fallback to top
if the position option is unknown */
void (*gtk_box_pack)(GtkBox *, GtkWidget *, gboolean, gboolean, guint) = gtk_box_pack_start;
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
switch(purple_prefs_get_int(PREF "/widget-position")) {
case(POSITION_TOP):
gtk_box_pack = gtk_box_pack_start;
break;
case(POSITION_BOTTOM):
gtk_box_pack = gtk_box_pack_end;
break;
};
gtk_box_pack(GTK_BOX(blist->vbox), bar->hbox, FALSE, TRUE, 2);
gtk_box_reorder_child(GTK_BOX(blist->vbox), bar->hbox, 0);
/* setup initial states */
bar->gtk_hnd = NULL;
bar->gtk_inst = NULL;
bar->hover_name = FALSE;
bar->hover_pm = FALSE;
bar->name_entry_activated = FALSE;
bar->pm_entry_activated = FALSE;
bar->name_dialog = FALSE;
bar->pm_dialog = FALSE;
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ bar->icon_eventbox, "button-press-event", cb_buddy_icon },
{ bar->icon_eventbox, "enter-notify-event", cb_buddy_icon_enter },
{ bar->icon_eventbox, "leave-notify-event", cb_buddy_icon_leave },
{ bar->name_eventbox, "button-press-event", cb_name },
{ bar->name_eventbox, "enter-notify-event", cb_name_enter },
{ bar->name_eventbox, "leave-notify-event", cb_name_leave },
{ bar->name_entry, "activate", cb_name_entry },
{ bar->name_entry, "focus-out-event", cb_name_entry_focus_out },
{ bar->pm_eventbox, "button-press-event", cb_pm },
{ bar->pm_eventbox, "enter-notify-event", cb_pm_enter },
{ bar->pm_eventbox, "leave-notify-event", cb_pm_leave },
{ bar->pm_entry, "activate", cb_pm_entry },
{ bar->pm_entry, "focus-out-event", cb_pm_entry_focus_out },
{ bar->status, "clicked", cb_status_button },
{ bar->mood, "clicked", cb_mood_button },
{ NULL, NULL, NULL }
};
/* purple signals and callback */
const struct pbar_prpl_signal p_signal_connections[] = {
{ purple_accounts_get_handle(), "account-status-changed", cb_status },
{ purple_connections_get_handle(), "signed-on", cb_signed_on },
{ purple_connections_get_handle(), "signed-off", cb_signed_off },
{ NULL, NULL, NULL }
};
/* purple preferences signals and callback */
const struct pbar_prpl_signal pp_signal_connections[] = {
{ bar, PIDGIN_PREFS_ROOT "/accounts/buddyicon", cb_buddy_icon_update },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(bar), g_signal_connections, NULL);
prpl_connect_signals(PBAR_WIDGET(bar), p_signal_connections, NULL);
prpl_prefs_connect_signals(PBAR_WIDGET(bar), pp_signal_connections, NULL);
/* show everything */
gtk_widget_show_all(bar->hbox);
gtk_widget_hide(bar->name_entry);
gtk_widget_hide(bar->pm_entry);
/* inform that the bar is installed */
widget_set_all_sensitive(FALSE);
- check_available_features();
update_available_widgets();
bar->installed = TRUE;
}
static void free_inner_widget()
{
g_return_if_fail(bar->installed);
bar->installed = FALSE;
/* disconnect purple and prefs signals */
prpl_disconnect_signals(PBAR_WIDGET(bar));
prpl_prefs_disconnect_signals(PBAR_WIDGET(bar));
gtk_destroy(PBAR_WIDGET(bar)); /* destroy widgets */
}
void reset_widget()
{
free_inner_widget();
/* create widget but do not free the structure itself
to save references for available features */
create_widget();
}
void destroy_widget()
{
free_inner_widget();
g_free(bar); /* free widget */
bar = NULL;
}
/* load preferences into our widget */
void init_widget()
{
g_return_if_fail(bar->installed);
/* entry frame */
gboolean state = purple_prefs_get_bool(PREF "/frame-entry");
set_widget_entry_frame(state);
/* nickname */
const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup");
const gchar *value = purple_prefs_get_string(PREF "/nickname");
int jtype = purple_prefs_get_int(PREF "/nickname-justify");
set_widget_name(markup, value);
set_widget_name_justify(jtype);
/* personal message */
markup = purple_prefs_get_string(PREF "/personal-message-markup");
value = purple_prefs_get_string(PREF "/personal-message");
jtype = purple_prefs_get_int(PREF "/personal-message-justify");
set_widget_pm(markup, value);
set_widget_pm_justify(jtype);
/* buddy icon */
GdkPixbuf *icon = get_buddy_icon();
set_widget_icon(icon);
/* mood image */
const gchar *current_mood = purple_prefs_get_string(PREF "/mood");
gchar *path = get_mood_icon_path(current_mood);
set_widget_mood(path);
g_free(path);
/* status image */
const gchar *stock = get_status_stock_id();
set_widget_status(stock);
/* fill status menu */
GList *accts = purple_accounts_get_all_active();
GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = (PurpleAccount *)accts->data;
GList *types = purple_account_get_status_types(account);
for(; types ; types = types->next) {
PurpleStatusType *type = (PurpleStatusType *)types->data;
PurpleStatusPrimitive prim;
const gchar *stock, *status_name;
GtkWidget *menu_item, *icon;
if(!purple_status_type_is_user_settable(type) ||
purple_status_type_is_independent(type))
continue;
prim = purple_status_type_get_primitive(type);
stock = pidgin_stock_id_from_status_primitive(prim);
if(g_hash_table_lookup(global_status, stock))
continue;
else
g_hash_table_insert(global_status, (gpointer)stock,
GINT_TO_POINTER(TRUE));
status_name = purple_status_type_get_name(type);
menu_item = gtk_image_menu_item_new_with_label(status_name);
icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), icon);
gtk_menu_shell_append(GTK_MENU_SHELL(bar->status_menu), menu_item);
g_signal_connect_swapped(menu_item, "activate",
G_CALLBACK(cb_status_menu),
(gpointer)type);
gtk_widget_show(menu_item);
}
}
g_hash_table_destroy(global_status);
/* statusbox hiding */
state = purple_prefs_get_bool(PREF "/hide-statusbox");
set_statusbox_visible(!state);
}
/* create a change name dialog */
void create_name_dialog()
{
const gchar *name = purple_prefs_get_string(PREF "/nickname");
if(!name || !strcmp(name, EMPTY_NAME))
name = "";
purple_request_input(thisplugin,
_("Change nickname"),
_("Enter your nickname here..."),
_("This will change your nickname "
"for every account which supports it."),
name,
FALSE,
FALSE,
NULL,
_("OK"),
G_CALLBACK(cb_name_apply),
_("Cancel"),
G_CALLBACK(cb_name_cancel),
NULL,
NULL,
NULL,
NULL);
bar->name_dialog = TRUE;
}
/* disable every features of the widget */
void widget_set_all_sensitive(gboolean sensitive)
{
GtkWidget *widgets[] = {
bar->icon,
bar->icon_eventbox,
bar->status,
bar->status_menu,
bar->mood,
bar->mood_menu,
bar->name_label,
bar->name_eventbox,
bar->name_entry,
bar->pm_label,
bar->pm_eventbox,
bar->pm_entry,
NULL
}; GtkWidget **w = widgets;
gboolean *attrs[] = {
&bar->mood_message,
&bar->current_song,
&bar->song_title,
&bar->song_album,
&bar->game_name,
&bar->office_app,
NULL
}; gboolean **a = attrs;
for(; *w ; w++)
gtk_widget_set_sensitive(*w, sensitive);
for(; *a ; a++)
**a = sensitive;
}
#define assert_ref(count, inc) (bar->count > 0 || inc > 0)
void check_available_features()
{
GList *a = purple_accounts_get_all_active();
for(; a ; a = a->next) {
PurpleAccount *acct = (PurpleAccount *)a->data;
if(purple_account_is_connected(acct))
update_available_features(acct, TRUE);
}
}
/* enable/disable features when an account changes */
void update_available_features(PurpleAccount *acct, gboolean enable)
{
int inc = 1;
PurplePlugin *plugin = purple_find_prpl(acct->protocol_id);
PurplePluginProtocolInfo *protocol = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
PurpleMood *mood = get_global_moods();
GHashTable *attrs = get_account_attrs(acct);
if(!enable)
inc = -1;
/* update references */
if(g_hash_table_lookup(attrs, "mood") && mood->mood &&
assert_ref(mood_ref, inc))
bar->mood_ref += inc;
if(g_hash_table_lookup(attrs, "moodtext") && mood->mood &&
assert_ref(mood_message_ref, inc))
bar->mood_message_ref += inc;
if(g_hash_table_lookup(attrs, "game") && assert_ref(game_name_ref, inc))
bar->game_name_ref += inc;
if(g_hash_table_lookup(attrs, "office") && assert_ref(office_app_ref, inc))
bar->office_app_ref += inc;
if(g_hash_table_lookup(attrs, "tune_title") &&
g_hash_table_lookup(attrs, "tune_artist") &&
g_hash_table_lookup(attrs, "tune_album") &&
assert_ref(current_song_ref, inc))
bar->current_song_ref += inc;
if(protocol->set_status && assert_ref(pm_ref, inc))
bar->pm_ref += inc;
if(protocol->set_buddy_icon && assert_ref(icon_ref, inc))
bar->icon_ref += inc;
if((!strcmp(acct->protocol_id, "prpl-jabber") || protocol->set_public_alias)&&
assert_ref(name_ref, inc))
bar->name_ref += inc;
if(assert_ref(status_ref, inc))
bar->status_ref += inc;
printf("account ref : %d %d %d %d %d %d %d %d %d %d\n",
bar->icon_ref,
bar->status_ref,
bar->mood_ref,
bar->name_ref,
bar->pm_ref,
bar->mood_message_ref,
bar->current_song_ref,
bar->song_title_ref,
bar->game_name_ref,
bar->office_app_ref);
}
void update_available_widgets()
{
gtk_widget_set_sensitive(bar->icon, bar->icon_ref);
gtk_widget_set_sensitive(bar->icon_eventbox, bar->icon_ref);
gtk_widget_set_sensitive(bar->status, bar->status_ref);
gtk_widget_set_sensitive(bar->status_menu, bar->status_ref);
gtk_widget_set_sensitive(bar->mood, bar->mood_ref);
gtk_widget_set_sensitive(bar->mood_menu, bar->mood_ref);
gtk_widget_set_sensitive(bar->name_label, bar->name_ref);
gtk_widget_set_sensitive(bar->name_eventbox, bar->name_ref);
gtk_widget_set_sensitive(bar->name_entry, bar->name_ref);
gtk_widget_set_sensitive(bar->pm_label, bar->pm_ref + bar->mood_message_ref +\
bar->game_name_ref + bar->office_app_ref +\
bar->current_song_ref);
gtk_widget_set_sensitive(bar->pm_eventbox, bar->pm_ref +
bar->mood_message_ref + bar->game_name_ref +
bar->office_app_ref + bar->current_song_ref);
gtk_widget_set_sensitive(bar->pm_entry, bar->pm_ref +
bar->mood_message_ref + bar->game_name_ref +
bar->office_app_ref + bar->current_song_ref);
bar->pm_message = bar->pm_ref;
bar->mood_message = bar->mood_message_ref;
bar->current_song = bar->current_song_ref;
bar->song_title = bar->current_song_ref;
bar->song_album = bar->current_song_ref;
bar->game_name = bar->game_name;
bar->office_app = bar->office_app;
}
/* create a personal message dialog */
void create_pm_dialog()
{
PurpleRequestFields *fields;
PurpleRequestFieldGroup *group;
PurpleRequestField *field;
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
if(!pm || !strcmp(pm, EMPTY_PM))
pm = "";
const struct s_field {
const gchar *text;
const gchar *pref;
gboolean enable;
} groups[] = {
{ N_("_Mood message"), PREF "/mood-message", bar->mood_message },
{ N_("Current song"), NULL, bar->current_song },
{ N_("Song _title"), PREF "/tune-title", bar->current_song },
{ N_("Song _artist"), PREF "/tune-artist", bar->song_title },
{ N_("Song al_bum"), PREF "/tune-album", bar->song_album },
{ N_("MSN pecan extra attributes"), NULL, bar->game_name && bar->office_app },
{ N_("_Game name"), PREF "/game-message", bar->game_name },
{ N_("_Office app name"), PREF "/office-message", bar->office_app },
{ NULL, NULL },
{ NULL, NULL }
}; const struct s_field *g = groups;
fields = purple_request_fields_new();
group = purple_request_field_group_new(_("Status and mood message"));
purple_request_fields_add_group(fields, group);
if(bar->pm_message) {
field = purple_request_field_string_new(PREF "/personal-message",
_("_Personal message"),
pm,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
for(; g->pref ; g++) {
for(; g->pref ; g++) {
const gchar *message;
if(!g->enable)
continue;
else if(purple_prefs_get_bool(PREF "/reset-attrs"))
message = "";
else
message = purple_prefs_get_string(g->pref);
field = purple_request_field_string_new(g->pref,
_(g->text),
message,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
if(g->enable) {
group = purple_request_field_group_new(_(g->text));
purple_request_fields_add_group(fields, group);
}
}
purple_request_fields(thisplugin,
_("Change status messages"),
_("Enter status message..."),
_("This will change some status messages for every "
"account which supports it, please be advised "
"that some are inconsistent between each other."),
fields,
_("OK"),
G_CALLBACK(cb_pm_apply),
_("Cancel"),
G_CALLBACK(cb_pm_cancel),
NULL, NULL, NULL, NULL);
bar->pm_dialog = TRUE;
}
/* replace format character <c><r> with <n> string and escape with <c><c> */
static gchar * g_strreplacefmt(const gchar *s, gchar c, gchar r, const gchar *n)
{
int sn = strlen(n);
int sr = strlen(s);
int index = 0;
gchar *ret = g_malloc(sr);
for(; *s != '\0' ; s++) {
if(*s == c) {
s++;
if(*s == r) {
const gchar *i = n;
sr += sn;
ret = g_realloc(ret, sr);
for(; *i != '\0' ; i++, index++)
ret[index] = *i;
continue;
}
else if(*s != c || *s == '\0')
s--;
}
ret[index] = *s;
index++;
}
ret[index] = '\0';
return ret;
}
void set_widget_name(const gchar *markup, const gchar *name)
{
g_return_if_fail(markup && name && bar->installed);
gchar *escaped_name, *new;
/* translate name if needed */
if(!strcmp(name, EMPTY_NAME))
name = _(EMPTY_NAME);
escaped_name = g_markup_printf_escaped("%s", name);
new = g_strreplacefmt(markup, '%', 'n', escaped_name);
g_free(escaped_name);
gtk_label_set_markup(GTK_LABEL(bar->name_label), new);
g_free(new);
}
void set_widget_pm(const gchar *markup, const gchar *pm)
{
g_return_if_fail(markup && pm && bar->installed);
gchar *escaped_pm, *new;
/* translate pm if needed */
if(!strcmp(pm, EMPTY_PM))
pm = _(EMPTY_PM);
escaped_pm = g_markup_printf_escaped("%s", pm);
new = g_strreplacefmt(markup, '%', 'p', escaped_pm);
g_free(escaped_pm);
gtk_label_set_markup(GTK_LABEL(bar->pm_label), new);
g_free(new);
}
void set_widget_status(const gchar *stock)
{
g_return_if_fail(stock && bar->installed);
GtkWidget *icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_button_set_image(GTK_BUTTON(bar->status), icon);
gtk_button_set_label(GTK_BUTTON(bar->status), "");
}
void set_widget_mood(const gchar *path)
{
g_return_if_fail(path && bar->installed);
GtkWidget *mood = gtk_image_new_from_file(path);
gtk_button_set_image(GTK_BUTTON(bar->mood), mood);
gtk_button_set_label(GTK_BUTTON(bar->mood), "");
}
void set_widget_icon(GdkPixbuf *icon)
{
g_return_if_fail(bar->installed);
if(icon)
gtk_image_set_from_pixbuf(GTK_IMAGE(bar->icon), icon);
else
gtk_image_set_from_stock(GTK_IMAGE(bar->icon), GTK_STOCK_MISSING_IMAGE, 48);
}
/* convertion of int justification
to float justification for
gtk_misc_set_alignment */
static float int_jtype_to_float_jtype(int justify)
{
float ret = 0.; /* default to left */
switch(justify) {
case(JUSTIFY_LEFT):
ret = 0.;
break;
case(JUSTIFY_CENTER):
ret = .5;
break;
case(JUSTIFY_RIGHT):
ret = 1.;
break;
}
return ret;
}
void set_widget_name_justify(int justify)
{
g_return_if_fail(bar->installed);
float jtype = int_jtype_to_float_jtype(justify);
gtk_misc_set_alignment(GTK_MISC(bar->name_label), jtype, .5);
}
void set_widget_pm_justify(int justify)
{
g_return_if_fail(bar->installed);
float jtype = int_jtype_to_float_jtype(justify);
gtk_misc_set_alignment(GTK_MISC(bar->pm_label), jtype, .5);
}
void set_widget_entry_frame(gboolean use_frame)
{
g_return_if_fail(bar->installed);
gtk_entry_set_has_frame(GTK_ENTRY(bar->name_entry), use_frame);
gtk_entry_set_has_frame(GTK_ENTRY(bar->pm_entry), use_frame);
}
void set_statusbox_visible(gboolean visible)
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
GtkWidget *statusbox = blist->statusbox;
if(statusbox)
gtk_widget_set_visible(statusbox, visible);
}
gboolean get_widget_name_hover_state() { return bar->hover_name; }
gboolean get_widget_pm_hover_state() { return bar->hover_pm; }
|
gawen947/pidgin-pbar
|
bda363d31c22a91c2b0c2e5ecc1b922d11a33026
|
Fix features not updated when bar is reset from the preferences dialog Fix features not updated when plugin start is delayed
|
diff --git a/preferences.c b/preferences.c
index 7840e61..968ca41 100644
--- a/preferences.c
+++ b/preferences.c
@@ -1,427 +1,425 @@
/* File: prefs.c
Time-stamp: <2011-06-17 05:03:03 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "preferences.h"
#include "widget.h"
/* callback for preferences setting which set preferences and
update interface when needed */
static void cb_nickname_markup(GtkWidget *widget, gpointer data);
static void cb_nickname_markup_hover(GtkWidget *widget, gpointer data);
static void cb_personal_message_markup(GtkWidget *widget, gpointer data);
static void cb_personal_message_markup_hover(GtkWidget *widget, gpointer data);
static void cb_hide_statusbox(GtkWidget *widget, gpointer data);
static void cb_override_status(GtkWidget *widget, gpointer data);
static void cb_nickname_justify(GtkWidget *widget, gpointer data);
static void cb_personal_message_justify(GtkWidget *widget, gpointer data);
static void cb_compact(GtkWidget *widget, gpointer data);
static void cb_frame_entry(GtkWidget *widget, gpointer data);
static void cb_swap_click(GtkWidget *widget, gpointer data);
static void cb_reset_attrs(GtkWidget *widget, gpointer data);
static void cb_widget_position(GtkWidget *widget, gpointer data);
/* the following structures are defined here as global
since they are needed in combobox callback */
/* alias we will use for combobox */
static const struct i_alias {
const char *alias;
int value;
} alias_justify[] = {
{ N_("Left"), JUSTIFY_LEFT },
{ N_("Center"), JUSTIFY_CENTER },
{ N_("Right"), JUSTIFY_RIGHT },
{ NULL, 0 }
};
/* widget position in the buddy list */
static const struct i_alias alias_position[] = {
{ N_("Top"), POSITION_TOP },
{ N_("Bottom"), POSITION_BOTTOM },
{ NULL, 0 }
};
/* init preferences and set default values */
void init_prefs()
{
/* string preferences and default value */
const struct prefs_string {
const char *name;
const char *value;
} prefs_add_string[] = {
{ PREF "/personal-message-markup-hover", "<span color=\"DarkOliveGreen4\"><small><i>%p</i></small></span>" },
{ PREF "/personal-message-markup", "<small>%p</small>" },
{ PREF "/nickname-markup-hover", "<span color=\"DarkOliveGreen4\"><b>%n</b></span>" },
{ PREF "/nickname-markup", "<b>%n</b>" },
{ PREF "/personal-message", EMPTY_PM },
{ PREF "/tune-title", "" },
{ PREF "/tune-artist", "" },
{ PREF "/tune-album", "" },
{ PREF "/game-message", "" },
{ PREF "/office-message", "" },
{ PREF "/nickname", EMPTY_NAME },
{ PREF "/mood-message", "" },
{ PREF "/mood", "" },
{ NULL, NULL }
}; const struct prefs_string *s = prefs_add_string;
/* boolean preferences and default value */
const struct prefs_bool {
const char *name;
gboolean value;
} prefs_add_bool[] = {
{ PREF "/hide-statusbox", TRUE },
{ PREF "/override-status", FALSE },
{ PREF "/frame-entry", TRUE },
{ PREF "/swap-click", FALSE },
{ PREF "/reset-attrs", FALSE },
{ PREF "/compact", FALSE },
{ NULL, FALSE }
}; const struct prefs_bool *b = prefs_add_bool;
/* integer preferences and default value */
const struct prefs_int {
const char *name;
int value;
} prefs_add_int[] = {
{ PREF "/nickname-justify", JUSTIFY_LEFT },
{ PREF "/personal-message-justify", JUSTIFY_LEFT },
{ PREF "/widget-position", POSITION_TOP },
{ NULL, 0 }
}; const struct prefs_int *i = prefs_add_int;
/* add preferences */
purple_prefs_add_none(PREF);
for(; s->name ; s++)
purple_prefs_add_string(s->name, s->value);
for(; b->name ; b++)
purple_prefs_add_bool(b->name, b->value);
for(; i->name ; i++)
purple_prefs_add_int(i->name, i->value);
}
GtkWidget * get_config_frame(PurplePlugin *plugin)
{
/* entry widgets label, associated preference and callback */
const struct widget {
const char *name;
const char *prefs;
void (*callback)(GtkWidget *, gpointer);
const char *tooltip;
} entry[] = {
{ N_("_Nickname markup"), PREF "/nickname-markup", cb_nickname_markup,
N_("Change the markup used to display the nickname using the "
"Pango Markup Language where %n is replaced with your nickname.") },
{ N_("Nickname markup _hovered"), PREF "/nickname-markup-hover",
cb_nickname_markup_hover,
N_("Change the markup used to display the nickname when hovered "
"by the mouse using the Pango Text Attribute Markup Language "
"where %n is replaced with your nickname") },
{ N_("Personal _message markup"), PREF "/personal-message-markup",
cb_personal_message_markup,
N_("Change the markup used to display the personal message using the "
"Pango Markup Language where %m is replaced with your personal "
"message.") },
{ N_("Personal message markup _hovered"), PREF "/personal-message-markup-hover",
cb_personal_message_markup_hover,
N_("Change the markup used to display the personal message when hovered "
"by the mouse using the Pango Markup Language where %m is replaced "
"with your personal message.") },
{ NULL, NULL, NULL }
}; const struct widget *e = entry;
/* combobox widgets label, associated preference, alias and callback */
const struct i_widget {
const char *name;
const char *prefs;
const struct i_alias *alias;
void (*callback)(GtkWidget *, gpointer);
const char *tooltip;
} combobox[] = {
{ N_("Align _nickname"), PREF "/nickname-justify", alias_justify,
cb_nickname_justify,
N_("Alignment of the nickname into the bar.") },
{ N_("Align personal _message"), PREF "/personal-message-justify",
alias_justify, cb_personal_message_justify,
N_("Alignment of the personal message into the bar.") },
{ N_("Widget _position in the buddy list"), PREF "/widget-position",
alias_position, cb_widget_position,
N_("Position of the widget into pidgin's buddy list.") },
{ NULL, NULL, NULL, NULL }
}; const struct i_widget *cbx = combobox;
/* check button widgets label, associated preference and callback */
const struct widget check_button[] = {
{ N_("Hide _statusbox"), PREF "/hide-statusbox", cb_hide_statusbox,
N_("Show or hide the Pidgin's default statusbox.") },
{ N_("_Ignore status changes"), PREF "/override-status", cb_override_status,
N_("Ignore changes made to status from outside the widget. "
"This include changes made in Pidgin's default statusbox "
"and other plugins.") },
{ N_("Use a frame for _entry"), PREF "/frame-entry", cb_frame_entry,
N_("Enable or disable the use of a frame around the entries when "
"editing the nickname or personal message from the bar.") },
{ N_("_Swap left and right click"), PREF "/swap-click", cb_swap_click,
N_("Swap the role of left and right click to edit the nickname or "
"personal message in the bar.") },
{ N_("Use a _compact bar"), PREF "/compact", cb_compact,
N_("Reduce the size of the widget putting the nickname and personal "
"message on one line.") },
{ N_("_Reset status messages"), PREF "/reset-attrs", cb_reset_attrs,
N_("Clear the status messages when Pidgin restart (except for personal "
"message). By default these messages are saved in the preferences and "
"reactivated when pidgin restart.") },
{ NULL, NULL, NULL }
}; const struct widget *cb = check_button;
/* create table */
GtkWidget *table = gtk_table_new(((sizeof(entry) - 2) +
sizeof(check_button) / 2 - 1) /
sizeof(struct widget),
2, FALSE);
/* load table and connect signals */
int x = 0, y = 0;
for(; e->name ; e++, y++) {
/* entry widgets */
GtkWidget *widget_label = gtk_label_new_with_mnemonic(_(e->name));
GtkWidget *widget_entry = gtk_entry_new();
const gchar *prefs_value = purple_prefs_get_string(e->prefs);
gtk_label_set_mnemonic_widget(GTK_LABEL(widget_label), widget_entry);
gtk_entry_set_text(GTK_ENTRY(widget_entry), prefs_value);
gtk_widget_set_tooltip_text(widget_entry, e->tooltip);
gtk_misc_set_alignment(GTK_MISC(widget_label), 0., .5);
gtk_table_attach(GTK_TABLE(table), widget_label, 0, 1, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
gtk_table_attach(GTK_TABLE(table), widget_entry, 1, 2, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
g_signal_connect(G_OBJECT(widget_entry), "activate", G_CALLBACK(e->callback),NULL);
g_signal_connect(G_OBJECT(widget_entry), "focus-out-event", G_CALLBACK(e->callback),NULL);
}
for(; cbx->name ; cbx++, y++) {
/* combobox widgets */
const struct i_alias *j;
GtkWidget *widget_label = gtk_label_new_with_mnemonic(_(cbx->name));
GtkWidget *widget_combo = gtk_combo_box_new_text();
int prefs_value = purple_prefs_get_int(cbx->prefs);
int i;
gtk_label_set_mnemonic_widget(GTK_LABEL(widget_label), widget_combo);
gtk_misc_set_alignment(GTK_MISC(widget_label), 0., .5);
gtk_widget_set_tooltip_text(widget_label, cbx->tooltip);
gtk_table_attach(GTK_TABLE(table), widget_label, 0, 1, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
gtk_table_attach(GTK_TABLE(table), widget_combo, 1, 2, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
for(i = 0, j = cbx->alias ; j->alias ; j++, i++) {
gtk_combo_box_append_text(GTK_COMBO_BOX(widget_combo), _(j->alias));
if(j->value == prefs_value)
gtk_combo_box_set_active(GTK_COMBO_BOX(widget_combo), i);
}
g_signal_connect(G_OBJECT(widget_combo), "changed", G_CALLBACK(cbx->callback), (gpointer)cbx->alias);
}
for(; cb->name ; cb++, x = (x + 1) % 2) {
/* check button widgets */
GtkWidget *widget_cb = gtk_check_button_new_with_mnemonic(_(cb->name));
gboolean prefs_value = purple_prefs_get_bool(cb->prefs);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget_cb), prefs_value);
gtk_widget_set_tooltip_text(widget_cb, cb->tooltip);
gtk_table_attach(GTK_TABLE(table), widget_cb, x, x+1, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
g_signal_connect(G_OBJECT(widget_cb), "toggled", G_CALLBACK(cb->callback),NULL);
if(x % 2)
y++;
}
return table; /* pidgin destroy this when closed */
}
static void cb_nickname_markup(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget));
purple_prefs_set_string(PREF "/nickname-markup", value);
if(!get_widget_name_hover_state()) {
const gchar *name = purple_prefs_get_string(PREF "/nickname");
set_widget_name(value, name);
}
purple_debug_info(NAME, "nickname markup changed\n");
}
static void cb_nickname_markup_hover(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget));
purple_prefs_set_string(PREF "/nickname-markup-hover", value);
if(get_widget_name_hover_state()) {
const gchar *name = purple_prefs_get_string(PREF "/nickname");
set_widget_name(value, name);
}
purple_debug_info(NAME, "nickname markup hover changed\n");
}
static void cb_personal_message_markup(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget));
purple_prefs_set_string(PREF "/personal-message-markup", value);
if(!get_widget_pm_hover_state()) {
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
set_widget_pm(value, pm);
}
purple_debug_info(NAME, "personal message markup hover changed\n");
}
static void cb_personal_message_markup_hover(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget));
purple_prefs_set_string(PREF "/personal-message-markup-hover", value);
if(get_widget_pm_hover_state()) {
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
set_widget_pm(value, pm);
}
purple_debug_info(NAME, "personal message markup hover changed\n");
}
static void cb_hide_statusbox(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/hide-statusbox", state);
set_statusbox_visible(!state);
purple_debug_info(NAME, "status box state changed\n");
}
static void cb_override_status(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/override-status", state);
purple_debug_info(NAME, "override status state changed\n");
}
static void cb_nickname_justify(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget));
const struct i_alias *j;
for(j = (struct i_alias *)data ; j->alias ; j++) {
if(!strcmp(value, _(j->alias))) {
purple_prefs_set_int(PREF "/nickname-justify", j->value);
set_widget_name_justify(j->value);
break;
}
}
purple_debug_info(NAME, "nickname justification changed\n");
}
static void cb_personal_message_justify(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget));
const struct i_alias *j;
for(j = (struct i_alias *)data ; j->alias ; j++) {
if(!strcmp(value, _(j->alias))) {
purple_prefs_set_int(PREF "/personal-message-justify", j->value);
set_widget_pm_justify(j->value);
break;
}
}
purple_debug_info(NAME, "personal message justification changed\n");
}
static void cb_compact(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/compact", state);
/* recreate bar since we need to repack everything */
- destroy_widget();
- create_widget();
+ reset_widget();
init_widget();
purple_debug_info(NAME, "compact state changed\n");
}
static void cb_frame_entry(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/frame-entry", state);
set_widget_entry_frame(state);
purple_debug_info(NAME, "frame entry state changed\n");
}
static void cb_swap_click(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/swap-click", state);
purple_debug_info(NAME, "swap click state changed\n");
}
static void cb_reset_attrs(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/reset-attrs", state);
set_widget_entry_frame(state);
purple_debug_info(NAME, "reset attributes state changed\n");
}
static void cb_widget_position(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget));
const struct i_alias *j;
for(j = (struct i_alias *)data ; j->alias ; j++) {
if(!strcmp(value, _(j->alias))) {
purple_prefs_set_int(PREF "/widget-position", j->value);
/* recreate bar since we need to repack everything */
- destroy_widget();
- create_widget();
+ reset_widget();
init_widget();
break;
}
}
purple_debug_info(NAME, "personal message justification changed\n");
}
diff --git a/widget.c b/widget.c
index 80d42de..9ce5ae7 100644
--- a/widget.c
+++ b/widget.c
@@ -1,657 +1,688 @@
/* File: widget.c
- Time-stamp: <2011-06-17 16:39:05 gawen>
+ Time-stamp: <2011-06-17 17:15:13 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "pbar.h"
#include "widget.h"
#include "widget_gtk.h"
#include "widget_prpl.h"
#include "preferences.h"
#include "purple.h"
#include "gtk.h"
/* we only have one widget per plugin
but this might change in the future */
struct widget *bar;
void create_widget()
{
- /* this should occurs only once but
- this way we avoid memory leaks */
- if(!bar)
+ /* we need this when the bar is reset for example
+ using the preferences dialog */
+ if(!bar) {
bar = g_malloc(sizeof(struct widget));
- memset(bar, 0, sizeof(struct widget));
+ memset(bar, 0, sizeof(struct widget));
+ }
/* widgets that can possibly be modified along plugin's execution */
bar->icon = gtk_image_new();
bar->status = gtk_button_new_from_stock(NULL);
bar->mood = gtk_button_new_from_stock(NULL);
bar->name_label = gtk_label_new(NULL);
bar->name_eventbox = gtk_event_box_new();
bar->name_entry = gtk_entry_new();
bar->pm_label = gtk_label_new(NULL);
bar->pm_eventbox = gtk_event_box_new();
bar->pm_entry = gtk_entry_new();
bar->hbox = gtk_hbox_new(FALSE, 2);
bar->icon_eventbox = gtk_event_box_new();
bar->status_menu = gtk_menu_new();
bar->mood_menu = gtk_menu_new();
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(bar), bar->hbox);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->status_menu);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->mood_menu);
/* widgets that are not modified */
GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
GtkWidget *hbox1 = gtk_hbox_new(FALSE, 2);
GtkWidget *hbox2 = gtk_hbox_new(FALSE, 2);
/* setup widgets */
gtk_label_set_ellipsize(GTK_LABEL(bar->name_label), PANGO_ELLIPSIZE_END);
gtk_label_set_ellipsize(GTK_LABEL(bar->pm_label), PANGO_ELLIPSIZE_END);
gtk_label_set_max_width_chars(GTK_LABEL(bar->name_label), 50);
gtk_button_set_relief(GTK_BUTTON(bar->status), GTK_RELIEF_NONE);
gtk_button_set_relief(GTK_BUTTON(bar->mood), GTK_RELIEF_NONE);
gtk_widget_set_can_focus(bar->name_eventbox, FALSE);
gtk_widget_set_can_focus(bar->pm_eventbox, FALSE);
gtk_widget_set_can_focus(bar->status, FALSE);
gtk_widget_set_can_focus(bar->mood, FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->icon_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->name_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->pm_eventbox), FALSE);
/* pack widgets */
gtk_container_add(GTK_CONTAINER(bar->name_eventbox), bar->name_label);
gtk_container_add(GTK_CONTAINER(bar->pm_eventbox), bar->pm_label);
gtk_container_add(GTK_CONTAINER(bar->icon_eventbox), bar->icon);
if(purple_prefs_get_bool(PREF "/compact")) {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
}
else {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0);
}
gtk_box_pack_start(GTK_BOX(bar->hbox), bar->icon_eventbox, FALSE, FALSE, 5);
gtk_box_pack_start(GTK_BOX(bar->hbox), vbox, TRUE, TRUE, 0);
/* pack at top of the buddy list and fallback to top
if the position option is unknown */
void (*gtk_box_pack)(GtkBox *, GtkWidget *, gboolean, gboolean, guint) = gtk_box_pack_start;
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
switch(purple_prefs_get_int(PREF "/widget-position")) {
case(POSITION_TOP):
gtk_box_pack = gtk_box_pack_start;
break;
case(POSITION_BOTTOM):
gtk_box_pack = gtk_box_pack_end;
break;
};
gtk_box_pack(GTK_BOX(blist->vbox), bar->hbox, FALSE, TRUE, 2);
gtk_box_reorder_child(GTK_BOX(blist->vbox), bar->hbox, 0);
/* setup initial states */
bar->gtk_hnd = NULL;
bar->gtk_inst = NULL;
bar->hover_name = FALSE;
bar->hover_pm = FALSE;
bar->name_entry_activated = FALSE;
bar->pm_entry_activated = FALSE;
bar->name_dialog = FALSE;
bar->pm_dialog = FALSE;
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ bar->icon_eventbox, "button-press-event", cb_buddy_icon },
{ bar->icon_eventbox, "enter-notify-event", cb_buddy_icon_enter },
{ bar->icon_eventbox, "leave-notify-event", cb_buddy_icon_leave },
{ bar->name_eventbox, "button-press-event", cb_name },
{ bar->name_eventbox, "enter-notify-event", cb_name_enter },
{ bar->name_eventbox, "leave-notify-event", cb_name_leave },
{ bar->name_entry, "activate", cb_name_entry },
{ bar->name_entry, "focus-out-event", cb_name_entry_focus_out },
{ bar->pm_eventbox, "button-press-event", cb_pm },
{ bar->pm_eventbox, "enter-notify-event", cb_pm_enter },
{ bar->pm_eventbox, "leave-notify-event", cb_pm_leave },
{ bar->pm_entry, "activate", cb_pm_entry },
{ bar->pm_entry, "focus-out-event", cb_pm_entry_focus_out },
{ bar->status, "clicked", cb_status_button },
{ bar->mood, "clicked", cb_mood_button },
{ NULL, NULL, NULL }
};
/* purple signals and callback */
const struct pbar_prpl_signal p_signal_connections[] = {
{ purple_accounts_get_handle(), "account-status-changed", cb_status },
{ purple_connections_get_handle(), "signed-on", cb_signed_on },
{ purple_connections_get_handle(), "signed-off", cb_signed_off },
{ NULL, NULL, NULL }
};
/* purple preferences signals and callback */
const struct pbar_prpl_signal pp_signal_connections[] = {
{ bar, PIDGIN_PREFS_ROOT "/accounts/buddyicon", cb_buddy_icon_update },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(bar), g_signal_connections, NULL);
prpl_connect_signals(PBAR_WIDGET(bar), p_signal_connections, NULL);
prpl_prefs_connect_signals(PBAR_WIDGET(bar), pp_signal_connections, NULL);
/* show everything */
gtk_widget_show_all(bar->hbox);
gtk_widget_hide(bar->name_entry);
gtk_widget_hide(bar->pm_entry);
/* inform that the bar is installed */
widget_set_all_sensitive(FALSE);
+ check_available_features();
+ update_available_widgets();
bar->installed = TRUE;
}
-void destroy_widget()
+static void free_inner_widget()
{
g_return_if_fail(bar->installed);
bar->installed = FALSE;
/* disconnect purple and prefs signals */
prpl_disconnect_signals(PBAR_WIDGET(bar));
prpl_prefs_disconnect_signals(PBAR_WIDGET(bar));
gtk_destroy(PBAR_WIDGET(bar)); /* destroy widgets */
+}
+
+void reset_widget()
+{
+ free_inner_widget();
+
+ /* create widget but do not free the structure itself
+ to save references for available features */
+ create_widget();
+}
+
+void destroy_widget()
+{
+ free_inner_widget();
+
g_free(bar); /* free widget */
bar = NULL;
}
/* load preferences into our widget */
void init_widget()
{
g_return_if_fail(bar->installed);
/* entry frame */
gboolean state = purple_prefs_get_bool(PREF "/frame-entry");
set_widget_entry_frame(state);
/* nickname */
const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup");
const gchar *value = purple_prefs_get_string(PREF "/nickname");
int jtype = purple_prefs_get_int(PREF "/nickname-justify");
set_widget_name(markup, value);
set_widget_name_justify(jtype);
/* personal message */
markup = purple_prefs_get_string(PREF "/personal-message-markup");
value = purple_prefs_get_string(PREF "/personal-message");
jtype = purple_prefs_get_int(PREF "/personal-message-justify");
set_widget_pm(markup, value);
set_widget_pm_justify(jtype);
/* buddy icon */
GdkPixbuf *icon = get_buddy_icon();
set_widget_icon(icon);
/* mood image */
const gchar *current_mood = purple_prefs_get_string(PREF "/mood");
gchar *path = get_mood_icon_path(current_mood);
set_widget_mood(path);
g_free(path);
/* status image */
const gchar *stock = get_status_stock_id();
set_widget_status(stock);
/* fill status menu */
GList *accts = purple_accounts_get_all_active();
GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = (PurpleAccount *)accts->data;
GList *types = purple_account_get_status_types(account);
for(; types ; types = types->next) {
PurpleStatusType *type = (PurpleStatusType *)types->data;
PurpleStatusPrimitive prim;
const gchar *stock, *status_name;
GtkWidget *menu_item, *icon;
if(!purple_status_type_is_user_settable(type) ||
purple_status_type_is_independent(type))
continue;
prim = purple_status_type_get_primitive(type);
stock = pidgin_stock_id_from_status_primitive(prim);
if(g_hash_table_lookup(global_status, stock))
continue;
else
g_hash_table_insert(global_status, (gpointer)stock,
GINT_TO_POINTER(TRUE));
status_name = purple_status_type_get_name(type);
menu_item = gtk_image_menu_item_new_with_label(status_name);
icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), icon);
gtk_menu_shell_append(GTK_MENU_SHELL(bar->status_menu), menu_item);
g_signal_connect_swapped(menu_item, "activate",
G_CALLBACK(cb_status_menu),
(gpointer)type);
gtk_widget_show(menu_item);
}
}
g_hash_table_destroy(global_status);
/* statusbox hiding */
state = purple_prefs_get_bool(PREF "/hide-statusbox");
set_statusbox_visible(!state);
}
/* create a change name dialog */
void create_name_dialog()
{
const gchar *name = purple_prefs_get_string(PREF "/nickname");
if(!name || !strcmp(name, EMPTY_NAME))
name = "";
purple_request_input(thisplugin,
_("Change nickname"),
_("Enter your nickname here..."),
_("This will change your nickname "
"for every account which supports it."),
name,
FALSE,
FALSE,
NULL,
_("OK"),
G_CALLBACK(cb_name_apply),
_("Cancel"),
G_CALLBACK(cb_name_cancel),
NULL,
NULL,
NULL,
NULL);
bar->name_dialog = TRUE;
}
/* disable every features of the widget */
void widget_set_all_sensitive(gboolean sensitive)
{
GtkWidget *widgets[] = {
bar->icon,
bar->icon_eventbox,
bar->status,
bar->status_menu,
bar->mood,
bar->mood_menu,
bar->name_label,
bar->name_eventbox,
bar->name_entry,
bar->pm_label,
bar->pm_eventbox,
bar->pm_entry,
NULL
}; GtkWidget **w = widgets;
gboolean *attrs[] = {
&bar->mood_message,
&bar->current_song,
&bar->song_title,
&bar->song_album,
&bar->game_name,
&bar->office_app,
NULL
}; gboolean **a = attrs;
for(; *w ; w++)
gtk_widget_set_sensitive(*w, sensitive);
for(; *a ; a++)
**a = sensitive;
}
#define assert_ref(count, inc) (bar->count > 0 || inc > 0)
+void check_available_features()
+{
+ GList *a = purple_accounts_get_all_active();
+
+ for(; a ; a = a->next) {
+ PurpleAccount *acct = (PurpleAccount *)a->data;
+
+ if(purple_account_is_connected(acct))
+ update_available_features(acct, TRUE);
+ }
+}
+
/* enable/disable features when an account changes */
-void account_changes(PurpleConnection *gc, gboolean enable)
+void update_available_features(PurpleAccount *acct, gboolean enable)
{
int inc = 1;
- PurpleAccount *acct = purple_connection_get_account(gc);
PurplePlugin *plugin = purple_find_prpl(acct->protocol_id);
PurplePluginProtocolInfo *protocol = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
PurpleMood *mood = get_global_moods();
GHashTable *attrs = get_account_attrs(acct);
if(!enable)
inc = -1;
/* update references */
if(g_hash_table_lookup(attrs, "mood") && mood->mood &&
assert_ref(mood_ref, inc))
bar->mood_ref += inc;
if(g_hash_table_lookup(attrs, "moodtext") && mood->mood &&
assert_ref(mood_message_ref, inc))
bar->mood_message_ref += inc;
if(g_hash_table_lookup(attrs, "game") && assert_ref(game_name_ref, inc))
bar->game_name_ref += inc;
if(g_hash_table_lookup(attrs, "office") && assert_ref(office_app_ref, inc))
bar->office_app_ref += inc;
if(g_hash_table_lookup(attrs, "tune_title") &&
g_hash_table_lookup(attrs, "tune_artist") &&
g_hash_table_lookup(attrs, "tune_album") &&
assert_ref(current_song_ref, inc))
bar->current_song_ref += inc;
if(protocol->set_status && assert_ref(pm_ref, inc))
bar->pm_ref += inc;
if(protocol->set_buddy_icon && assert_ref(icon_ref, inc))
bar->icon_ref += inc;
if((!strcmp(acct->protocol_id, "prpl-jabber") || protocol->set_public_alias)&&
assert_ref(name_ref, inc))
bar->name_ref += inc;
if(assert_ref(status_ref, inc))
bar->status_ref += inc;
printf("account ref : %d %d %d %d %d %d %d %d %d %d\n",
bar->icon_ref,
bar->status_ref,
bar->mood_ref,
bar->name_ref,
bar->pm_ref,
bar->mood_message_ref,
bar->current_song_ref,
bar->song_title_ref,
bar->game_name_ref,
bar->office_app_ref);
+}
- /* update widgets sensitive */
+void update_available_widgets()
+{
gtk_widget_set_sensitive(bar->icon, bar->icon_ref);
gtk_widget_set_sensitive(bar->icon_eventbox, bar->icon_ref);
gtk_widget_set_sensitive(bar->status, bar->status_ref);
gtk_widget_set_sensitive(bar->status_menu, bar->status_ref);
gtk_widget_set_sensitive(bar->mood, bar->mood_ref);
gtk_widget_set_sensitive(bar->mood_menu, bar->mood_ref);
gtk_widget_set_sensitive(bar->name_label, bar->name_ref);
gtk_widget_set_sensitive(bar->name_eventbox, bar->name_ref);
gtk_widget_set_sensitive(bar->name_entry, bar->name_ref);
gtk_widget_set_sensitive(bar->pm_label, bar->pm_ref + bar->mood_message_ref +\
bar->game_name_ref + bar->office_app_ref +\
bar->current_song_ref);
gtk_widget_set_sensitive(bar->pm_eventbox, bar->pm_ref +
bar->mood_message_ref + bar->game_name_ref +
bar->office_app_ref + bar->current_song_ref);
gtk_widget_set_sensitive(bar->pm_entry, bar->pm_ref +
bar->mood_message_ref + bar->game_name_ref +
bar->office_app_ref + bar->current_song_ref);
bar->pm_message = bar->pm_ref;
bar->mood_message = bar->mood_message_ref;
bar->current_song = bar->current_song_ref;
bar->song_title = bar->current_song_ref;
bar->song_album = bar->current_song_ref;
bar->game_name = bar->game_name;
bar->office_app = bar->office_app;
}
/* create a personal message dialog */
void create_pm_dialog()
{
PurpleRequestFields *fields;
PurpleRequestFieldGroup *group;
PurpleRequestField *field;
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
if(!pm || !strcmp(pm, EMPTY_PM))
pm = "";
const struct s_field {
const gchar *text;
const gchar *pref;
gboolean enable;
} groups[] = {
{ N_("_Mood message"), PREF "/mood-message", bar->mood_message },
{ N_("Current song"), NULL, bar->current_song },
{ N_("Song _title"), PREF "/tune-title", bar->current_song },
{ N_("Song _artist"), PREF "/tune-artist", bar->song_title },
{ N_("Song al_bum"), PREF "/tune-album", bar->song_album },
{ N_("MSN pecan extra attributes"), NULL, bar->game_name && bar->office_app },
{ N_("_Game name"), PREF "/game-message", bar->game_name },
{ N_("_Office app name"), PREF "/office-message", bar->office_app },
{ NULL, NULL },
{ NULL, NULL }
}; const struct s_field *g = groups;
fields = purple_request_fields_new();
group = purple_request_field_group_new(_("Status and mood message"));
purple_request_fields_add_group(fields, group);
if(bar->pm_message) {
field = purple_request_field_string_new(PREF "/personal-message",
_("_Personal message"),
pm,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
for(; g->pref ; g++) {
for(; g->pref ; g++) {
const gchar *message;
if(!g->enable)
continue;
else if(purple_prefs_get_bool(PREF "/reset-attrs"))
message = "";
else
message = purple_prefs_get_string(g->pref);
field = purple_request_field_string_new(g->pref,
_(g->text),
message,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
if(g->enable) {
group = purple_request_field_group_new(_(g->text));
purple_request_fields_add_group(fields, group);
}
}
purple_request_fields(thisplugin,
_("Change status messages"),
_("Enter status message..."),
_("This will change some status messages for every "
"account which supports it, please be advised "
"that some are inconsistent between each other."),
fields,
_("OK"),
G_CALLBACK(cb_pm_apply),
_("Cancel"),
G_CALLBACK(cb_pm_cancel),
NULL, NULL, NULL, NULL);
bar->pm_dialog = TRUE;
}
/* replace format character <c><r> with <n> string and escape with <c><c> */
static gchar * g_strreplacefmt(const gchar *s, gchar c, gchar r, const gchar *n)
{
int sn = strlen(n);
int sr = strlen(s);
int index = 0;
gchar *ret = g_malloc(sr);
for(; *s != '\0' ; s++) {
if(*s == c) {
s++;
if(*s == r) {
const gchar *i = n;
sr += sn;
ret = g_realloc(ret, sr);
for(; *i != '\0' ; i++, index++)
ret[index] = *i;
continue;
}
else if(*s != c || *s == '\0')
s--;
}
ret[index] = *s;
index++;
}
ret[index] = '\0';
return ret;
}
void set_widget_name(const gchar *markup, const gchar *name)
{
g_return_if_fail(markup && name && bar->installed);
gchar *escaped_name, *new;
/* translate name if needed */
if(!strcmp(name, EMPTY_NAME))
name = _(EMPTY_NAME);
escaped_name = g_markup_printf_escaped("%s", name);
new = g_strreplacefmt(markup, '%', 'n', escaped_name);
g_free(escaped_name);
gtk_label_set_markup(GTK_LABEL(bar->name_label), new);
g_free(new);
}
void set_widget_pm(const gchar *markup, const gchar *pm)
{
g_return_if_fail(markup && pm && bar->installed);
gchar *escaped_pm, *new;
/* translate pm if needed */
if(!strcmp(pm, EMPTY_PM))
pm = _(EMPTY_PM);
escaped_pm = g_markup_printf_escaped("%s", pm);
new = g_strreplacefmt(markup, '%', 'p', escaped_pm);
g_free(escaped_pm);
gtk_label_set_markup(GTK_LABEL(bar->pm_label), new);
g_free(new);
}
void set_widget_status(const gchar *stock)
{
g_return_if_fail(stock && bar->installed);
GtkWidget *icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_button_set_image(GTK_BUTTON(bar->status), icon);
gtk_button_set_label(GTK_BUTTON(bar->status), "");
}
void set_widget_mood(const gchar *path)
{
g_return_if_fail(path && bar->installed);
GtkWidget *mood = gtk_image_new_from_file(path);
gtk_button_set_image(GTK_BUTTON(bar->mood), mood);
gtk_button_set_label(GTK_BUTTON(bar->mood), "");
}
void set_widget_icon(GdkPixbuf *icon)
{
g_return_if_fail(bar->installed);
if(icon)
gtk_image_set_from_pixbuf(GTK_IMAGE(bar->icon), icon);
else
gtk_image_set_from_stock(GTK_IMAGE(bar->icon), GTK_STOCK_MISSING_IMAGE, 48);
}
/* convertion of int justification
to float justification for
gtk_misc_set_alignment */
static float int_jtype_to_float_jtype(int justify)
{
float ret = 0.; /* default to left */
switch(justify) {
case(JUSTIFY_LEFT):
ret = 0.;
break;
case(JUSTIFY_CENTER):
ret = .5;
break;
case(JUSTIFY_RIGHT):
ret = 1.;
break;
}
return ret;
}
void set_widget_name_justify(int justify)
{
g_return_if_fail(bar->installed);
float jtype = int_jtype_to_float_jtype(justify);
gtk_misc_set_alignment(GTK_MISC(bar->name_label), jtype, .5);
}
void set_widget_pm_justify(int justify)
{
g_return_if_fail(bar->installed);
float jtype = int_jtype_to_float_jtype(justify);
gtk_misc_set_alignment(GTK_MISC(bar->pm_label), jtype, .5);
}
void set_widget_entry_frame(gboolean use_frame)
{
g_return_if_fail(bar->installed);
gtk_entry_set_has_frame(GTK_ENTRY(bar->name_entry), use_frame);
gtk_entry_set_has_frame(GTK_ENTRY(bar->pm_entry), use_frame);
}
void set_statusbox_visible(gboolean visible)
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
GtkWidget *statusbox = blist->statusbox;
if(statusbox)
gtk_widget_set_visible(statusbox, visible);
}
gboolean get_widget_name_hover_state() { return bar->hover_name; }
gboolean get_widget_pm_hover_state() { return bar->hover_pm; }
diff --git a/widget.h b/widget.h
index 1eac766..8eefe13 100644
--- a/widget.h
+++ b/widget.h
@@ -1,110 +1,113 @@
/* File: widget.h
Time-stamp: <2011-06-17 15:32:27 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _WIDGET_H_
#define _WIDGET_H_
#include "common.h"
#include "gtk.h"
struct widget {
BEGIN_PBAR_WIDGET;
/* icon and status */
GtkWidget *icon;
GtkWidget *icon_eventbox;
GtkWidget *status;
GtkWidget *status_menu;
/* mood */
GtkWidget *mood;
GtkWidget *mood_menu;
/* nickname */
GtkWidget *name_label;
GtkWidget *name_eventbox;
GtkWidget *name_entry;
/* personal message */
GtkWidget *pm_label;
GtkWidget *pm_eventbox;
GtkWidget *pm_entry;
GtkWidget *hbox; /* contains the widget */
gboolean installed; /* widget installed or not */
gboolean hover_name; /* name hovered or not */
gboolean hover_pm; /* pm hovered or not */
/* avoid setting status and name twice
with focus-out-event */
gboolean name_entry_activated;
gboolean pm_entry_activated;
/* avoid activating entry with dialog */
gboolean name_dialog;
gboolean pm_dialog;
/* attributes state for
attributes dialogs */
gboolean mood_message;
gboolean current_song;
gboolean song_title;
gboolean song_album;
gboolean game_name;
gboolean office_app;
gboolean pm_message;
/* references */
unsigned int icon_ref;
unsigned int status_ref;
unsigned int mood_ref;
unsigned int name_ref;
unsigned int pm_ref;
unsigned int mood_message_ref;
unsigned int current_song_ref;
unsigned int song_title_ref;
unsigned int game_name_ref;
unsigned int office_app_ref;
};
extern struct widget *bar;
void create_widget();
+void reset_widget();
void destroy_widget();
void init_widget();
void create_name_dialog();
void create_pm_dialog();
-void account_changes(PurpleConnection *gc, gboolean enable);
+void update_available_features(PurpleAccount *acct, gboolean enable);
+void check_available_features();
+void update_available_widgets();
void widget_set_all_sensitive(gboolean sensitive);
void set_widget_name(const gchar *markup, const gchar *name);
void set_widget_pm(const gchar *markup, const gchar *pm);
void set_widget_status(const gchar *stock);
void set_widget_mood(const gchar *path);
void set_widget_icon(GdkPixbuf *icon);
void set_widget_name_justify(int justify);
void set_widget_pm_justify(int justify);
void set_widget_entry_frame(gboolean use_frame);
void set_statusbox_visible(gboolean visible);
gboolean get_widget_name_hover_state();
gboolean get_widget_pm_hover_state();
#endif /* _WIDGET_H_ */
diff --git a/widget_prpl.c b/widget_prpl.c
index 0cf5803..b98fe4d 100644
--- a/widget_prpl.c
+++ b/widget_prpl.c
@@ -1,233 +1,238 @@
/* File: widget_prpl.c
Time-stamp: <2011-06-17 14:42:59 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "preferences.h"
#include "widget.h"
#include "widget_prpl.h"
#include "purple.h"
void cb_status(PurpleAccount *account, PurpleStatus *old, PurpleStatus *new)
{
g_return_if_fail(bar->installed);
PurpleStatusPrimitive prim;
const gchar *stock, *pm;
PurpleSavedStatus *status = purple_savedstatus_get_current();
if(purple_prefs_get_bool(PREF "/override-status")) {
pm = purple_prefs_get_string(PREF "/personal-message");
purple_savedstatus_set_message(status,pm);
purple_savedstatus_activate(status);
}
else {
const gchar *markup;
markup = purple_prefs_get_string(PREF "/personal-message-markup");
pm = purple_savedstatus_get_message(status);
if(!pm)
pm = "";
set_widget_pm(markup, pm);
purple_prefs_set_string(PREF "/personal-message", pm);
}
prim = purple_savedstatus_get_type(status);
stock = pidgin_stock_id_from_status_primitive(prim);
set_widget_status(stock);
}
void cb_signed_off(PurpleConnection *gc)
-{ account_changes(gc, FALSE); }
+{
+ PurpleAccount *acct = purple_connection_get_account(gc);
+ update_available_features(acct, FALSE);
+ update_available_widgets();
+}
void cb_signed_on(PurpleConnection *gc)
{
const gchar *name = purple_prefs_get_string(PREF "/nickname");
PurpleAccount *account = purple_connection_get_account(gc);
set_display_name(account, name);
- account_changes(gc, TRUE);
+ update_available_features(account, TRUE);
+ update_available_widgets();
purple_debug_info(NAME, "nickname changed to \"%s\" by signed-on account\n",
name);
if(gc && gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS) {
const gchar *mood = purple_prefs_get_string(PREF "/mood");
set_status_with_mood(account, mood);
purple_debug_info(NAME, "mood changed to \"%s\" by signed-on account\n",
mood);
}
/* load tune and stuff */
GList *a_tune = NULL;
GList *a_mood = NULL;
const struct attrs {
const gchar *pref;
const gchar *attr;
GList **list;
} attrs[] = {
{ PREF "/mood-message", PURPLE_MOOD_COMMENT, &a_mood },
{ PREF "/tune-title", PURPLE_TUNE_TITLE, &a_tune },
{ PREF "/tune-artist", PURPLE_TUNE_ARTIST, &a_tune },
{ PREF "/tune-album", PURPLE_TUNE_ALBUM, &a_tune },
{ PREF "/game-message", "game", &a_tune },
{ PREF "/office-message", "office", &a_tune },
{ NULL, NULL, NULL }
}; const register struct attrs *a = attrs;
for(; a->pref ; a++) {
const gchar *value;
if(purple_prefs_get_bool(PREF "/reset-attrs"))
value = NULL;
else
value = purple_prefs_get_string(a->pref);
if(value && !strcmp(value, ""))
value = NULL;
else
purple_debug_info(NAME, "%s message changed to \"%s\" by signed-on account\n",
a->attr, value);
*(a->list) = g_list_append(*(a->list), (gpointer)a->attr);
*(a->list) = g_list_append(*(a->list), (gpointer)value);
}
const struct status_list {
const gchar *status_id;
GList *list;
gboolean cont;
} status[] = {
{ "tune", a_tune, TRUE },
{ "mood", a_mood, TRUE },
{ NULL, NULL, FALSE}
}; register const struct status_list *s = status;
for(; s->cont ; s++) {
purple_account_set_status_list(account, s->status_id, TRUE, s->list);
g_list_free(s->list);
}
}
void cb_buddy_icon_update(const char *name, PurplePrefType type,
gconstpointer val, gpointer data)
{
g_return_if_fail(bar->installed);
GdkPixbuf *icon;
icon = get_buddy_icon();
set_widget_icon(icon);
}
void cb_name_apply(PurpleAccount *account, const char *user_info)
{
g_return_if_fail(bar->installed);
const gchar *markup, *name;
name = user_info;
markup = purple_prefs_get_string(PREF "/nickname-markup");
set_widget_name(markup, name);
purple_prefs_set_string(PREF "/nickname", name);
set_display_name_all(name);
bar->name_dialog = FALSE;
purple_debug_info(NAME, "nickname changed to \"%s\" by user\n", name);
}
void cb_name_cancel(PurpleAccount *account, const char *user_info)
{
g_return_if_fail(bar->installed);
bar->name_dialog = FALSE;
}
void cb_pm_apply(gpointer data, PurpleRequestFields *fields)
{
g_return_if_fail(bar->installed);
/* attrs */
GList *a_tune = NULL;
GList *a_mood = NULL;
/* just to update widget */
const gchar *pm = purple_request_fields_get_string(fields, PREF "/personal-message");
const gchar *markup = purple_prefs_get_string(PREF "/personal-message-markup");
set_status_message(pm);
set_widget_pm(markup, pm);
purple_debug_info(NAME, "personal message changed to \"%s\" by user\n", pm);
const struct r_field {
const gchar *id;
const gchar *attr;
GList **list;
} r_fields[] = {
{ PREF "/mood-message", PURPLE_MOOD_COMMENT, &a_mood },
{ PREF "/tune-title", PURPLE_TUNE_TITLE, &a_tune },
{ PREF "/tune-artist", PURPLE_TUNE_ARTIST, &a_tune },
{ PREF "/tune-album", PURPLE_TUNE_ALBUM, &a_tune },
{ PREF "/game-message", "game", &a_tune },
{ PREF "/office-message", "office", &a_tune },
{ NULL, NULL, NULL }
}; const register struct r_field *rf = r_fields;
for(; rf->id ; rf++) {
const gchar *value = purple_request_fields_get_string(fields, rf->id);
if(!purple_prefs_get_bool(PREF "/reset-attrs"))
purple_prefs_set_string(rf->id, value);
if(value && !strcmp(value, ""))
value = NULL;
else
purple_debug_info(NAME, "%s message changed to \"%s\" by user\n",
rf->attr, value);
*(rf->list) = g_list_append(*(rf->list), (gpointer)rf->attr);
*(rf->list) = g_list_append(*(rf->list), (gpointer)value);
}
const struct status_list {
const gchar *status_id;
GList *list;
gboolean cont;
} status[] = {
{ "tune", a_tune, TRUE },
{ "mood", a_mood, TRUE },
{ NULL, NULL, FALSE}
}; register const struct status_list *s = status;
for(; s->cont ; s++) {
set_status_all(s->status_id, s->list);
g_list_free(s->list);
}
bar->pm_dialog = FALSE;
}
void cb_pm_cancel(gpointer data, PurpleRequestFields *fields)
{
g_return_if_fail(bar->installed);
bar->pm_dialog = FALSE;
}
|
gawen947/pidgin-pbar
|
8686fd1ee8c38bde2c1f0e523d8062cbba3053d1
|
Fix double deconnection bug
|
diff --git a/widget.c b/widget.c
index 6b4051d..80d42de 100644
--- a/widget.c
+++ b/widget.c
@@ -1,638 +1,657 @@
/* File: widget.c
- Time-stamp: <2011-06-17 16:01:30 gawen>
+ Time-stamp: <2011-06-17 16:39:05 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "pbar.h"
#include "widget.h"
#include "widget_gtk.h"
#include "widget_prpl.h"
#include "preferences.h"
#include "purple.h"
#include "gtk.h"
/* we only have one widget per plugin
but this might change in the future */
struct widget *bar;
void create_widget()
{
/* this should occurs only once but
this way we avoid memory leaks */
if(!bar)
bar = g_malloc(sizeof(struct widget));
memset(bar, 0, sizeof(struct widget));
/* widgets that can possibly be modified along plugin's execution */
bar->icon = gtk_image_new();
bar->status = gtk_button_new_from_stock(NULL);
bar->mood = gtk_button_new_from_stock(NULL);
bar->name_label = gtk_label_new(NULL);
bar->name_eventbox = gtk_event_box_new();
bar->name_entry = gtk_entry_new();
bar->pm_label = gtk_label_new(NULL);
bar->pm_eventbox = gtk_event_box_new();
bar->pm_entry = gtk_entry_new();
bar->hbox = gtk_hbox_new(FALSE, 2);
bar->icon_eventbox = gtk_event_box_new();
bar->status_menu = gtk_menu_new();
bar->mood_menu = gtk_menu_new();
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(bar), bar->hbox);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->status_menu);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->mood_menu);
/* widgets that are not modified */
GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
GtkWidget *hbox1 = gtk_hbox_new(FALSE, 2);
GtkWidget *hbox2 = gtk_hbox_new(FALSE, 2);
/* setup widgets */
gtk_label_set_ellipsize(GTK_LABEL(bar->name_label), PANGO_ELLIPSIZE_END);
gtk_label_set_ellipsize(GTK_LABEL(bar->pm_label), PANGO_ELLIPSIZE_END);
gtk_label_set_max_width_chars(GTK_LABEL(bar->name_label), 50);
gtk_button_set_relief(GTK_BUTTON(bar->status), GTK_RELIEF_NONE);
gtk_button_set_relief(GTK_BUTTON(bar->mood), GTK_RELIEF_NONE);
gtk_widget_set_can_focus(bar->name_eventbox, FALSE);
gtk_widget_set_can_focus(bar->pm_eventbox, FALSE);
gtk_widget_set_can_focus(bar->status, FALSE);
gtk_widget_set_can_focus(bar->mood, FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->icon_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->name_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->pm_eventbox), FALSE);
/* pack widgets */
gtk_container_add(GTK_CONTAINER(bar->name_eventbox), bar->name_label);
gtk_container_add(GTK_CONTAINER(bar->pm_eventbox), bar->pm_label);
gtk_container_add(GTK_CONTAINER(bar->icon_eventbox), bar->icon);
if(purple_prefs_get_bool(PREF "/compact")) {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
}
else {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0);
}
gtk_box_pack_start(GTK_BOX(bar->hbox), bar->icon_eventbox, FALSE, FALSE, 5);
gtk_box_pack_start(GTK_BOX(bar->hbox), vbox, TRUE, TRUE, 0);
/* pack at top of the buddy list and fallback to top
if the position option is unknown */
void (*gtk_box_pack)(GtkBox *, GtkWidget *, gboolean, gboolean, guint) = gtk_box_pack_start;
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
switch(purple_prefs_get_int(PREF "/widget-position")) {
case(POSITION_TOP):
gtk_box_pack = gtk_box_pack_start;
break;
case(POSITION_BOTTOM):
gtk_box_pack = gtk_box_pack_end;
break;
};
gtk_box_pack(GTK_BOX(blist->vbox), bar->hbox, FALSE, TRUE, 2);
gtk_box_reorder_child(GTK_BOX(blist->vbox), bar->hbox, 0);
/* setup initial states */
bar->gtk_hnd = NULL;
bar->gtk_inst = NULL;
bar->hover_name = FALSE;
bar->hover_pm = FALSE;
bar->name_entry_activated = FALSE;
bar->pm_entry_activated = FALSE;
bar->name_dialog = FALSE;
bar->pm_dialog = FALSE;
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ bar->icon_eventbox, "button-press-event", cb_buddy_icon },
{ bar->icon_eventbox, "enter-notify-event", cb_buddy_icon_enter },
{ bar->icon_eventbox, "leave-notify-event", cb_buddy_icon_leave },
{ bar->name_eventbox, "button-press-event", cb_name },
{ bar->name_eventbox, "enter-notify-event", cb_name_enter },
{ bar->name_eventbox, "leave-notify-event", cb_name_leave },
{ bar->name_entry, "activate", cb_name_entry },
{ bar->name_entry, "focus-out-event", cb_name_entry_focus_out },
{ bar->pm_eventbox, "button-press-event", cb_pm },
{ bar->pm_eventbox, "enter-notify-event", cb_pm_enter },
{ bar->pm_eventbox, "leave-notify-event", cb_pm_leave },
{ bar->pm_entry, "activate", cb_pm_entry },
{ bar->pm_entry, "focus-out-event", cb_pm_entry_focus_out },
{ bar->status, "clicked", cb_status_button },
{ bar->mood, "clicked", cb_mood_button },
{ NULL, NULL, NULL }
};
/* purple signals and callback */
const struct pbar_prpl_signal p_signal_connections[] = {
{ purple_accounts_get_handle(), "account-status-changed", cb_status },
{ purple_connections_get_handle(), "signed-on", cb_signed_on },
{ purple_connections_get_handle(), "signed-off", cb_signed_off },
{ NULL, NULL, NULL }
};
/* purple preferences signals and callback */
const struct pbar_prpl_signal pp_signal_connections[] = {
{ bar, PIDGIN_PREFS_ROOT "/accounts/buddyicon", cb_buddy_icon_update },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(bar), g_signal_connections, NULL);
prpl_connect_signals(PBAR_WIDGET(bar), p_signal_connections, NULL);
prpl_prefs_connect_signals(PBAR_WIDGET(bar), pp_signal_connections, NULL);
/* show everything */
gtk_widget_show_all(bar->hbox);
gtk_widget_hide(bar->name_entry);
gtk_widget_hide(bar->pm_entry);
/* inform that the bar is installed */
widget_set_all_sensitive(FALSE);
bar->installed = TRUE;
}
void destroy_widget()
{
g_return_if_fail(bar->installed);
bar->installed = FALSE;
/* disconnect purple and prefs signals */
prpl_disconnect_signals(PBAR_WIDGET(bar));
prpl_prefs_disconnect_signals(PBAR_WIDGET(bar));
gtk_destroy(PBAR_WIDGET(bar)); /* destroy widgets */
g_free(bar); /* free widget */
bar = NULL;
}
/* load preferences into our widget */
void init_widget()
{
g_return_if_fail(bar->installed);
/* entry frame */
gboolean state = purple_prefs_get_bool(PREF "/frame-entry");
set_widget_entry_frame(state);
/* nickname */
const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup");
const gchar *value = purple_prefs_get_string(PREF "/nickname");
int jtype = purple_prefs_get_int(PREF "/nickname-justify");
set_widget_name(markup, value);
set_widget_name_justify(jtype);
/* personal message */
markup = purple_prefs_get_string(PREF "/personal-message-markup");
value = purple_prefs_get_string(PREF "/personal-message");
jtype = purple_prefs_get_int(PREF "/personal-message-justify");
set_widget_pm(markup, value);
set_widget_pm_justify(jtype);
/* buddy icon */
GdkPixbuf *icon = get_buddy_icon();
set_widget_icon(icon);
/* mood image */
const gchar *current_mood = purple_prefs_get_string(PREF "/mood");
gchar *path = get_mood_icon_path(current_mood);
set_widget_mood(path);
g_free(path);
/* status image */
const gchar *stock = get_status_stock_id();
set_widget_status(stock);
/* fill status menu */
GList *accts = purple_accounts_get_all_active();
GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = (PurpleAccount *)accts->data;
GList *types = purple_account_get_status_types(account);
for(; types ; types = types->next) {
PurpleStatusType *type = (PurpleStatusType *)types->data;
PurpleStatusPrimitive prim;
const gchar *stock, *status_name;
GtkWidget *menu_item, *icon;
if(!purple_status_type_is_user_settable(type) ||
purple_status_type_is_independent(type))
continue;
prim = purple_status_type_get_primitive(type);
stock = pidgin_stock_id_from_status_primitive(prim);
if(g_hash_table_lookup(global_status, stock))
continue;
else
g_hash_table_insert(global_status, (gpointer)stock,
GINT_TO_POINTER(TRUE));
status_name = purple_status_type_get_name(type);
menu_item = gtk_image_menu_item_new_with_label(status_name);
icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), icon);
gtk_menu_shell_append(GTK_MENU_SHELL(bar->status_menu), menu_item);
g_signal_connect_swapped(menu_item, "activate",
G_CALLBACK(cb_status_menu),
(gpointer)type);
gtk_widget_show(menu_item);
}
}
g_hash_table_destroy(global_status);
/* statusbox hiding */
state = purple_prefs_get_bool(PREF "/hide-statusbox");
set_statusbox_visible(!state);
}
/* create a change name dialog */
void create_name_dialog()
{
const gchar *name = purple_prefs_get_string(PREF "/nickname");
if(!name || !strcmp(name, EMPTY_NAME))
name = "";
purple_request_input(thisplugin,
_("Change nickname"),
_("Enter your nickname here..."),
_("This will change your nickname "
"for every account which supports it."),
name,
FALSE,
FALSE,
NULL,
_("OK"),
G_CALLBACK(cb_name_apply),
_("Cancel"),
G_CALLBACK(cb_name_cancel),
NULL,
NULL,
NULL,
NULL);
bar->name_dialog = TRUE;
}
/* disable every features of the widget */
void widget_set_all_sensitive(gboolean sensitive)
{
GtkWidget *widgets[] = {
bar->icon,
bar->icon_eventbox,
bar->status,
bar->status_menu,
bar->mood,
bar->mood_menu,
bar->name_label,
bar->name_eventbox,
bar->name_entry,
bar->pm_label,
bar->pm_eventbox,
bar->pm_entry,
NULL
}; GtkWidget **w = widgets;
gboolean *attrs[] = {
&bar->mood_message,
&bar->current_song,
&bar->song_title,
&bar->song_album,
&bar->game_name,
&bar->office_app,
NULL
}; gboolean **a = attrs;
for(; *w ; w++)
gtk_widget_set_sensitive(*w, sensitive);
for(; *a ; a++)
**a = sensitive;
}
+#define assert_ref(count, inc) (bar->count > 0 || inc > 0)
+
/* enable/disable features when an account changes */
void account_changes(PurpleConnection *gc, gboolean enable)
{
int inc = 1;
PurpleAccount *acct = purple_connection_get_account(gc);
PurplePlugin *plugin = purple_find_prpl(acct->protocol_id);
PurplePluginProtocolInfo *protocol = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
PurpleMood *mood = get_global_moods();
GHashTable *attrs = get_account_attrs(acct);
if(!enable)
inc = -1;
/* update references */
- if(g_hash_table_lookup(attrs, "mood") && mood->mood)
- bar->mood_ref += inc;
- if(g_hash_table_lookup(attrs, "moodtext") && mood->mood)
+ if(g_hash_table_lookup(attrs, "mood") && mood->mood &&
+ assert_ref(mood_ref, inc))
+ bar->mood_ref += inc;
+ if(g_hash_table_lookup(attrs, "moodtext") && mood->mood &&
+ assert_ref(mood_message_ref, inc))
bar->mood_message_ref += inc;
- if(g_hash_table_lookup(attrs, "game"))
+ if(g_hash_table_lookup(attrs, "game") && assert_ref(game_name_ref, inc))
bar->game_name_ref += inc;
- if(g_hash_table_lookup(attrs, "office"))
+ if(g_hash_table_lookup(attrs, "office") && assert_ref(office_app_ref, inc))
bar->office_app_ref += inc;
if(g_hash_table_lookup(attrs, "tune_title") &&
g_hash_table_lookup(attrs, "tune_artist") &&
- g_hash_table_lookup(attrs, "tune_album"))
+ g_hash_table_lookup(attrs, "tune_album") &&
+ assert_ref(current_song_ref, inc))
bar->current_song_ref += inc;
- if(protocol->set_status)
+ if(protocol->set_status && assert_ref(pm_ref, inc))
bar->pm_ref += inc;
- if(protocol->set_buddy_icon)
+ if(protocol->set_buddy_icon && assert_ref(icon_ref, inc))
bar->icon_ref += inc;
- if(!strcmp(acct->protocol_id, "prpl-jabber") || protocol->set_public_alias)
+ if((!strcmp(acct->protocol_id, "prpl-jabber") || protocol->set_public_alias)&&
+ assert_ref(name_ref, inc))
bar->name_ref += inc;
- bar->status_ref += inc;
+ if(assert_ref(status_ref, inc))
+ bar->status_ref += inc;
+
+ printf("account ref : %d %d %d %d %d %d %d %d %d %d\n",
+ bar->icon_ref,
+ bar->status_ref,
+ bar->mood_ref,
+ bar->name_ref,
+ bar->pm_ref,
+ bar->mood_message_ref,
+ bar->current_song_ref,
+ bar->song_title_ref,
+ bar->game_name_ref,
+ bar->office_app_ref);
/* update widgets sensitive */
gtk_widget_set_sensitive(bar->icon, bar->icon_ref);
gtk_widget_set_sensitive(bar->icon_eventbox, bar->icon_ref);
gtk_widget_set_sensitive(bar->status, bar->status_ref);
gtk_widget_set_sensitive(bar->status_menu, bar->status_ref);
gtk_widget_set_sensitive(bar->mood, bar->mood_ref);
gtk_widget_set_sensitive(bar->mood_menu, bar->mood_ref);
gtk_widget_set_sensitive(bar->name_label, bar->name_ref);
gtk_widget_set_sensitive(bar->name_eventbox, bar->name_ref);
gtk_widget_set_sensitive(bar->name_entry, bar->name_ref);
gtk_widget_set_sensitive(bar->pm_label, bar->pm_ref + bar->mood_message_ref +\
bar->game_name_ref + bar->office_app_ref +\
bar->current_song_ref);
gtk_widget_set_sensitive(bar->pm_eventbox, bar->pm_ref +
bar->mood_message_ref + bar->game_name_ref +
bar->office_app_ref + bar->current_song_ref);
gtk_widget_set_sensitive(bar->pm_entry, bar->pm_ref +
bar->mood_message_ref + bar->game_name_ref +
bar->office_app_ref + bar->current_song_ref);
bar->pm_message = bar->pm_ref;
bar->mood_message = bar->mood_message_ref;
bar->current_song = bar->current_song_ref;
bar->song_title = bar->current_song_ref;
bar->song_album = bar->current_song_ref;
bar->game_name = bar->game_name;
bar->office_app = bar->office_app;
}
/* create a personal message dialog */
void create_pm_dialog()
{
PurpleRequestFields *fields;
PurpleRequestFieldGroup *group;
PurpleRequestField *field;
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
if(!pm || !strcmp(pm, EMPTY_PM))
pm = "";
const struct s_field {
const gchar *text;
const gchar *pref;
gboolean enable;
} groups[] = {
{ N_("_Mood message"), PREF "/mood-message", bar->mood_message },
{ N_("Current song"), NULL, bar->current_song },
{ N_("Song _title"), PREF "/tune-title", bar->current_song },
{ N_("Song _artist"), PREF "/tune-artist", bar->song_title },
{ N_("Song al_bum"), PREF "/tune-album", bar->song_album },
{ N_("MSN pecan extra attributes"), NULL, bar->game_name && bar->office_app },
{ N_("_Game name"), PREF "/game-message", bar->game_name },
{ N_("_Office app name"), PREF "/office-message", bar->office_app },
{ NULL, NULL },
{ NULL, NULL }
}; const struct s_field *g = groups;
fields = purple_request_fields_new();
group = purple_request_field_group_new(_("Status and mood message"));
purple_request_fields_add_group(fields, group);
if(bar->pm_message) {
field = purple_request_field_string_new(PREF "/personal-message",
_("_Personal message"),
pm,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
for(; g->pref ; g++) {
for(; g->pref ; g++) {
const gchar *message;
if(!g->enable)
continue;
else if(purple_prefs_get_bool(PREF "/reset-attrs"))
message = "";
else
message = purple_prefs_get_string(g->pref);
field = purple_request_field_string_new(g->pref,
_(g->text),
message,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
if(g->enable) {
group = purple_request_field_group_new(_(g->text));
purple_request_fields_add_group(fields, group);
}
}
purple_request_fields(thisplugin,
_("Change status messages"),
_("Enter status message..."),
_("This will change some status messages for every "
"account which supports it, please be advised "
"that some are inconsistent between each other."),
fields,
_("OK"),
G_CALLBACK(cb_pm_apply),
_("Cancel"),
G_CALLBACK(cb_pm_cancel),
NULL, NULL, NULL, NULL);
bar->pm_dialog = TRUE;
}
/* replace format character <c><r> with <n> string and escape with <c><c> */
static gchar * g_strreplacefmt(const gchar *s, gchar c, gchar r, const gchar *n)
{
int sn = strlen(n);
int sr = strlen(s);
int index = 0;
gchar *ret = g_malloc(sr);
for(; *s != '\0' ; s++) {
if(*s == c) {
s++;
if(*s == r) {
const gchar *i = n;
sr += sn;
ret = g_realloc(ret, sr);
for(; *i != '\0' ; i++, index++)
ret[index] = *i;
continue;
}
else if(*s != c || *s == '\0')
s--;
}
ret[index] = *s;
index++;
}
ret[index] = '\0';
return ret;
}
void set_widget_name(const gchar *markup, const gchar *name)
{
g_return_if_fail(markup && name && bar->installed);
gchar *escaped_name, *new;
/* translate name if needed */
if(!strcmp(name, EMPTY_NAME))
name = _(EMPTY_NAME);
escaped_name = g_markup_printf_escaped("%s", name);
new = g_strreplacefmt(markup, '%', 'n', escaped_name);
g_free(escaped_name);
gtk_label_set_markup(GTK_LABEL(bar->name_label), new);
g_free(new);
}
void set_widget_pm(const gchar *markup, const gchar *pm)
{
g_return_if_fail(markup && pm && bar->installed);
gchar *escaped_pm, *new;
/* translate pm if needed */
if(!strcmp(pm, EMPTY_PM))
pm = _(EMPTY_PM);
escaped_pm = g_markup_printf_escaped("%s", pm);
new = g_strreplacefmt(markup, '%', 'p', escaped_pm);
g_free(escaped_pm);
gtk_label_set_markup(GTK_LABEL(bar->pm_label), new);
g_free(new);
}
void set_widget_status(const gchar *stock)
{
g_return_if_fail(stock && bar->installed);
GtkWidget *icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_button_set_image(GTK_BUTTON(bar->status), icon);
gtk_button_set_label(GTK_BUTTON(bar->status), "");
}
void set_widget_mood(const gchar *path)
{
g_return_if_fail(path && bar->installed);
GtkWidget *mood = gtk_image_new_from_file(path);
gtk_button_set_image(GTK_BUTTON(bar->mood), mood);
gtk_button_set_label(GTK_BUTTON(bar->mood), "");
}
void set_widget_icon(GdkPixbuf *icon)
{
g_return_if_fail(bar->installed);
if(icon)
gtk_image_set_from_pixbuf(GTK_IMAGE(bar->icon), icon);
else
gtk_image_set_from_stock(GTK_IMAGE(bar->icon), GTK_STOCK_MISSING_IMAGE, 48);
}
/* convertion of int justification
to float justification for
gtk_misc_set_alignment */
static float int_jtype_to_float_jtype(int justify)
{
float ret = 0.; /* default to left */
switch(justify) {
case(JUSTIFY_LEFT):
ret = 0.;
break;
case(JUSTIFY_CENTER):
ret = .5;
break;
case(JUSTIFY_RIGHT):
ret = 1.;
break;
}
return ret;
}
void set_widget_name_justify(int justify)
{
g_return_if_fail(bar->installed);
float jtype = int_jtype_to_float_jtype(justify);
gtk_misc_set_alignment(GTK_MISC(bar->name_label), jtype, .5);
}
void set_widget_pm_justify(int justify)
{
g_return_if_fail(bar->installed);
float jtype = int_jtype_to_float_jtype(justify);
gtk_misc_set_alignment(GTK_MISC(bar->pm_label), jtype, .5);
}
void set_widget_entry_frame(gboolean use_frame)
{
g_return_if_fail(bar->installed);
gtk_entry_set_has_frame(GTK_ENTRY(bar->name_entry), use_frame);
gtk_entry_set_has_frame(GTK_ENTRY(bar->pm_entry), use_frame);
}
void set_statusbox_visible(gboolean visible)
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
GtkWidget *statusbox = blist->statusbox;
if(statusbox)
gtk_widget_set_visible(statusbox, visible);
}
gboolean get_widget_name_hover_state() { return bar->hover_name; }
gboolean get_widget_pm_hover_state() { return bar->hover_pm; }
|
gawen947/pidgin-pbar
|
f020d9178f954ad9107ee70e6c74c5fc79116be9
|
Don't display moods when it's said to be available but none exists
|
diff --git a/widget.c b/widget.c
index 9584d67..6b4051d 100644
--- a/widget.c
+++ b/widget.c
@@ -1,637 +1,638 @@
/* File: widget.c
- Time-stamp: <2011-06-17 15:47:41 gawen>
+ Time-stamp: <2011-06-17 16:01:30 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "pbar.h"
#include "widget.h"
#include "widget_gtk.h"
#include "widget_prpl.h"
#include "preferences.h"
#include "purple.h"
#include "gtk.h"
/* we only have one widget per plugin
but this might change in the future */
struct widget *bar;
void create_widget()
{
/* this should occurs only once but
this way we avoid memory leaks */
if(!bar)
bar = g_malloc(sizeof(struct widget));
memset(bar, 0, sizeof(struct widget));
/* widgets that can possibly be modified along plugin's execution */
bar->icon = gtk_image_new();
bar->status = gtk_button_new_from_stock(NULL);
bar->mood = gtk_button_new_from_stock(NULL);
bar->name_label = gtk_label_new(NULL);
bar->name_eventbox = gtk_event_box_new();
bar->name_entry = gtk_entry_new();
bar->pm_label = gtk_label_new(NULL);
bar->pm_eventbox = gtk_event_box_new();
bar->pm_entry = gtk_entry_new();
bar->hbox = gtk_hbox_new(FALSE, 2);
bar->icon_eventbox = gtk_event_box_new();
bar->status_menu = gtk_menu_new();
bar->mood_menu = gtk_menu_new();
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(bar), bar->hbox);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->status_menu);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->mood_menu);
/* widgets that are not modified */
GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
GtkWidget *hbox1 = gtk_hbox_new(FALSE, 2);
GtkWidget *hbox2 = gtk_hbox_new(FALSE, 2);
/* setup widgets */
gtk_label_set_ellipsize(GTK_LABEL(bar->name_label), PANGO_ELLIPSIZE_END);
gtk_label_set_ellipsize(GTK_LABEL(bar->pm_label), PANGO_ELLIPSIZE_END);
gtk_label_set_max_width_chars(GTK_LABEL(bar->name_label), 50);
gtk_button_set_relief(GTK_BUTTON(bar->status), GTK_RELIEF_NONE);
gtk_button_set_relief(GTK_BUTTON(bar->mood), GTK_RELIEF_NONE);
gtk_widget_set_can_focus(bar->name_eventbox, FALSE);
gtk_widget_set_can_focus(bar->pm_eventbox, FALSE);
gtk_widget_set_can_focus(bar->status, FALSE);
gtk_widget_set_can_focus(bar->mood, FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->icon_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->name_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->pm_eventbox), FALSE);
/* pack widgets */
gtk_container_add(GTK_CONTAINER(bar->name_eventbox), bar->name_label);
gtk_container_add(GTK_CONTAINER(bar->pm_eventbox), bar->pm_label);
gtk_container_add(GTK_CONTAINER(bar->icon_eventbox), bar->icon);
if(purple_prefs_get_bool(PREF "/compact")) {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
}
else {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0);
}
gtk_box_pack_start(GTK_BOX(bar->hbox), bar->icon_eventbox, FALSE, FALSE, 5);
gtk_box_pack_start(GTK_BOX(bar->hbox), vbox, TRUE, TRUE, 0);
/* pack at top of the buddy list and fallback to top
if the position option is unknown */
void (*gtk_box_pack)(GtkBox *, GtkWidget *, gboolean, gboolean, guint) = gtk_box_pack_start;
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
switch(purple_prefs_get_int(PREF "/widget-position")) {
case(POSITION_TOP):
gtk_box_pack = gtk_box_pack_start;
break;
case(POSITION_BOTTOM):
gtk_box_pack = gtk_box_pack_end;
break;
};
gtk_box_pack(GTK_BOX(blist->vbox), bar->hbox, FALSE, TRUE, 2);
gtk_box_reorder_child(GTK_BOX(blist->vbox), bar->hbox, 0);
/* setup initial states */
bar->gtk_hnd = NULL;
bar->gtk_inst = NULL;
bar->hover_name = FALSE;
bar->hover_pm = FALSE;
bar->name_entry_activated = FALSE;
bar->pm_entry_activated = FALSE;
bar->name_dialog = FALSE;
bar->pm_dialog = FALSE;
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ bar->icon_eventbox, "button-press-event", cb_buddy_icon },
{ bar->icon_eventbox, "enter-notify-event", cb_buddy_icon_enter },
{ bar->icon_eventbox, "leave-notify-event", cb_buddy_icon_leave },
{ bar->name_eventbox, "button-press-event", cb_name },
{ bar->name_eventbox, "enter-notify-event", cb_name_enter },
{ bar->name_eventbox, "leave-notify-event", cb_name_leave },
{ bar->name_entry, "activate", cb_name_entry },
{ bar->name_entry, "focus-out-event", cb_name_entry_focus_out },
{ bar->pm_eventbox, "button-press-event", cb_pm },
{ bar->pm_eventbox, "enter-notify-event", cb_pm_enter },
{ bar->pm_eventbox, "leave-notify-event", cb_pm_leave },
{ bar->pm_entry, "activate", cb_pm_entry },
{ bar->pm_entry, "focus-out-event", cb_pm_entry_focus_out },
{ bar->status, "clicked", cb_status_button },
{ bar->mood, "clicked", cb_mood_button },
{ NULL, NULL, NULL }
};
/* purple signals and callback */
const struct pbar_prpl_signal p_signal_connections[] = {
{ purple_accounts_get_handle(), "account-status-changed", cb_status },
{ purple_connections_get_handle(), "signed-on", cb_signed_on },
{ purple_connections_get_handle(), "signed-off", cb_signed_off },
{ NULL, NULL, NULL }
};
/* purple preferences signals and callback */
const struct pbar_prpl_signal pp_signal_connections[] = {
{ bar, PIDGIN_PREFS_ROOT "/accounts/buddyicon", cb_buddy_icon_update },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(bar), g_signal_connections, NULL);
prpl_connect_signals(PBAR_WIDGET(bar), p_signal_connections, NULL);
prpl_prefs_connect_signals(PBAR_WIDGET(bar), pp_signal_connections, NULL);
/* show everything */
gtk_widget_show_all(bar->hbox);
gtk_widget_hide(bar->name_entry);
gtk_widget_hide(bar->pm_entry);
/* inform that the bar is installed */
widget_set_all_sensitive(FALSE);
bar->installed = TRUE;
}
void destroy_widget()
{
g_return_if_fail(bar->installed);
bar->installed = FALSE;
/* disconnect purple and prefs signals */
prpl_disconnect_signals(PBAR_WIDGET(bar));
prpl_prefs_disconnect_signals(PBAR_WIDGET(bar));
gtk_destroy(PBAR_WIDGET(bar)); /* destroy widgets */
g_free(bar); /* free widget */
bar = NULL;
}
/* load preferences into our widget */
void init_widget()
{
g_return_if_fail(bar->installed);
/* entry frame */
gboolean state = purple_prefs_get_bool(PREF "/frame-entry");
set_widget_entry_frame(state);
/* nickname */
const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup");
const gchar *value = purple_prefs_get_string(PREF "/nickname");
int jtype = purple_prefs_get_int(PREF "/nickname-justify");
set_widget_name(markup, value);
set_widget_name_justify(jtype);
/* personal message */
markup = purple_prefs_get_string(PREF "/personal-message-markup");
value = purple_prefs_get_string(PREF "/personal-message");
jtype = purple_prefs_get_int(PREF "/personal-message-justify");
set_widget_pm(markup, value);
set_widget_pm_justify(jtype);
/* buddy icon */
GdkPixbuf *icon = get_buddy_icon();
set_widget_icon(icon);
/* mood image */
const gchar *current_mood = purple_prefs_get_string(PREF "/mood");
gchar *path = get_mood_icon_path(current_mood);
set_widget_mood(path);
g_free(path);
/* status image */
const gchar *stock = get_status_stock_id();
set_widget_status(stock);
/* fill status menu */
GList *accts = purple_accounts_get_all_active();
GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = (PurpleAccount *)accts->data;
GList *types = purple_account_get_status_types(account);
for(; types ; types = types->next) {
PurpleStatusType *type = (PurpleStatusType *)types->data;
PurpleStatusPrimitive prim;
const gchar *stock, *status_name;
GtkWidget *menu_item, *icon;
if(!purple_status_type_is_user_settable(type) ||
purple_status_type_is_independent(type))
continue;
prim = purple_status_type_get_primitive(type);
stock = pidgin_stock_id_from_status_primitive(prim);
if(g_hash_table_lookup(global_status, stock))
continue;
else
g_hash_table_insert(global_status, (gpointer)stock,
GINT_TO_POINTER(TRUE));
status_name = purple_status_type_get_name(type);
menu_item = gtk_image_menu_item_new_with_label(status_name);
icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), icon);
gtk_menu_shell_append(GTK_MENU_SHELL(bar->status_menu), menu_item);
g_signal_connect_swapped(menu_item, "activate",
G_CALLBACK(cb_status_menu),
(gpointer)type);
gtk_widget_show(menu_item);
}
}
g_hash_table_destroy(global_status);
/* statusbox hiding */
state = purple_prefs_get_bool(PREF "/hide-statusbox");
set_statusbox_visible(!state);
}
/* create a change name dialog */
void create_name_dialog()
{
const gchar *name = purple_prefs_get_string(PREF "/nickname");
if(!name || !strcmp(name, EMPTY_NAME))
name = "";
purple_request_input(thisplugin,
_("Change nickname"),
_("Enter your nickname here..."),
_("This will change your nickname "
"for every account which supports it."),
name,
FALSE,
FALSE,
NULL,
_("OK"),
G_CALLBACK(cb_name_apply),
_("Cancel"),
G_CALLBACK(cb_name_cancel),
NULL,
NULL,
NULL,
NULL);
bar->name_dialog = TRUE;
}
/* disable every features of the widget */
void widget_set_all_sensitive(gboolean sensitive)
{
GtkWidget *widgets[] = {
bar->icon,
bar->icon_eventbox,
bar->status,
bar->status_menu,
bar->mood,
bar->mood_menu,
bar->name_label,
bar->name_eventbox,
bar->name_entry,
bar->pm_label,
bar->pm_eventbox,
bar->pm_entry,
NULL
}; GtkWidget **w = widgets;
gboolean *attrs[] = {
&bar->mood_message,
&bar->current_song,
&bar->song_title,
&bar->song_album,
&bar->game_name,
&bar->office_app,
NULL
}; gboolean **a = attrs;
for(; *w ; w++)
gtk_widget_set_sensitive(*w, sensitive);
for(; *a ; a++)
**a = sensitive;
}
/* enable/disable features when an account changes */
void account_changes(PurpleConnection *gc, gboolean enable)
{
int inc = 1;
PurpleAccount *acct = purple_connection_get_account(gc);
PurplePlugin *plugin = purple_find_prpl(acct->protocol_id);
PurplePluginProtocolInfo *protocol = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
+ PurpleMood *mood = get_global_moods();
GHashTable *attrs = get_account_attrs(acct);
if(!enable)
inc = -1;
/* update references */
- if(g_hash_table_lookup(attrs, "mood"))
+ if(g_hash_table_lookup(attrs, "mood") && mood->mood)
bar->mood_ref += inc;
- if(g_hash_table_lookup(attrs, "moodtext"))
+ if(g_hash_table_lookup(attrs, "moodtext") && mood->mood)
bar->mood_message_ref += inc;
if(g_hash_table_lookup(attrs, "game"))
bar->game_name_ref += inc;
if(g_hash_table_lookup(attrs, "office"))
bar->office_app_ref += inc;
if(g_hash_table_lookup(attrs, "tune_title") &&
g_hash_table_lookup(attrs, "tune_artist") &&
g_hash_table_lookup(attrs, "tune_album"))
bar->current_song_ref += inc;
if(protocol->set_status)
bar->pm_ref += inc;
if(protocol->set_buddy_icon)
bar->icon_ref += inc;
if(!strcmp(acct->protocol_id, "prpl-jabber") || protocol->set_public_alias)
bar->name_ref += inc;
bar->status_ref += inc;
/* update widgets sensitive */
gtk_widget_set_sensitive(bar->icon, bar->icon_ref);
gtk_widget_set_sensitive(bar->icon_eventbox, bar->icon_ref);
gtk_widget_set_sensitive(bar->status, bar->status_ref);
gtk_widget_set_sensitive(bar->status_menu, bar->status_ref);
gtk_widget_set_sensitive(bar->mood, bar->mood_ref);
gtk_widget_set_sensitive(bar->mood_menu, bar->mood_ref);
gtk_widget_set_sensitive(bar->name_label, bar->name_ref);
gtk_widget_set_sensitive(bar->name_eventbox, bar->name_ref);
gtk_widget_set_sensitive(bar->name_entry, bar->name_ref);
gtk_widget_set_sensitive(bar->pm_label, bar->pm_ref + bar->mood_message_ref +\
bar->game_name_ref + bar->office_app_ref +\
bar->current_song_ref);
gtk_widget_set_sensitive(bar->pm_eventbox, bar->pm_ref +
bar->mood_message_ref + bar->game_name_ref +
bar->office_app_ref + bar->current_song_ref);
gtk_widget_set_sensitive(bar->pm_entry, bar->pm_ref +
bar->mood_message_ref + bar->game_name_ref +
bar->office_app_ref + bar->current_song_ref);
bar->pm_message = bar->pm_ref;
bar->mood_message = bar->mood_message_ref;
bar->current_song = bar->current_song_ref;
bar->song_title = bar->current_song_ref;
bar->song_album = bar->current_song_ref;
bar->game_name = bar->game_name;
bar->office_app = bar->office_app;
}
/* create a personal message dialog */
void create_pm_dialog()
{
PurpleRequestFields *fields;
PurpleRequestFieldGroup *group;
PurpleRequestField *field;
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
if(!pm || !strcmp(pm, EMPTY_PM))
pm = "";
const struct s_field {
const gchar *text;
const gchar *pref;
gboolean enable;
} groups[] = {
{ N_("_Mood message"), PREF "/mood-message", bar->mood_message },
{ N_("Current song"), NULL, bar->current_song },
{ N_("Song _title"), PREF "/tune-title", bar->current_song },
{ N_("Song _artist"), PREF "/tune-artist", bar->song_title },
{ N_("Song al_bum"), PREF "/tune-album", bar->song_album },
{ N_("MSN pecan extra attributes"), NULL, bar->game_name && bar->office_app },
{ N_("_Game name"), PREF "/game-message", bar->game_name },
{ N_("_Office app name"), PREF "/office-message", bar->office_app },
{ NULL, NULL },
{ NULL, NULL }
}; const struct s_field *g = groups;
fields = purple_request_fields_new();
group = purple_request_field_group_new(_("Status and mood message"));
purple_request_fields_add_group(fields, group);
if(bar->pm_message) {
field = purple_request_field_string_new(PREF "/personal-message",
_("_Personal message"),
pm,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
for(; g->pref ; g++) {
for(; g->pref ; g++) {
const gchar *message;
if(!g->enable)
continue;
else if(purple_prefs_get_bool(PREF "/reset-attrs"))
message = "";
else
message = purple_prefs_get_string(g->pref);
field = purple_request_field_string_new(g->pref,
_(g->text),
message,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
if(g->enable) {
group = purple_request_field_group_new(_(g->text));
purple_request_fields_add_group(fields, group);
}
}
purple_request_fields(thisplugin,
_("Change status messages"),
_("Enter status message..."),
_("This will change some status messages for every "
"account which supports it, please be advised "
"that some are inconsistent between each other."),
fields,
_("OK"),
G_CALLBACK(cb_pm_apply),
_("Cancel"),
G_CALLBACK(cb_pm_cancel),
NULL, NULL, NULL, NULL);
bar->pm_dialog = TRUE;
}
/* replace format character <c><r> with <n> string and escape with <c><c> */
static gchar * g_strreplacefmt(const gchar *s, gchar c, gchar r, const gchar *n)
{
int sn = strlen(n);
int sr = strlen(s);
int index = 0;
gchar *ret = g_malloc(sr);
for(; *s != '\0' ; s++) {
if(*s == c) {
s++;
if(*s == r) {
const gchar *i = n;
sr += sn;
ret = g_realloc(ret, sr);
for(; *i != '\0' ; i++, index++)
ret[index] = *i;
continue;
}
else if(*s != c || *s == '\0')
s--;
}
ret[index] = *s;
index++;
}
ret[index] = '\0';
return ret;
}
void set_widget_name(const gchar *markup, const gchar *name)
{
g_return_if_fail(markup && name && bar->installed);
gchar *escaped_name, *new;
/* translate name if needed */
if(!strcmp(name, EMPTY_NAME))
name = _(EMPTY_NAME);
escaped_name = g_markup_printf_escaped("%s", name);
new = g_strreplacefmt(markup, '%', 'n', escaped_name);
g_free(escaped_name);
gtk_label_set_markup(GTK_LABEL(bar->name_label), new);
g_free(new);
}
void set_widget_pm(const gchar *markup, const gchar *pm)
{
g_return_if_fail(markup && pm && bar->installed);
gchar *escaped_pm, *new;
/* translate pm if needed */
if(!strcmp(pm, EMPTY_PM))
pm = _(EMPTY_PM);
escaped_pm = g_markup_printf_escaped("%s", pm);
new = g_strreplacefmt(markup, '%', 'p', escaped_pm);
g_free(escaped_pm);
gtk_label_set_markup(GTK_LABEL(bar->pm_label), new);
g_free(new);
}
void set_widget_status(const gchar *stock)
{
g_return_if_fail(stock && bar->installed);
GtkWidget *icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_button_set_image(GTK_BUTTON(bar->status), icon);
gtk_button_set_label(GTK_BUTTON(bar->status), "");
}
void set_widget_mood(const gchar *path)
{
g_return_if_fail(path && bar->installed);
GtkWidget *mood = gtk_image_new_from_file(path);
gtk_button_set_image(GTK_BUTTON(bar->mood), mood);
gtk_button_set_label(GTK_BUTTON(bar->mood), "");
}
void set_widget_icon(GdkPixbuf *icon)
{
g_return_if_fail(bar->installed);
if(icon)
gtk_image_set_from_pixbuf(GTK_IMAGE(bar->icon), icon);
else
gtk_image_set_from_stock(GTK_IMAGE(bar->icon), GTK_STOCK_MISSING_IMAGE, 48);
}
/* convertion of int justification
to float justification for
gtk_misc_set_alignment */
static float int_jtype_to_float_jtype(int justify)
{
float ret = 0.; /* default to left */
switch(justify) {
case(JUSTIFY_LEFT):
ret = 0.;
break;
case(JUSTIFY_CENTER):
ret = .5;
break;
case(JUSTIFY_RIGHT):
ret = 1.;
break;
}
return ret;
}
void set_widget_name_justify(int justify)
{
g_return_if_fail(bar->installed);
float jtype = int_jtype_to_float_jtype(justify);
gtk_misc_set_alignment(GTK_MISC(bar->name_label), jtype, .5);
}
void set_widget_pm_justify(int justify)
{
g_return_if_fail(bar->installed);
float jtype = int_jtype_to_float_jtype(justify);
gtk_misc_set_alignment(GTK_MISC(bar->pm_label), jtype, .5);
}
void set_widget_entry_frame(gboolean use_frame)
{
g_return_if_fail(bar->installed);
gtk_entry_set_has_frame(GTK_ENTRY(bar->name_entry), use_frame);
gtk_entry_set_has_frame(GTK_ENTRY(bar->pm_entry), use_frame);
}
void set_statusbox_visible(gboolean visible)
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
GtkWidget *statusbox = blist->statusbox;
if(statusbox)
gtk_widget_set_visible(statusbox, visible);
}
gboolean get_widget_name_hover_state() { return bar->hover_name; }
gboolean get_widget_pm_hover_state() { return bar->hover_pm; }
|
gawen947/pidgin-pbar
|
d858343a440dfba30fff46686a81a54f584ec641
|
Disable features on signed-on/signed-off account
|
diff --git a/purple.c b/purple.c
index f4dccbf..6878965 100644
--- a/purple.c
+++ b/purple.c
@@ -1,402 +1,401 @@
/* File: purple.c
- Time-stamp: <2011-02-10 17:54:01 gawen>
+ Time-stamp: <2011-06-17 13:57:28 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* this file contains common functions for libpurple and pidgin */
#include "common.h"
#include "pbar.h"
#include "gtk.h"
#include "purple.h"
/* callbacks */
static void cb_global_moods_for_each(gpointer key, gpointer value,
gpointer user_data);
static void cb_set_alias_failure(PurpleAccount *account, const char *error);
static void cb_dummy();
/* check if default gtk blist is created */
gboolean is_gtk_blist_created()
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
if(!blist ||
!blist->vbox ||
!gtk_widget_get_visible(blist->vbox))
return FALSE;
return TRUE;
}
/* get buddy icon from statusbox widget */
GdkPixbuf * get_buddy_icon()
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
const PidginStatusBox *statusbox = PIDGIN_STATUS_BOX(blist->statusbox);
return statusbox->buddy_icon;
}
/* get buddy icon hovered from statusbox widget */
GdkPixbuf * get_buddy_icon_hover()
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
const PidginStatusBox *statusbox = PIDGIN_STATUS_BOX(blist->statusbox);
return statusbox->buddy_icon_hover;
}
/* create purple protocol icon from protocol info */
GdkPixbuf * create_prpl_icon_from_info(PurplePluginProtocolInfo *prpl_info,
PidginPrplIconSize size)
{
const char *protoname = NULL;
char *tmp;
char *filename = NULL;
GdkPixbuf *pixbuf;
if (prpl_info->list_icon == NULL)
return NULL;
protoname = prpl_info->list_icon(NULL, NULL);
if (protoname == NULL)
return NULL;
/*
* Status icons will be themeable too, and then it will look up
* protoname from the theme
*/
tmp = g_strconcat(protoname, ".png", NULL);
filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols",
size == PIDGIN_PRPL_ICON_SMALL ? "16" :
size == PIDGIN_PRPL_ICON_MEDIUM ? "22" : "48",
tmp, NULL);
g_free(tmp);
pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
g_free(filename);
return pixbuf;
}
/* get current status stock id */
const gchar * get_status_stock_id()
{
const PurpleSavedStatus *status = purple_savedstatus_get_current();
PurpleStatusPrimitive prim = purple_savedstatus_get_type(status);
return pidgin_stock_id_from_status_primitive(prim);
}
/* get mood icon path */
gchar * get_mood_icon_path(const gchar *mood)
{
gchar *path;
if(!mood || !strcmp(mood, ""))
path = g_build_filename(DATADIR, "pixmaps", "pidgin",
"toolbar", "16", "emote-select.png", NULL);
else if(!strcmp(mood, "busy"))
path = g_build_filename(DATADIR, "pixmaps", "pidgin",
"status", "16", "busy.png", NULL);
else if(!strcmp(mood, "hiptop"))
path = g_build_filename(DATADIR, "pixmaps", "pidgin",
"emblems", "16", "hiptop.png", NULL);
else {
gchar *filename = g_strdup_printf("%s.png", mood);
path = g_build_filename(DATADIR, "pixmaps", "pidgin",
"emotes", "small", filename, NULL);
g_free(filename);
}
return path;
}
/* get available attributes for a protocol
returned hashtable should be freed manually */
GHashTable * get_protocol_attrs(PurplePluginProtocolInfo *protocol)
{
if(!protocol->status_types)
return NULL;
GHashTable *attrs = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
GList *l = protocol->status_types(NULL);
for(; l ; l = l->next) {
PurpleStatusType *type = (PurpleStatusType *)l->data;
GList *k = purple_status_type_get_attrs(type);
for(; k ; k = k->next) {
struct _PurpleStatusAttr {
char *id;
char *name;
PurpleValue *value_type;
};
struct _PurpleStatusAttr *attr = (struct _PurpleStatusAttr *)k->data;
if(g_hash_table_lookup(attrs, attr->id))
continue;
else
g_hash_table_insert(attrs, (gpointer)attr->id,
GINT_TO_POINTER(TRUE));
}
}
return attrs;
}
/* get available attributes for an account
returned hashtable should be freed manally */
/* TODO: review this, now it does the same as get_protocol_attrs... */
GHashTable * get_account_attrs(PurpleAccount *account)
{
GHashTable *attrs = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
GList *l = purple_account_get_status_types(account);
for(; l ; l = l->next) {
PurpleStatusType *type = (PurpleStatusType *)l->data;
GList *k = purple_status_type_get_attrs(type);
for(; k ; k = k->next) {
struct _PurpleStatusAttr {
char *id;
char *name;
PurpleValue *value_type;
};
struct _PurpleStatusAttr *attr = (struct _PurpleStatusAttr *)k->data;
if(g_hash_table_lookup(attrs, attr->id))
continue;
else
g_hash_table_insert(attrs, (gpointer)attr->id,
GINT_TO_POINTER(TRUE));
}
}
return attrs;
}
/* get global moods */
PurpleMood * get_global_moods()
{
GHashTable *global_moods = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
GHashTable *mood_counts = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
GList *accounts = purple_accounts_get_all_active();
PurpleMood *result = NULL;
GList *out_moods = NULL;
int i = 0;
int num_accounts = 0;
for(; accounts ; accounts = g_list_delete_link(accounts, accounts)) {
PurpleAccount *account = (PurpleAccount *)accounts->data;
if(purple_account_is_connected(account)) {
PurpleConnection *gc = purple_account_get_connection(account);
if(gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS) {
PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(
gc->prpl);
PurpleMood *mood = NULL;
for(mood = prpl_info->get_moods(account) ;
mood->mood ; mood++) {
int mood_count = GPOINTER_TO_INT(g_hash_table_lookup(mood_counts,
mood->mood));
if(!g_hash_table_lookup(global_moods, mood->mood))
g_hash_table_insert(global_moods, (gpointer)mood->mood, mood);
g_hash_table_insert(mood_counts, (gpointer)mood->mood,
GINT_TO_POINTER(mood_count + 1));
}
num_accounts++;
}
}
}
g_hash_table_foreach(global_moods, cb_global_moods_for_each, &out_moods);
result = g_new0(PurpleMood, g_hash_table_size(global_moods) + 1);
while(out_moods) {
PurpleMood *mood = (PurpleMood *)out_moods->data;
int in_num_accounts = GPOINTER_TO_INT(g_hash_table_lookup(mood_counts,
mood->mood));
if(in_num_accounts == num_accounts) {
/* mood is present in all accounts supporting moods */
result[i].mood = mood->mood;
result[i].description = mood->description;
i++;
}
out_moods = g_list_delete_link(out_moods, out_moods);
}
g_hash_table_destroy(global_moods);
g_hash_table_destroy(mood_counts);
return result;
}
/* set status to the specified mood */
void set_status_with_mood(PurpleAccount *account, const gchar *mood)
{
purple_account_set_status(account, "mood", TRUE, PURPLE_MOOD_NAME, mood,
NULL);
}
/* set status to the specified mood for all accounts */
void set_status_with_mood_all(const gchar *mood)
{
GList *accts = purple_accounts_get_all_active();
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = (PurpleAccount *)accts->data;
PurpleConnection *gc = purple_account_get_connection(account);
if(gc && gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS)
set_status_with_mood(account, mood);
}
}
-
/* set exclusive status for all accounts */
void set_status_all(const gchar *status_id, GList *attrs)
{
GList *accts = purple_accounts_get_all_active();
/* empty list means we have nothing to do */
if(!attrs)
return;
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = accts->data;
if(!purple_account_is_connected(account))
continue;
purple_account_set_status_list(account, status_id, TRUE, attrs);
}
}
/* set display name for account */
void set_display_name(PurpleAccount *account, const gchar *name)
{
const gchar *id = purple_account_get_protocol_id(account);
/* exception for set_public_alias */
if(!strcmp(id, "prpl-jabber")) {
PurpleConnection *gc = account->gc;
gchar *iq_id = g_strdup_printf("purple%x", g_random_int());
xmlnode *iq, *pubsub, *publish, *nicknode;
gc = account->gc;
iq_id = g_strdup_printf("purple%x", g_random_int());
iq = xmlnode_new("iq");
xmlnode_set_attrib(iq, "type", "set");
xmlnode_set_attrib(iq, "id", iq_id);
pubsub = xmlnode_new("pubsub");
xmlnode_set_attrib(pubsub, "xmlns", "http://jabber.org/protocol/pubsub");
publish = xmlnode_new("publish");
xmlnode_set_attrib(publish,"node","http://jabber.org/protocol/nick");
nicknode = xmlnode_new_child(xmlnode_new_child(publish, "item"), "nick");
xmlnode_set_namespace(nicknode, "http://jabber.org/protocol/nick");
xmlnode_insert_data(nicknode, name, -1);
xmlnode_insert_child(pubsub, publish);
xmlnode_insert_child(iq, pubsub);
purple_signal_emit(purple_connection_get_prpl(gc),
"jabber-sending-xmlnode", gc, &iq);
g_free(iq_id);
}
else
/* provide dummy callback since some
protocols don't check before calling */
purple_account_set_public_alias(account, name, cb_dummy,
cb_set_alias_failure);
}
/* set display name for all connected accounts */
void set_display_name_all(const char *name)
{
GList *accts = purple_accounts_get_all_active();
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = accts->data;
if(!purple_account_is_connected(account))
continue;
set_display_name(account, name);
}
}
/* set status message (personal message) */
void set_status_message(const gchar *pm)
{
PurpleSavedStatus *status = purple_savedstatus_get_current();
purple_savedstatus_set_message(status, pm);
purple_savedstatus_activate(status);
}
void prpl_connect_signals(struct pbar_widget *w,
const struct pbar_prpl_signal *sig_list,
gpointer data)
{
const struct pbar_prpl_signal *s = sig_list;
for(; s->signal ; s++)
purple_signal_connect(s->instance,
s->signal,
w,
PURPLE_CALLBACK(s->callback),
data);
}
void prpl_prefs_connect_signals(struct pbar_widget *w,
const struct pbar_prpl_signal *sig_list,
gpointer data)
{
const struct pbar_prpl_signal *s = sig_list;
for(; s->signal ; s++)
purple_prefs_connect_callback(s->instance,
s->signal,
PURPLE_PREFS_CALLBACK(s->callback),
data);
}
void prpl_disconnect_signals(struct pbar_widget *w)
{ purple_signals_disconnect_by_handle(w); }
void prpl_prefs_disconnect_signals(struct pbar_widget *w)
{ purple_prefs_disconnect_by_handle(w); }
static void cb_global_moods_for_each(gpointer key, gpointer value,
gpointer user_data)
{
GList **out_moods = (GList **)user_data;
PurpleMood *mood = (PurpleMood *)value;
*out_moods = g_list_append(*out_moods, mood);
}
static void cb_set_alias_failure(PurpleAccount *account, const char *error)
{
const gchar *id = purple_account_get_protocol_id(account);
purple_debug_info(NAME, "aliases not supported by \"%s\"\n", id);
}
static void cb_dummy() {}
diff --git a/widget.c b/widget.c
index 4fdd82d..9584d67 100644
--- a/widget.c
+++ b/widget.c
@@ -1,534 +1,637 @@
/* File: widget.c
- Time-stamp: <2011-02-08 19:42:07 gawen>
+ Time-stamp: <2011-06-17 15:47:41 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "pbar.h"
#include "widget.h"
#include "widget_gtk.h"
#include "widget_prpl.h"
#include "preferences.h"
#include "purple.h"
#include "gtk.h"
/* we only have one widget per plugin
but this might change in the future */
struct widget *bar;
void create_widget()
{
/* this should occurs only once but
- this way way we avoid memory leaks */
+ this way we avoid memory leaks */
if(!bar)
bar = g_malloc(sizeof(struct widget));
memset(bar, 0, sizeof(struct widget));
/* widgets that can possibly be modified along plugin's execution */
bar->icon = gtk_image_new();
bar->status = gtk_button_new_from_stock(NULL);
bar->mood = gtk_button_new_from_stock(NULL);
bar->name_label = gtk_label_new(NULL);
bar->name_eventbox = gtk_event_box_new();
bar->name_entry = gtk_entry_new();
bar->pm_label = gtk_label_new(NULL);
bar->pm_eventbox = gtk_event_box_new();
bar->pm_entry = gtk_entry_new();
bar->hbox = gtk_hbox_new(FALSE, 2);
bar->icon_eventbox = gtk_event_box_new();
bar->status_menu = gtk_menu_new();
bar->mood_menu = gtk_menu_new();
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(bar), bar->hbox);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->status_menu);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->mood_menu);
/* widgets that are not modified */
GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
GtkWidget *hbox1 = gtk_hbox_new(FALSE, 2);
GtkWidget *hbox2 = gtk_hbox_new(FALSE, 2);
/* setup widgets */
gtk_label_set_ellipsize(GTK_LABEL(bar->name_label), PANGO_ELLIPSIZE_END);
gtk_label_set_ellipsize(GTK_LABEL(bar->pm_label), PANGO_ELLIPSIZE_END);
gtk_label_set_max_width_chars(GTK_LABEL(bar->name_label), 50);
gtk_button_set_relief(GTK_BUTTON(bar->status), GTK_RELIEF_NONE);
gtk_button_set_relief(GTK_BUTTON(bar->mood), GTK_RELIEF_NONE);
gtk_widget_set_can_focus(bar->name_eventbox, FALSE);
gtk_widget_set_can_focus(bar->pm_eventbox, FALSE);
gtk_widget_set_can_focus(bar->status, FALSE);
gtk_widget_set_can_focus(bar->mood, FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->icon_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->name_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->pm_eventbox), FALSE);
/* pack widgets */
gtk_container_add(GTK_CONTAINER(bar->name_eventbox), bar->name_label);
gtk_container_add(GTK_CONTAINER(bar->pm_eventbox), bar->pm_label);
gtk_container_add(GTK_CONTAINER(bar->icon_eventbox), bar->icon);
if(purple_prefs_get_bool(PREF "/compact")) {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
}
else {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0);
}
gtk_box_pack_start(GTK_BOX(bar->hbox), bar->icon_eventbox, FALSE, FALSE, 5);
gtk_box_pack_start(GTK_BOX(bar->hbox), vbox, TRUE, TRUE, 0);
/* pack at top of the buddy list and fallback to top
if the position option is unknown */
void (*gtk_box_pack)(GtkBox *, GtkWidget *, gboolean, gboolean, guint) = gtk_box_pack_start;
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
switch(purple_prefs_get_int(PREF "/widget-position")) {
case(POSITION_TOP):
gtk_box_pack = gtk_box_pack_start;
break;
case(POSITION_BOTTOM):
gtk_box_pack = gtk_box_pack_end;
break;
};
gtk_box_pack(GTK_BOX(blist->vbox), bar->hbox, FALSE, TRUE, 2);
gtk_box_reorder_child(GTK_BOX(blist->vbox), bar->hbox, 0);
/* setup initial states */
bar->gtk_hnd = NULL;
bar->gtk_inst = NULL;
bar->hover_name = FALSE;
bar->hover_pm = FALSE;
bar->name_entry_activated = FALSE;
bar->pm_entry_activated = FALSE;
bar->name_dialog = FALSE;
bar->pm_dialog = FALSE;
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ bar->icon_eventbox, "button-press-event", cb_buddy_icon },
{ bar->icon_eventbox, "enter-notify-event", cb_buddy_icon_enter },
{ bar->icon_eventbox, "leave-notify-event", cb_buddy_icon_leave },
{ bar->name_eventbox, "button-press-event", cb_name },
{ bar->name_eventbox, "enter-notify-event", cb_name_enter },
{ bar->name_eventbox, "leave-notify-event", cb_name_leave },
{ bar->name_entry, "activate", cb_name_entry },
{ bar->name_entry, "focus-out-event", cb_name_entry_focus_out },
{ bar->pm_eventbox, "button-press-event", cb_pm },
{ bar->pm_eventbox, "enter-notify-event", cb_pm_enter },
{ bar->pm_eventbox, "leave-notify-event", cb_pm_leave },
{ bar->pm_entry, "activate", cb_pm_entry },
{ bar->pm_entry, "focus-out-event", cb_pm_entry_focus_out },
{ bar->status, "clicked", cb_status_button },
{ bar->mood, "clicked", cb_mood_button },
{ NULL, NULL, NULL }
};
/* purple signals and callback */
const struct pbar_prpl_signal p_signal_connections[] = {
{ purple_accounts_get_handle(), "account-status-changed", cb_status },
{ purple_connections_get_handle(), "signed-on", cb_signed_on },
+ { purple_connections_get_handle(), "signed-off", cb_signed_off },
{ NULL, NULL, NULL }
};
/* purple preferences signals and callback */
const struct pbar_prpl_signal pp_signal_connections[] = {
{ bar, PIDGIN_PREFS_ROOT "/accounts/buddyicon", cb_buddy_icon_update },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(bar), g_signal_connections, NULL);
prpl_connect_signals(PBAR_WIDGET(bar), p_signal_connections, NULL);
prpl_prefs_connect_signals(PBAR_WIDGET(bar), pp_signal_connections, NULL);
/* show everything */
gtk_widget_show_all(bar->hbox);
gtk_widget_hide(bar->name_entry);
gtk_widget_hide(bar->pm_entry);
/* inform that the bar is installed */
+ widget_set_all_sensitive(FALSE);
bar->installed = TRUE;
}
void destroy_widget()
{
g_return_if_fail(bar->installed);
bar->installed = FALSE;
/* disconnect purple and prefs signals */
prpl_disconnect_signals(PBAR_WIDGET(bar));
prpl_prefs_disconnect_signals(PBAR_WIDGET(bar));
gtk_destroy(PBAR_WIDGET(bar)); /* destroy widgets */
g_free(bar); /* free widget */
bar = NULL;
}
/* load preferences into our widget */
void init_widget()
{
g_return_if_fail(bar->installed);
/* entry frame */
gboolean state = purple_prefs_get_bool(PREF "/frame-entry");
set_widget_entry_frame(state);
/* nickname */
const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup");
const gchar *value = purple_prefs_get_string(PREF "/nickname");
int jtype = purple_prefs_get_int(PREF "/nickname-justify");
set_widget_name(markup, value);
set_widget_name_justify(jtype);
/* personal message */
markup = purple_prefs_get_string(PREF "/personal-message-markup");
value = purple_prefs_get_string(PREF "/personal-message");
jtype = purple_prefs_get_int(PREF "/personal-message-justify");
set_widget_pm(markup, value);
set_widget_pm_justify(jtype);
/* buddy icon */
GdkPixbuf *icon = get_buddy_icon();
set_widget_icon(icon);
/* mood image */
const gchar *current_mood = purple_prefs_get_string(PREF "/mood");
gchar *path = get_mood_icon_path(current_mood);
set_widget_mood(path);
g_free(path);
/* status image */
const gchar *stock = get_status_stock_id();
set_widget_status(stock);
/* fill status menu */
GList *accts = purple_accounts_get_all_active();
GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = (PurpleAccount *)accts->data;
GList *types = purple_account_get_status_types(account);
for(; types ; types = types->next) {
PurpleStatusType *type = (PurpleStatusType *)types->data;
PurpleStatusPrimitive prim;
const gchar *stock, *status_name;
GtkWidget *menu_item, *icon;
if(!purple_status_type_is_user_settable(type) ||
purple_status_type_is_independent(type))
continue;
prim = purple_status_type_get_primitive(type);
stock = pidgin_stock_id_from_status_primitive(prim);
if(g_hash_table_lookup(global_status, stock))
continue;
else
g_hash_table_insert(global_status, (gpointer)stock,
GINT_TO_POINTER(TRUE));
status_name = purple_status_type_get_name(type);
menu_item = gtk_image_menu_item_new_with_label(status_name);
icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), icon);
gtk_menu_shell_append(GTK_MENU_SHELL(bar->status_menu), menu_item);
g_signal_connect_swapped(menu_item, "activate",
G_CALLBACK(cb_status_menu),
(gpointer)type);
gtk_widget_show(menu_item);
}
}
g_hash_table_destroy(global_status);
/* statusbox hiding */
state = purple_prefs_get_bool(PREF "/hide-statusbox");
set_statusbox_visible(!state);
}
/* create a change name dialog */
void create_name_dialog()
{
const gchar *name = purple_prefs_get_string(PREF "/nickname");
if(!name || !strcmp(name, EMPTY_NAME))
name = "";
purple_request_input(thisplugin,
_("Change nickname"),
_("Enter your nickname here..."),
_("This will change your nickname "
"for every account which supports it."),
name,
FALSE,
FALSE,
NULL,
_("OK"),
G_CALLBACK(cb_name_apply),
_("Cancel"),
G_CALLBACK(cb_name_cancel),
NULL,
NULL,
NULL,
NULL);
bar->name_dialog = TRUE;
}
+/* disable every features of the widget */
+void widget_set_all_sensitive(gboolean sensitive)
+{
+ GtkWidget *widgets[] = {
+ bar->icon,
+ bar->icon_eventbox,
+ bar->status,
+ bar->status_menu,
+ bar->mood,
+ bar->mood_menu,
+ bar->name_label,
+ bar->name_eventbox,
+ bar->name_entry,
+ bar->pm_label,
+ bar->pm_eventbox,
+ bar->pm_entry,
+ NULL
+ }; GtkWidget **w = widgets;
+
+ gboolean *attrs[] = {
+ &bar->mood_message,
+ &bar->current_song,
+ &bar->song_title,
+ &bar->song_album,
+ &bar->game_name,
+ &bar->office_app,
+ NULL
+ }; gboolean **a = attrs;
+
+ for(; *w ; w++)
+ gtk_widget_set_sensitive(*w, sensitive);
+ for(; *a ; a++)
+ **a = sensitive;
+}
+
+/* enable/disable features when an account changes */
+void account_changes(PurpleConnection *gc, gboolean enable)
+{
+ int inc = 1;
+ PurpleAccount *acct = purple_connection_get_account(gc);
+ PurplePlugin *plugin = purple_find_prpl(acct->protocol_id);
+ PurplePluginProtocolInfo *protocol = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
+ GHashTable *attrs = get_account_attrs(acct);
+
+ if(!enable)
+ inc = -1;
+
+ /* update references */
+ if(g_hash_table_lookup(attrs, "mood"))
+ bar->mood_ref += inc;
+ if(g_hash_table_lookup(attrs, "moodtext"))
+ bar->mood_message_ref += inc;
+ if(g_hash_table_lookup(attrs, "game"))
+ bar->game_name_ref += inc;
+ if(g_hash_table_lookup(attrs, "office"))
+ bar->office_app_ref += inc;
+ if(g_hash_table_lookup(attrs, "tune_title") &&
+ g_hash_table_lookup(attrs, "tune_artist") &&
+ g_hash_table_lookup(attrs, "tune_album"))
+ bar->current_song_ref += inc;
+ if(protocol->set_status)
+ bar->pm_ref += inc;
+ if(protocol->set_buddy_icon)
+ bar->icon_ref += inc;
+ if(!strcmp(acct->protocol_id, "prpl-jabber") || protocol->set_public_alias)
+ bar->name_ref += inc;
+ bar->status_ref += inc;
+
+ /* update widgets sensitive */
+ gtk_widget_set_sensitive(bar->icon, bar->icon_ref);
+ gtk_widget_set_sensitive(bar->icon_eventbox, bar->icon_ref);
+ gtk_widget_set_sensitive(bar->status, bar->status_ref);
+ gtk_widget_set_sensitive(bar->status_menu, bar->status_ref);
+ gtk_widget_set_sensitive(bar->mood, bar->mood_ref);
+ gtk_widget_set_sensitive(bar->mood_menu, bar->mood_ref);
+ gtk_widget_set_sensitive(bar->name_label, bar->name_ref);
+ gtk_widget_set_sensitive(bar->name_eventbox, bar->name_ref);
+ gtk_widget_set_sensitive(bar->name_entry, bar->name_ref);
+ gtk_widget_set_sensitive(bar->pm_label, bar->pm_ref + bar->mood_message_ref +\
+ bar->game_name_ref + bar->office_app_ref +\
+ bar->current_song_ref);
+ gtk_widget_set_sensitive(bar->pm_eventbox, bar->pm_ref +
+ bar->mood_message_ref + bar->game_name_ref +
+ bar->office_app_ref + bar->current_song_ref);
+ gtk_widget_set_sensitive(bar->pm_entry, bar->pm_ref +
+ bar->mood_message_ref + bar->game_name_ref +
+ bar->office_app_ref + bar->current_song_ref);
+ bar->pm_message = bar->pm_ref;
+ bar->mood_message = bar->mood_message_ref;
+ bar->current_song = bar->current_song_ref;
+ bar->song_title = bar->current_song_ref;
+ bar->song_album = bar->current_song_ref;
+ bar->game_name = bar->game_name;
+ bar->office_app = bar->office_app;
+}
+
/* create a personal message dialog */
void create_pm_dialog()
{
PurpleRequestFields *fields;
PurpleRequestFieldGroup *group;
PurpleRequestField *field;
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
if(!pm || !strcmp(pm, EMPTY_PM))
pm = "";
const struct s_field {
const gchar *text;
const gchar *pref;
+ gboolean enable;
} groups[] = {
- { N_("_Mood message"), PREF "/mood-message" },
- { N_("Current song"), NULL },
- { N_("Song _title"), PREF "/tune-title" },
- { N_("Song _artist"), PREF "/tune-artist" },
- { N_("Song al_bum"), PREF "/tune-album" },
- { N_("MSN pecan extra attributes"), NULL },
- { N_("_Game name"), PREF "/game-message" },
- { N_("_Office app name"), PREF "/office-message" },
+ { N_("_Mood message"), PREF "/mood-message", bar->mood_message },
+ { N_("Current song"), NULL, bar->current_song },
+ { N_("Song _title"), PREF "/tune-title", bar->current_song },
+ { N_("Song _artist"), PREF "/tune-artist", bar->song_title },
+ { N_("Song al_bum"), PREF "/tune-album", bar->song_album },
+ { N_("MSN pecan extra attributes"), NULL, bar->game_name && bar->office_app },
+ { N_("_Game name"), PREF "/game-message", bar->game_name },
+ { N_("_Office app name"), PREF "/office-message", bar->office_app },
{ NULL, NULL },
{ NULL, NULL }
}; const struct s_field *g = groups;
fields = purple_request_fields_new();
group = purple_request_field_group_new(_("Status and mood message"));
purple_request_fields_add_group(fields, group);
- field = purple_request_field_string_new(PREF "/personal-message",
- _("_Personal message"),
- pm,
- FALSE);
- purple_request_field_set_required(field, FALSE);
- purple_request_field_group_add_field(group, field);
+ if(bar->pm_message) {
+ field = purple_request_field_string_new(PREF "/personal-message",
+ _("_Personal message"),
+ pm,
+ FALSE);
+ purple_request_field_set_required(field, FALSE);
+ purple_request_field_group_add_field(group, field);
+ }
for(; g->pref ; g++) {
for(; g->pref ; g++) {
const gchar *message;
- if(purple_prefs_get_bool(PREF "/reset-attrs"))
+ if(!g->enable)
+ continue;
+ else if(purple_prefs_get_bool(PREF "/reset-attrs"))
message = "";
else
message = purple_prefs_get_string(g->pref);
field = purple_request_field_string_new(g->pref,
_(g->text),
message,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
- group = purple_request_field_group_new(_(g->text));
- purple_request_fields_add_group(fields, group);
+ if(g->enable) {
+ group = purple_request_field_group_new(_(g->text));
+ purple_request_fields_add_group(fields, group);
+ }
}
purple_request_fields(thisplugin,
_("Change status messages"),
_("Enter status message..."),
_("This will change some status messages for every "
"account which supports it, please be advised "
"that some are inconsistent between each other."),
fields,
_("OK"),
G_CALLBACK(cb_pm_apply),
_("Cancel"),
G_CALLBACK(cb_pm_cancel),
NULL, NULL, NULL, NULL);
bar->pm_dialog = TRUE;
}
-
/* replace format character <c><r> with <n> string and escape with <c><c> */
static gchar * g_strreplacefmt(const gchar *s, gchar c, gchar r, const gchar *n)
{
int sn = strlen(n);
int sr = strlen(s);
int index = 0;
gchar *ret = g_malloc(sr);
for(; *s != '\0' ; s++) {
if(*s == c) {
s++;
if(*s == r) {
const gchar *i = n;
sr += sn;
ret = g_realloc(ret, sr);
for(; *i != '\0' ; i++, index++)
ret[index] = *i;
continue;
}
else if(*s != c || *s == '\0')
s--;
}
ret[index] = *s;
index++;
}
ret[index] = '\0';
return ret;
}
-
void set_widget_name(const gchar *markup, const gchar *name)
{
g_return_if_fail(markup && name && bar->installed);
gchar *escaped_name, *new;
/* translate name if needed */
if(!strcmp(name, EMPTY_NAME))
name = _(EMPTY_NAME);
escaped_name = g_markup_printf_escaped("%s", name);
new = g_strreplacefmt(markup, '%', 'n', escaped_name);
g_free(escaped_name);
gtk_label_set_markup(GTK_LABEL(bar->name_label), new);
g_free(new);
}
void set_widget_pm(const gchar *markup, const gchar *pm)
{
g_return_if_fail(markup && pm && bar->installed);
gchar *escaped_pm, *new;
/* translate pm if needed */
if(!strcmp(pm, EMPTY_PM))
pm = _(EMPTY_PM);
escaped_pm = g_markup_printf_escaped("%s", pm);
new = g_strreplacefmt(markup, '%', 'p', escaped_pm);
g_free(escaped_pm);
gtk_label_set_markup(GTK_LABEL(bar->pm_label), new);
g_free(new);
}
void set_widget_status(const gchar *stock)
{
g_return_if_fail(stock && bar->installed);
GtkWidget *icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_button_set_image(GTK_BUTTON(bar->status), icon);
gtk_button_set_label(GTK_BUTTON(bar->status), "");
}
void set_widget_mood(const gchar *path)
{
g_return_if_fail(path && bar->installed);
GtkWidget *mood = gtk_image_new_from_file(path);
gtk_button_set_image(GTK_BUTTON(bar->mood), mood);
gtk_button_set_label(GTK_BUTTON(bar->mood), "");
}
void set_widget_icon(GdkPixbuf *icon)
{
g_return_if_fail(bar->installed);
if(icon)
gtk_image_set_from_pixbuf(GTK_IMAGE(bar->icon), icon);
else
gtk_image_set_from_stock(GTK_IMAGE(bar->icon), GTK_STOCK_MISSING_IMAGE, 48);
}
/* convertion of int justification
to float justification for
gtk_misc_set_alignment */
static float int_jtype_to_float_jtype(int justify)
{
float ret = 0.; /* default to left */
switch(justify) {
case(JUSTIFY_LEFT):
ret = 0.;
break;
case(JUSTIFY_CENTER):
ret = .5;
break;
case(JUSTIFY_RIGHT):
ret = 1.;
break;
}
return ret;
}
void set_widget_name_justify(int justify)
{
g_return_if_fail(bar->installed);
float jtype = int_jtype_to_float_jtype(justify);
gtk_misc_set_alignment(GTK_MISC(bar->name_label), jtype, .5);
}
void set_widget_pm_justify(int justify)
{
g_return_if_fail(bar->installed);
float jtype = int_jtype_to_float_jtype(justify);
gtk_misc_set_alignment(GTK_MISC(bar->pm_label), jtype, .5);
}
void set_widget_entry_frame(gboolean use_frame)
{
g_return_if_fail(bar->installed);
gtk_entry_set_has_frame(GTK_ENTRY(bar->name_entry), use_frame);
gtk_entry_set_has_frame(GTK_ENTRY(bar->pm_entry), use_frame);
}
void set_statusbox_visible(gboolean visible)
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
GtkWidget *statusbox = blist->statusbox;
if(statusbox)
gtk_widget_set_visible(statusbox, visible);
}
gboolean get_widget_name_hover_state() { return bar->hover_name; }
gboolean get_widget_pm_hover_state() { return bar->hover_pm; }
diff --git a/widget.h b/widget.h
index 8e6f627..1eac766 100644
--- a/widget.h
+++ b/widget.h
@@ -1,86 +1,110 @@
/* File: widget.h
- Time-stamp: <2011-02-08 19:39:51 gawen>
+ Time-stamp: <2011-06-17 15:32:27 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _WIDGET_H_
#define _WIDGET_H_
#include "common.h"
#include "gtk.h"
struct widget {
BEGIN_PBAR_WIDGET;
/* icon and status */
GtkWidget *icon;
GtkWidget *icon_eventbox;
GtkWidget *status;
GtkWidget *status_menu;
/* mood */
GtkWidget *mood;
GtkWidget *mood_menu;
/* nickname */
GtkWidget *name_label;
GtkWidget *name_eventbox;
GtkWidget *name_entry;
/* personal message */
GtkWidget *pm_label;
GtkWidget *pm_eventbox;
GtkWidget *pm_entry;
GtkWidget *hbox; /* contains the widget */
gboolean installed; /* widget installed or not */
gboolean hover_name; /* name hovered or not */
gboolean hover_pm; /* pm hovered or not */
/* avoid setting status and name twice
with focus-out-event */
gboolean name_entry_activated;
gboolean pm_entry_activated;
/* avoid activating entry with dialog */
gboolean name_dialog;
gboolean pm_dialog;
+
+ /* attributes state for
+ attributes dialogs */
+ gboolean mood_message;
+ gboolean current_song;
+ gboolean song_title;
+ gboolean song_album;
+ gboolean game_name;
+ gboolean office_app;
+ gboolean pm_message;
+
+ /* references */
+ unsigned int icon_ref;
+ unsigned int status_ref;
+ unsigned int mood_ref;
+ unsigned int name_ref;
+ unsigned int pm_ref;
+ unsigned int mood_message_ref;
+ unsigned int current_song_ref;
+ unsigned int song_title_ref;
+ unsigned int game_name_ref;
+ unsigned int office_app_ref;
};
extern struct widget *bar;
void create_widget();
void destroy_widget();
void init_widget();
void create_name_dialog();
void create_pm_dialog();
+void account_changes(PurpleConnection *gc, gboolean enable);
+void widget_set_all_sensitive(gboolean sensitive);
void set_widget_name(const gchar *markup, const gchar *name);
void set_widget_pm(const gchar *markup, const gchar *pm);
void set_widget_status(const gchar *stock);
void set_widget_mood(const gchar *path);
void set_widget_icon(GdkPixbuf *icon);
void set_widget_name_justify(int justify);
void set_widget_pm_justify(int justify);
void set_widget_entry_frame(gboolean use_frame);
void set_statusbox_visible(gboolean visible);
gboolean get_widget_name_hover_state();
gboolean get_widget_pm_hover_state();
#endif /* _WIDGET_H_ */
diff --git a/widget_prpl.c b/widget_prpl.c
index 6d9ea25..0cf5803 100644
--- a/widget_prpl.c
+++ b/widget_prpl.c
@@ -1,229 +1,233 @@
/* File: widget_prpl.c
- Time-stamp: <2010-11-15 18:03:20 gawen>
+ Time-stamp: <2011-06-17 14:42:59 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "preferences.h"
#include "widget.h"
#include "widget_prpl.h"
#include "purple.h"
void cb_status(PurpleAccount *account, PurpleStatus *old, PurpleStatus *new)
{
g_return_if_fail(bar->installed);
PurpleStatusPrimitive prim;
const gchar *stock, *pm;
PurpleSavedStatus *status = purple_savedstatus_get_current();
if(purple_prefs_get_bool(PREF "/override-status")) {
pm = purple_prefs_get_string(PREF "/personal-message");
purple_savedstatus_set_message(status,pm);
purple_savedstatus_activate(status);
}
else {
const gchar *markup;
markup = purple_prefs_get_string(PREF "/personal-message-markup");
pm = purple_savedstatus_get_message(status);
if(!pm)
pm = "";
set_widget_pm(markup, pm);
purple_prefs_set_string(PREF "/personal-message", pm);
}
prim = purple_savedstatus_get_type(status);
stock = pidgin_stock_id_from_status_primitive(prim);
set_widget_status(stock);
}
+void cb_signed_off(PurpleConnection *gc)
+{ account_changes(gc, FALSE); }
+
void cb_signed_on(PurpleConnection *gc)
{
const gchar *name = purple_prefs_get_string(PREF "/nickname");
PurpleAccount *account = purple_connection_get_account(gc);
set_display_name(account, name);
+ account_changes(gc, TRUE);
purple_debug_info(NAME, "nickname changed to \"%s\" by signed-on account\n",
name);
if(gc && gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS) {
const gchar *mood = purple_prefs_get_string(PREF "/mood");
set_status_with_mood(account, mood);
purple_debug_info(NAME, "mood changed to \"%s\" by signed-on account\n",
mood);
}
/* load tune and stuff */
GList *a_tune = NULL;
GList *a_mood = NULL;
const struct attrs {
const gchar *pref;
const gchar *attr;
GList **list;
} attrs[] = {
{ PREF "/mood-message", PURPLE_MOOD_COMMENT, &a_mood },
{ PREF "/tune-title", PURPLE_TUNE_TITLE, &a_tune },
{ PREF "/tune-artist", PURPLE_TUNE_ARTIST, &a_tune },
{ PREF "/tune-album", PURPLE_TUNE_ALBUM, &a_tune },
{ PREF "/game-message", "game", &a_tune },
{ PREF "/office-message", "office", &a_tune },
{ NULL, NULL, NULL }
}; const register struct attrs *a = attrs;
for(; a->pref ; a++) {
const gchar *value;
if(purple_prefs_get_bool(PREF "/reset-attrs"))
value = NULL;
else
value = purple_prefs_get_string(a->pref);
if(value && !strcmp(value, ""))
value = NULL;
else
purple_debug_info(NAME, "%s message changed to \"%s\" by signed-on account\n",
a->attr, value);
*(a->list) = g_list_append(*(a->list), (gpointer)a->attr);
*(a->list) = g_list_append(*(a->list), (gpointer)value);
}
const struct status_list {
const gchar *status_id;
GList *list;
gboolean cont;
} status[] = {
{ "tune", a_tune, TRUE },
{ "mood", a_mood, TRUE },
{ NULL, NULL, FALSE}
}; register const struct status_list *s = status;
for(; s->cont ; s++) {
purple_account_set_status_list(account, s->status_id, TRUE, s->list);
g_list_free(s->list);
}
}
void cb_buddy_icon_update(const char *name, PurplePrefType type,
gconstpointer val, gpointer data)
{
g_return_if_fail(bar->installed);
GdkPixbuf *icon;
icon = get_buddy_icon();
set_widget_icon(icon);
}
void cb_name_apply(PurpleAccount *account, const char *user_info)
{
g_return_if_fail(bar->installed);
const gchar *markup, *name;
name = user_info;
markup = purple_prefs_get_string(PREF "/nickname-markup");
set_widget_name(markup, name);
purple_prefs_set_string(PREF "/nickname", name);
set_display_name_all(name);
bar->name_dialog = FALSE;
purple_debug_info(NAME, "nickname changed to \"%s\" by user\n", name);
}
void cb_name_cancel(PurpleAccount *account, const char *user_info)
{
g_return_if_fail(bar->installed);
bar->name_dialog = FALSE;
}
void cb_pm_apply(gpointer data, PurpleRequestFields *fields)
{
g_return_if_fail(bar->installed);
/* attrs */
GList *a_tune = NULL;
GList *a_mood = NULL;
/* just to update widget */
const gchar *pm = purple_request_fields_get_string(fields, PREF "/personal-message");
const gchar *markup = purple_prefs_get_string(PREF "/personal-message-markup");
set_status_message(pm);
set_widget_pm(markup, pm);
purple_debug_info(NAME, "personal message changed to \"%s\" by user\n", pm);
const struct r_field {
const gchar *id;
const gchar *attr;
GList **list;
} r_fields[] = {
{ PREF "/mood-message", PURPLE_MOOD_COMMENT, &a_mood },
{ PREF "/tune-title", PURPLE_TUNE_TITLE, &a_tune },
{ PREF "/tune-artist", PURPLE_TUNE_ARTIST, &a_tune },
{ PREF "/tune-album", PURPLE_TUNE_ALBUM, &a_tune },
{ PREF "/game-message", "game", &a_tune },
{ PREF "/office-message", "office", &a_tune },
{ NULL, NULL, NULL }
}; const register struct r_field *rf = r_fields;
for(; rf->id ; rf++) {
const gchar *value = purple_request_fields_get_string(fields, rf->id);
if(!purple_prefs_get_bool(PREF "/reset-attrs"))
purple_prefs_set_string(rf->id, value);
if(value && !strcmp(value, ""))
value = NULL;
else
purple_debug_info(NAME, "%s message changed to \"%s\" by user\n",
rf->attr, value);
*(rf->list) = g_list_append(*(rf->list), (gpointer)rf->attr);
*(rf->list) = g_list_append(*(rf->list), (gpointer)value);
}
const struct status_list {
const gchar *status_id;
GList *list;
gboolean cont;
} status[] = {
{ "tune", a_tune, TRUE },
{ "mood", a_mood, TRUE },
{ NULL, NULL, FALSE}
}; register const struct status_list *s = status;
for(; s->cont ; s++) {
set_status_all(s->status_id, s->list);
g_list_free(s->list);
}
bar->pm_dialog = FALSE;
}
void cb_pm_cancel(gpointer data, PurpleRequestFields *fields)
{
g_return_if_fail(bar->installed);
bar->pm_dialog = FALSE;
}
diff --git a/widget_prpl.h b/widget_prpl.h
index a25fade..ebec6ed 100644
--- a/widget_prpl.h
+++ b/widget_prpl.h
@@ -1,35 +1,36 @@
/* File: widget_prpl.h
- Time-stamp: <2010-11-08 18:51:46 gawen>
+ Time-stamp: <2011-06-17 13:40:18 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _WIDGET_PRPL_H_
#define _WIDGET_PRPL_H_
#include "common.h"
void cb_name_apply(PurpleAccount *account, const char *user_info);
void cb_name_cancel(PurpleAccount *account, const char *user_info);
void cb_pm_apply(gpointer data, PurpleRequestFields *fields);
void cb_pm_cancel(gpointer data, PurpleRequestFields *fields);
void cb_status(PurpleAccount *account, PurpleStatus *old, PurpleStatus *new);
void cb_signed_on(PurpleConnection *gc);
+void cb_signed_off(PurpleConnection *gc);
void cb_buddy_icon_update(const char *name, PurplePrefType type,
gconstpointer val, gpointer data);
#endif /* _WIDGET_PRPL_H_ */
|
gawen947/pidgin-pbar
|
f5fbbe7158df8babd256a1430f4681b585460166
|
Add tooltip to preferences
|
diff --git a/preferences.c b/preferences.c
index 0e5f30c..7840e61 100644
--- a/preferences.c
+++ b/preferences.c
@@ -1,376 +1,427 @@
/* File: prefs.c
- Time-stamp: <2011-04-02 16:25:35 gawen>
+ Time-stamp: <2011-06-17 05:03:03 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "preferences.h"
#include "widget.h"
/* callback for preferences setting which set preferences and
update interface when needed */
static void cb_nickname_markup(GtkWidget *widget, gpointer data);
static void cb_nickname_markup_hover(GtkWidget *widget, gpointer data);
static void cb_personal_message_markup(GtkWidget *widget, gpointer data);
static void cb_personal_message_markup_hover(GtkWidget *widget, gpointer data);
static void cb_hide_statusbox(GtkWidget *widget, gpointer data);
static void cb_override_status(GtkWidget *widget, gpointer data);
static void cb_nickname_justify(GtkWidget *widget, gpointer data);
static void cb_personal_message_justify(GtkWidget *widget, gpointer data);
static void cb_compact(GtkWidget *widget, gpointer data);
static void cb_frame_entry(GtkWidget *widget, gpointer data);
static void cb_swap_click(GtkWidget *widget, gpointer data);
static void cb_reset_attrs(GtkWidget *widget, gpointer data);
static void cb_widget_position(GtkWidget *widget, gpointer data);
/* the following structures are defined here as global
since they are needed in combobox callback */
/* alias we will use for combobox */
static const struct i_alias {
const char *alias;
int value;
} alias_justify[] = {
{ N_("Left"), JUSTIFY_LEFT },
{ N_("Center"), JUSTIFY_CENTER },
{ N_("Right"), JUSTIFY_RIGHT },
{ NULL, 0 }
};
/* widget position in the buddy list */
static const struct i_alias alias_position[] = {
{ N_("Top"), POSITION_TOP },
{ N_("Bottom"), POSITION_BOTTOM },
{ NULL, 0 }
};
/* init preferences and set default values */
void init_prefs()
{
/* string preferences and default value */
const struct prefs_string {
const char *name;
const char *value;
} prefs_add_string[] = {
{ PREF "/personal-message-markup-hover", "<span color=\"DarkOliveGreen4\"><small><i>%p</i></small></span>" },
{ PREF "/personal-message-markup", "<small>%p</small>" },
{ PREF "/nickname-markup-hover", "<span color=\"DarkOliveGreen4\"><b>%n</b></span>" },
{ PREF "/nickname-markup", "<b>%n</b>" },
{ PREF "/personal-message", EMPTY_PM },
{ PREF "/tune-title", "" },
{ PREF "/tune-artist", "" },
{ PREF "/tune-album", "" },
{ PREF "/game-message", "" },
{ PREF "/office-message", "" },
{ PREF "/nickname", EMPTY_NAME },
{ PREF "/mood-message", "" },
{ PREF "/mood", "" },
{ NULL, NULL }
}; const struct prefs_string *s = prefs_add_string;
/* boolean preferences and default value */
const struct prefs_bool {
const char *name;
gboolean value;
} prefs_add_bool[] = {
{ PREF "/hide-statusbox", TRUE },
{ PREF "/override-status", FALSE },
{ PREF "/frame-entry", TRUE },
{ PREF "/swap-click", FALSE },
{ PREF "/reset-attrs", FALSE },
{ PREF "/compact", FALSE },
{ NULL, FALSE }
}; const struct prefs_bool *b = prefs_add_bool;
/* integer preferences and default value */
const struct prefs_int {
const char *name;
int value;
} prefs_add_int[] = {
{ PREF "/nickname-justify", JUSTIFY_LEFT },
{ PREF "/personal-message-justify", JUSTIFY_LEFT },
{ PREF "/widget-position", POSITION_TOP },
{ NULL, 0 }
}; const struct prefs_int *i = prefs_add_int;
/* add preferences */
purple_prefs_add_none(PREF);
for(; s->name ; s++)
purple_prefs_add_string(s->name, s->value);
for(; b->name ; b++)
purple_prefs_add_bool(b->name, b->value);
for(; i->name ; i++)
purple_prefs_add_int(i->name, i->value);
}
GtkWidget * get_config_frame(PurplePlugin *plugin)
{
/* entry widgets label, associated preference and callback */
const struct widget {
const char *name;
const char *prefs;
void (*callback)(GtkWidget *, gpointer);
+ const char *tooltip;
} entry[] = {
- { N_("_Nickname markup"), PREF "/nickname-markup", cb_nickname_markup },
- { N_("Nickname markup _hovered"), PREF "/nickname-markup-hover", cb_nickname_markup_hover },
- { N_("Personal _message markup"), PREF "/personal-message-markup", cb_personal_message_markup },
- { N_("Personal message markup _hovered"), PREF "/personal-message-markup-hover", cb_personal_message_markup_hover },
+ { N_("_Nickname markup"), PREF "/nickname-markup", cb_nickname_markup,
+ N_("Change the markup used to display the nickname using the "
+ "Pango Markup Language where %n is replaced with your nickname.") },
+
+ { N_("Nickname markup _hovered"), PREF "/nickname-markup-hover",
+ cb_nickname_markup_hover,
+ N_("Change the markup used to display the nickname when hovered "
+ "by the mouse using the Pango Text Attribute Markup Language "
+ "where %n is replaced with your nickname") },
+
+ { N_("Personal _message markup"), PREF "/personal-message-markup",
+ cb_personal_message_markup,
+ N_("Change the markup used to display the personal message using the "
+ "Pango Markup Language where %m is replaced with your personal "
+ "message.") },
+
+ { N_("Personal message markup _hovered"), PREF "/personal-message-markup-hover",
+ cb_personal_message_markup_hover,
+ N_("Change the markup used to display the personal message when hovered "
+ "by the mouse using the Pango Markup Language where %m is replaced "
+ "with your personal message.") },
+
{ NULL, NULL, NULL }
}; const struct widget *e = entry;
/* combobox widgets label, associated preference, alias and callback */
const struct i_widget {
const char *name;
const char *prefs;
const struct i_alias *alias;
void (*callback)(GtkWidget *, gpointer);
+ const char *tooltip;
} combobox[] = {
- { N_("Align _nickname"), PREF "/nickname-justify", alias_justify, cb_nickname_justify },
- { N_("Align personal _message"), PREF "/personal-message-justify", alias_justify, cb_personal_message_justify },
- { N_("Widget _position in the buddy list"), PREF "/widget-position", alias_position, cb_widget_position },
+ { N_("Align _nickname"), PREF "/nickname-justify", alias_justify,
+ cb_nickname_justify,
+ N_("Alignment of the nickname into the bar.") },
+
+ { N_("Align personal _message"), PREF "/personal-message-justify",
+ alias_justify, cb_personal_message_justify,
+ N_("Alignment of the personal message into the bar.") },
+
+ { N_("Widget _position in the buddy list"), PREF "/widget-position",
+ alias_position, cb_widget_position,
+ N_("Position of the widget into pidgin's buddy list.") },
+
{ NULL, NULL, NULL, NULL }
}; const struct i_widget *cbx = combobox;
/* check button widgets label, associated preference and callback */
const struct widget check_button[] = {
- { N_("Hide _statusbox"), PREF "/hide-statusbox", cb_hide_statusbox },
- { N_("_Ignore status changes"), PREF "/override-status", cb_override_status },
- { N_("Use a frame for _entry"), PREF "/frame-entry", cb_frame_entry },
- { N_("_Swap left and right click"), PREF "/swap-click", cb_swap_click },
- { N_("Use a _compact bar"), PREF "/compact", cb_compact },
- { N_("_Reset status messages"), PREF "/reset-attrs", cb_reset_attrs },
+ { N_("Hide _statusbox"), PREF "/hide-statusbox", cb_hide_statusbox,
+ N_("Show or hide the Pidgin's default statusbox.") },
+
+ { N_("_Ignore status changes"), PREF "/override-status", cb_override_status,
+ N_("Ignore changes made to status from outside the widget. "
+ "This include changes made in Pidgin's default statusbox "
+ "and other plugins.") },
+
+ { N_("Use a frame for _entry"), PREF "/frame-entry", cb_frame_entry,
+ N_("Enable or disable the use of a frame around the entries when "
+ "editing the nickname or personal message from the bar.") },
+
+ { N_("_Swap left and right click"), PREF "/swap-click", cb_swap_click,
+ N_("Swap the role of left and right click to edit the nickname or "
+ "personal message in the bar.") },
+
+ { N_("Use a _compact bar"), PREF "/compact", cb_compact,
+ N_("Reduce the size of the widget putting the nickname and personal "
+ "message on one line.") },
+
+ { N_("_Reset status messages"), PREF "/reset-attrs", cb_reset_attrs,
+ N_("Clear the status messages when Pidgin restart (except for personal "
+ "message). By default these messages are saved in the preferences and "
+ "reactivated when pidgin restart.") },
+
{ NULL, NULL, NULL }
}; const struct widget *cb = check_button;
/* create table */
GtkWidget *table = gtk_table_new(((sizeof(entry) - 2) +
sizeof(check_button) / 2 - 1) /
sizeof(struct widget),
2, FALSE);
/* load table and connect signals */
int x = 0, y = 0;
for(; e->name ; e++, y++) {
/* entry widgets */
GtkWidget *widget_label = gtk_label_new_with_mnemonic(_(e->name));
GtkWidget *widget_entry = gtk_entry_new();
const gchar *prefs_value = purple_prefs_get_string(e->prefs);
gtk_label_set_mnemonic_widget(GTK_LABEL(widget_label), widget_entry);
gtk_entry_set_text(GTK_ENTRY(widget_entry), prefs_value);
+ gtk_widget_set_tooltip_text(widget_entry, e->tooltip);
gtk_misc_set_alignment(GTK_MISC(widget_label), 0., .5);
gtk_table_attach(GTK_TABLE(table), widget_label, 0, 1, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
gtk_table_attach(GTK_TABLE(table), widget_entry, 1, 2, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
g_signal_connect(G_OBJECT(widget_entry), "activate", G_CALLBACK(e->callback),NULL);
g_signal_connect(G_OBJECT(widget_entry), "focus-out-event", G_CALLBACK(e->callback),NULL);
}
for(; cbx->name ; cbx++, y++) {
/* combobox widgets */
const struct i_alias *j;
GtkWidget *widget_label = gtk_label_new_with_mnemonic(_(cbx->name));
GtkWidget *widget_combo = gtk_combo_box_new_text();
int prefs_value = purple_prefs_get_int(cbx->prefs);
int i;
gtk_label_set_mnemonic_widget(GTK_LABEL(widget_label), widget_combo);
gtk_misc_set_alignment(GTK_MISC(widget_label), 0., .5);
+ gtk_widget_set_tooltip_text(widget_label, cbx->tooltip);
gtk_table_attach(GTK_TABLE(table), widget_label, 0, 1, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
gtk_table_attach(GTK_TABLE(table), widget_combo, 1, 2, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
for(i = 0, j = cbx->alias ; j->alias ; j++, i++) {
gtk_combo_box_append_text(GTK_COMBO_BOX(widget_combo), _(j->alias));
if(j->value == prefs_value)
gtk_combo_box_set_active(GTK_COMBO_BOX(widget_combo), i);
}
g_signal_connect(G_OBJECT(widget_combo), "changed", G_CALLBACK(cbx->callback), (gpointer)cbx->alias);
}
for(; cb->name ; cb++, x = (x + 1) % 2) {
/* check button widgets */
GtkWidget *widget_cb = gtk_check_button_new_with_mnemonic(_(cb->name));
gboolean prefs_value = purple_prefs_get_bool(cb->prefs);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget_cb), prefs_value);
+ gtk_widget_set_tooltip_text(widget_cb, cb->tooltip);
gtk_table_attach(GTK_TABLE(table), widget_cb, x, x+1, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
g_signal_connect(G_OBJECT(widget_cb), "toggled", G_CALLBACK(cb->callback),NULL);
if(x % 2)
y++;
}
return table; /* pidgin destroy this when closed */
}
static void cb_nickname_markup(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget));
purple_prefs_set_string(PREF "/nickname-markup", value);
if(!get_widget_name_hover_state()) {
const gchar *name = purple_prefs_get_string(PREF "/nickname");
set_widget_name(value, name);
}
purple_debug_info(NAME, "nickname markup changed\n");
}
static void cb_nickname_markup_hover(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget));
purple_prefs_set_string(PREF "/nickname-markup-hover", value);
if(get_widget_name_hover_state()) {
const gchar *name = purple_prefs_get_string(PREF "/nickname");
set_widget_name(value, name);
}
purple_debug_info(NAME, "nickname markup hover changed\n");
}
static void cb_personal_message_markup(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget));
purple_prefs_set_string(PREF "/personal-message-markup", value);
if(!get_widget_pm_hover_state()) {
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
set_widget_pm(value, pm);
}
purple_debug_info(NAME, "personal message markup hover changed\n");
}
static void cb_personal_message_markup_hover(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget));
purple_prefs_set_string(PREF "/personal-message-markup-hover", value);
if(get_widget_pm_hover_state()) {
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
set_widget_pm(value, pm);
}
purple_debug_info(NAME, "personal message markup hover changed\n");
}
static void cb_hide_statusbox(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/hide-statusbox", state);
set_statusbox_visible(!state);
purple_debug_info(NAME, "status box state changed\n");
}
static void cb_override_status(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/override-status", state);
purple_debug_info(NAME, "override status state changed\n");
}
static void cb_nickname_justify(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget));
const struct i_alias *j;
for(j = (struct i_alias *)data ; j->alias ; j++) {
if(!strcmp(value, _(j->alias))) {
purple_prefs_set_int(PREF "/nickname-justify", j->value);
set_widget_name_justify(j->value);
break;
}
}
purple_debug_info(NAME, "nickname justification changed\n");
}
static void cb_personal_message_justify(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget));
const struct i_alias *j;
for(j = (struct i_alias *)data ; j->alias ; j++) {
if(!strcmp(value, _(j->alias))) {
purple_prefs_set_int(PREF "/personal-message-justify", j->value);
set_widget_pm_justify(j->value);
break;
}
}
purple_debug_info(NAME, "personal message justification changed\n");
}
static void cb_compact(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/compact", state);
/* recreate bar since we need to repack everything */
destroy_widget();
create_widget();
init_widget();
purple_debug_info(NAME, "compact state changed\n");
}
static void cb_frame_entry(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/frame-entry", state);
set_widget_entry_frame(state);
purple_debug_info(NAME, "frame entry state changed\n");
}
static void cb_swap_click(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/swap-click", state);
purple_debug_info(NAME, "swap click state changed\n");
}
static void cb_reset_attrs(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/reset-attrs", state);
set_widget_entry_frame(state);
purple_debug_info(NAME, "reset attributes state changed\n");
}
static void cb_widget_position(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget));
const struct i_alias *j;
for(j = (struct i_alias *)data ; j->alias ; j++) {
if(!strcmp(value, _(j->alias))) {
purple_prefs_set_int(PREF "/widget-position", j->value);
/* recreate bar since we need to repack everything */
destroy_widget();
create_widget();
init_widget();
break;
}
}
purple_debug_info(NAME, "personal message justification changed\n");
}
|
gawen947/pidgin-pbar
|
9fb5d155be0b0c1f0632e048bfd93fb7379eb1de
|
Change web addr.
|
diff --git a/pbar.h b/pbar.h
index 34a9400..de63364 100644
--- a/pbar.h
+++ b/pbar.h
@@ -1,61 +1,61 @@
/* File: pbar.h
Time-stamp: <2010-11-15 23:55:36 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _PBAR_H_
#define _PBAR_H_
#include "common.h"
#ifndef G_GNUC_NULL_TERMINATED
# if __GNUC__ >= 4
# define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
# else
# define G_GNUC_NULL_TERMINATED
# endif /* __GNUC__ >= 4 */
#endif /* G_GNUC_NULL_TERMINATED */
/* name */
#define NAME "pbar" /* internal name */
#define DISP_NAME N_("PBar") /* displayed name */
#define VERSION "0.2-git" /* current version */
/* plugin information */
#define PLUGIN_ID "gtk-" NAME /* gtk plugin id */
#define PLUGIN_NAME DISP_NAME
#ifndef COMMIT
# define PLUGIN_VERSION VERSION
#else
# define PLUGIN_VERSION VERSION " (commit:" COMMIT ")" /* add git commit
when available */
#endif
#define PLUGIN_SUMMARY N_("A toolbar to update some account settings " \
"globally.")
#define PLUGIN_DESCRIPTION N_("Adds a toolbar to the buddy list to quickly " \
"update nickname, personal message, icon, " \
"status and mood. It also allows updating of " \
"the current song and other parameters which " \
"are updated globally on all accounts that " \
"support them.")
#define PLUGIN_AUTHOR "David Hauweele <[email protected]>"
-#define PLUGIN_WEBSITE "http://www.atlantysse.prout.be/~gawen/pidgin-pbar.html"
+#define PLUGIN_WEBSITE "http://www.hauweele.net/~gawen/pidgin-pbar.html"
extern PurplePlugin *thisplugin;
#endif /* _PBAR_H_ */
|
gawen947/pidgin-pbar
|
3da073e1d5883cf7f5dcc92b2408487941eff51f
|
Change mail addr.
|
diff --git a/ChangeLog b/ChangeLog
index d3c03dd..ac7963f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,2 +1,2 @@
-* Wed Jan 5 2010 David Hauweele <[email protected]>
+* Wed Jan 5 2010 David Hauweele <[email protected]>
- Release 0.1
diff --git a/acct_features.c b/acct_features.c
index 54a2028..242ecd4 100644
--- a/acct_features.c
+++ b/acct_features.c
@@ -1,281 +1,281 @@
/* File: acct_features.c
Time-stamp: <2011-02-11 01:41:03 gawen>
- Copyright (C) 2011 David Hauweele <[email protected]>
+ Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "pbar.h"
#include "purple.h"
#include "gtk.h"
#include "acct_features.h"
static void cb_destroy_win(GtkWidget *widget, gpointer data);
static void cb_close_button(GtkWidget *widget, gpointer data);
static void cb_refresh_button(GtkWidget *widget, gpointer data);
enum {
ACCTICON_COLUMN,
ACCT_COLUMN,
NICKNAME_COLUMN,
PM_COLUMN,
ICON_COLUMN,
MOOD_COLUMN,
MOODMSG_COLUMN,
TUNE_COLUMN,
GAME_COLUMN,
APP_COLUMN,
N_COLUMN
};
static void cb_destroy_win(GtkWidget *widget, gpointer data)
{ destroy_acct_features_dialog((struct acct_features_dialog *)data); }
static void cb_close_button(GtkWidget *widget, gpointer data)
{ destroy_acct_features_dialog((struct acct_features_dialog *)data); }
static void cb_refresh_button(GtkWidget *widget, gpointer data)
{
struct acct_features_dialog *f_diag = (struct acct_features_dialog *)data;
gtk_list_store_clear(f_diag->list_store);
init_acct_features_dialog(f_diag);
}
struct acct_features_dialog * create_acct_features_dialog()
{
struct acct_features_dialog *f_diag = g_malloc(sizeof(struct acct_features_dialog));
memset(f_diag, 0, sizeof(struct acct_features_dialog));
/* widgets that can possibly be modified along dialog lifetime */
f_diag->window = pidgin_create_dialog(_("Account features"),
PIDGIN_HIG_BORDER,
"acct-features",
TRUE);
f_diag->list_store = gtk_list_store_new(N_COLUMN,
GDK_TYPE_PIXBUF, /* ACCTICON */
G_TYPE_STRING, /* ACCT */
GDK_TYPE_PIXBUF, /* NICKNAME */
GDK_TYPE_PIXBUF, /* PM */
GDK_TYPE_PIXBUF, /* ICON */
GDK_TYPE_PIXBUF, /* MOOD */
GDK_TYPE_PIXBUF, /* MOODMSG */
GDK_TYPE_PIXBUF, /* TUNE */
GDK_TYPE_PIXBUF, /* GAME */
GDK_TYPE_PIXBUF /* APP */ );
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(f_diag), f_diag->window);
/* widgets that are not modified */
GtkWidget *pbox = gtk_pidgin_dialog_box_new(_("Available features..."),
_("The following list shows the"
" available features for each"
" activated account. The last"
" line summarizes features"
" that have an impact on at"
" least one account."),
PIDGIN_STOCK_DIALOG_INFO);
GtkWidget *vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(f_diag->window),
FALSE,
PIDGIN_HIG_BORDER);
GtkWidget *hbox = pidgin_dialog_get_action_area(GTK_DIALOG(f_diag->window));
GtkWidget *view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(f_diag->list_store));
GtkWidget *refresh_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
/* create view and model */
GtkTreeViewColumn *p_col = gtk_tree_view_column_new();
GtkCellRenderer *p_renderer;
gtk_tree_view_column_set_title(p_col, _("Account"));
gtk_tree_view_append_column(GTK_TREE_VIEW(view), p_col);
p_renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, FALSE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"pixbuf", ACCTICON_COLUMN);
p_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, TRUE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"text", ACCT_COLUMN);
const struct g_column {
const gchar *title; /* column title */
const gchar *attr_type; /* column type attribute */
GtkCellRenderer *(*gtk_cell_renderer_new)(); /* gtk cell renderer creation */
guint position; /* column position */
} columns[] = {
{ N_("Nickname"), "pixbuf", gtk_cell_renderer_pixbuf_new, NICKNAME_COLUMN },
{ N_("Status message"), "pixbuf", gtk_cell_renderer_pixbuf_new, PM_COLUMN },
{ N_("Buddy icon"), "pixbuf", gtk_cell_renderer_pixbuf_new, ICON_COLUMN },
{ N_("Mood"), "pixbuf", gtk_cell_renderer_pixbuf_new, MOOD_COLUMN },
{ N_("Mood message"), "pixbuf", gtk_cell_renderer_pixbuf_new, MOODMSG_COLUMN },
{ N_("Tune"), "pixbuf", gtk_cell_renderer_pixbuf_new, TUNE_COLUMN },
{ N_("Game"), "pixbuf", gtk_cell_renderer_pixbuf_new, GAME_COLUMN },
{ N_("App."), "pixbuf", gtk_cell_renderer_pixbuf_new, APP_COLUMN },
{ NULL, NULL, NULL, 0 }
}; const struct g_column *col = columns;
/* create columns */
for(; col->title ; col++) {
GtkCellRenderer *renderer = col->gtk_cell_renderer_new();
GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes(_(col->title),
renderer,
col->attr_type,
col->position,
NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
}
/* pack widgets */
gtk_box_pack_start(GTK_BOX(hbox), refresh_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), pbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), view, TRUE, TRUE, 0);
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ f_diag->window, "destroy", cb_destroy_win },
{ refresh_button, "clicked", cb_refresh_button },
{ close_button, "clicked", cb_close_button },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(f_diag), g_signal_connections, f_diag);
/* show everything */
gtk_widget_show_all(f_diag->window);
gtk_window_present(GTK_WINDOW(f_diag->window));
return f_diag;
}
void destroy_acct_features_dialog(struct acct_features_dialog *f_diag)
{
gtk_destroy(PBAR_WIDGET(f_diag)); /* destroy widgets */
g_free(f_diag); /* free dialog */
}
void init_acct_features_dialog(struct acct_features_dialog *f_diag)
{
GList *a = purple_accounts_get_all_active();
/* TODO: should be freed ? */
GdkPixbuf *yes = gtk_widget_render_icon(f_diag->window, GTK_STOCK_YES,
GTK_ICON_SIZE_MENU, NULL);
GdkPixbuf *no = gtk_widget_render_icon(f_diag->window, GTK_STOCK_NO,
GTK_ICON_SIZE_MENU, NULL);
/* last line summarize all available features */
GtkTreeIter e_iter;
GdkPixbuf *e_icon = gtk_widget_render_icon(f_diag->window,
PIDGIN_STOCK_INFO,
GTK_ICON_SIZE_MENU,
NULL);
GdkPixbuf *e_pm = no;
GdkPixbuf *e_buddyicon = no;
GdkPixbuf *e_nickname = no;
GdkPixbuf *e_mood = no;
GdkPixbuf *e_moodmsg = no;
GdkPixbuf *e_game = no;
GdkPixbuf *e_app = no;
GdkPixbuf *e_tune = no;
for(; a ; a = a->next) {
PurpleAccount *acct = (PurpleAccount *)a->data;
PurplePlugin *plugin = purple_find_prpl(acct->protocol_id);
PurplePluginProtocolInfo *protocol = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
GtkTreeIter iter;
gchar *username = g_strdup_printf("%s (%s)",
purple_account_get_username(acct),
purple_account_get_protocol_name(acct));
GdkPixbuf *a_icon = pidgin_create_prpl_icon(acct, PIDGIN_PRPL_ICON_MEDIUM);
GHashTable *attrs = get_account_attrs(acct);
GdkPixbuf *nickname, *mood, *moodmsg, *game, *app, *tune, *pm, *buddyicon;
if(g_hash_table_lookup(attrs, "mood"))
e_mood = mood = yes;
else
mood = no;
if(g_hash_table_lookup(attrs, "moodtext"))
e_moodmsg = moodmsg = yes;
else
moodmsg = no;
if(g_hash_table_lookup(attrs, "game"))
e_game = game = yes;
else
game = no;
if(g_hash_table_lookup(attrs, "office"))
e_app = app = yes;
else
app = no;
if((g_hash_table_lookup(attrs, "tune_title") &&
g_hash_table_lookup(attrs, "tune_artist") &&
g_hash_table_lookup(attrs, "tune_album")))
e_tune = tune = yes;
else
tune = no;
g_hash_table_destroy(attrs);
if(protocol->set_status)
e_pm = pm = yes;
else
pm = no;
if(protocol->set_buddy_icon)
e_buddyicon = buddyicon = yes;
else
buddyicon = no;
/* exception for XMPP
nickname supported
manually
FIXME: however some XMPP account don't support nickname extension */
if(!strcmp(acct->protocol_id, "prpl-jabber") || protocol->set_public_alias)
e_nickname = nickname = yes;
else
nickname = no;
gtk_list_store_append(f_diag->list_store, &iter);
gtk_list_store_set(f_diag->list_store, &iter,
ACCT_COLUMN, username,
ACCTICON_COLUMN, a_icon,
NICKNAME_COLUMN, nickname,
PM_COLUMN, pm,
ICON_COLUMN, buddyicon,
MOOD_COLUMN, mood,
MOODMSG_COLUMN, moodmsg,
TUNE_COLUMN, tune,
GAME_COLUMN, game,
APP_COLUMN, app,
-1);
g_free(username);
}
/* last line summarize all available features */
gtk_list_store_append(f_diag->list_store, &e_iter);
gtk_list_store_set(f_diag->list_store, &e_iter,
ACCT_COLUMN, "Available features",
ACCTICON_COLUMN, e_icon,
NICKNAME_COLUMN, e_nickname,
PM_COLUMN, e_pm,
ICON_COLUMN, e_buddyicon,
MOOD_COLUMN, e_mood,
MOODMSG_COLUMN, e_moodmsg,
TUNE_COLUMN, e_tune,
GAME_COLUMN, e_game,
APP_COLUMN, e_app,
-1);
}
diff --git a/acct_features.h b/acct_features.h
index 8ececc2..6ce6029 100644
--- a/acct_features.h
+++ b/acct_features.h
@@ -1,38 +1,38 @@
/* File: acct_features.h
Time-stamp: <2011-02-07 17:31:32 gawen>
- Copyright (C) 2011 David Hauweele <[email protected]>
+ Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _ACCT_FEATURES_H_
#define _ACCT_FEATURES_H_
#include "common.h"
#include "gtk.h"
struct acct_features_dialog {
BEGIN_PBAR_WIDGET;
/* window and list storage */
GtkWidget *window;
GtkListStore *list_store;
};
struct acct_features_dialog * create_acct_features_dialog();
void destroy_acct_features_dialog(struct acct_features_dialog *f_diag);
void init_acct_features_dialog(struct acct_features_dialog *f_diag);
#endif /* _ACCT_FEATURES_H_ */
diff --git a/actions.c b/actions.c
index 60b5ad5..f9f3fa3 100644
--- a/actions.c
+++ b/actions.c
@@ -1,104 +1,104 @@
/* File: actions.c
Time-stamp: <2011-02-10 17:40:19 gawen>
- Copyright (C) 2011 David Hauweele <[email protected]>
+ Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "pbar.h"
#include "widget.h"
#include "purple.h"
#include "protocol_features.h"
#include "acct_features.h"
#include "status_dialog.h"
#include "mood_dialog.h"
static void cb_icon_choose(const gchar *path, gpointer data)
{
g_return_if_fail(path);
purple_prefs_set_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon", path);
}
static void protocol_features(PurplePluginAction *act)
{
struct protocol_features_dialog *f_diag = create_protocol_features_dialog();
init_protocol_features_dialog(f_diag);
}
static void acct_features(PurplePluginAction *act)
{
struct acct_features_dialog *f_diag = create_acct_features_dialog();
init_acct_features_dialog(f_diag);
}
static void change_nickname(PurplePluginAction *act)
{ create_name_dialog(); }
static void change_pm(PurplePluginAction *act)
{ create_pm_dialog(); }
static void change_status(PurplePluginAction *act)
{
struct status_dialog *s_diag = create_status_dialog();
init_status_dialog(s_diag);
}
static void change_mood(PurplePluginAction *act)
{
struct mood_dialog *s_diag = create_mood_dialog();
init_mood_dialog(s_diag);
}
static void change_icon(PurplePluginAction *act)
{
g_return_if_fail(bar->installed);
PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
GtkWidget *chooser = pidgin_buddy_icon_chooser_new(GTK_WINDOW
(gtk_widget_get_toplevel
(GTK_WIDGET(blist))),
cb_icon_choose,
NULL);
gtk_widget_show(chooser);
}
GList * create_actions(PurplePlugin *plugin, gpointer ctx)
{
GList *l = NULL;
const struct action {
const gchar *title;
void (*action)(PurplePluginAction *);
} actions[] = {
{ N_("Change nickname"), change_nickname },
{ N_("Change personal message"), change_pm },
{ N_("Change status"), change_status },
{ N_("Change mood"), change_mood },
{ N_("Change icon"), change_icon },
{ N_("Protocol features"), protocol_features },
{ N_("Account features"), acct_features },
{ NULL, NULL }
}; const struct action *acts = actions;
for(; acts->title ; acts++) {
PurplePluginAction *act = purple_plugin_action_new(_(acts->title),
acts->action);
l = g_list_append(l, act);
}
return l;
}
diff --git a/actions.h b/actions.h
index 7ca5220..cf540df 100644
--- a/actions.h
+++ b/actions.h
@@ -1,26 +1,26 @@
/* File: actions.h
Time-stamp: <2011-02-04 03:33:28 gawen>
- Copyright (C) 2011 David Hauweele <[email protected]>
+ Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _ACTIONS_H_
#define _ACTIONS_H_
#include "common.h"
GList * create_actions(PurplePlugin *plugin, gpointer ctx);
#endif /* _ACTIONS_H_ */
diff --git a/common.h b/common.h
index c139551..5eca8b3 100644
--- a/common.h
+++ b/common.h
@@ -1,52 +1,52 @@
/* File: common.h
Time-stamp: <2010-10-05 01:14:39 gawen>
- Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _COMMON_H_
#define _COMMON_H_
/* define for NLS */
#define GETTEXT_PACKAGE "pidgin-pbar"
/* common include for pidgin and gtk */
#include <string.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include "pidginstock.h"
#include "plugin.h"
#include "signals.h"
#include "gtkblist.h"
#include "gtkstatusbox.h"
#include "gtkprefs.h"
#include "prpl.h"
#include "request.h"
#include "debug.h"
#include "gtkutils.h"
#include "buddyicon.h"
#include "version.h"
#include "gtkplugin.h"
#ifdef _WIN32
# include "win32dep.h"
#endif /* _WIN32 */
#endif /* _COMMON_H_ */
diff --git a/fr.po b/fr.po
index 993c6dd..d9a1509 100644
--- a/fr.po
+++ b/fr.po
@@ -1,189 +1,189 @@
# Pidgin PBar French translation.
-# Copyright (C) 2010, David Hauweele <[email protected]>
+# Copyright (C) 2010, David Hauweele <[email protected]>
# This file is distributed under the same license as the Pidgin PBar package.
-# David Hauweele <[email protected]>, 2010.
+# David Hauweele <[email protected]>, 2010.
#
msgid ""
msgstr ""
"Project-Id-Version: fr\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-10-13 20:18+0200\n"
"PO-Revision-Date: 2010-11-17 14:20+0100\n"
-"Last-Translator: David Hauweele <[email protected]>\n"
+"Last-Translator: David Hauweele <[email protected]>\n"
"Language-Team: French <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. name
#. internal name
#: pbar.h:36
msgid "PBar"
msgstr "PBar"
#: pbar.h:48
msgid "A toolbar to update some account settings globally."
msgstr "Une barre d'outils pour mettre à jour certains paramètres de manière globale."
#: pbar.h:50
msgid "Adds a toolbar to the buddy list to quickly update nickname, personal message, icon, status and mood. It also allows updating of the current song and other parameters which are updated globally on all accounts that support them."
msgstr "Ajoute une barre d'outils à la liste de contacts pour rapidement mettre à jour le pseudonyme, le message personnel, l'icône, le status et l'humeur. Il permet également de mettre à jour le morceau actuel et d'autres paramètres qui sont mis à jours de manière globale sur tous les comptes qui les supportent."
#: preferences.c:50
msgid "Left"
msgstr "Gauche"
#: preferences.c:51
msgid "Center"
msgstr "Centre"
#: preferences.c:52
msgid "Right"
msgstr "Droite"
#: preferences.c:58
msgid "Top"
msgstr "Haut"
#: preferences.c:59
msgid "Bottom"
msgstr "Bas"
#: preferences.c:130
msgid "_Nickname markup"
msgstr "Balise du _pseudonyme"
#: preferences.c:131
msgid "Nickname markup _hovered"
msgstr "Balise du pseudonyme _survolé"
#: preferences.c:132
msgid "Personal _message markup"
msgstr "Balise du _message personnel"
#: preferences.c:133
msgid "Personal message markup _hovered"
msgstr "Balise du message personnel _survolé"
#: preferences.c:144
msgid "Align _nickname"
msgstr "Aligner le _pseudonyme"
#: preferences.c:145
msgid "Align personal _message"
msgstr "Aligner le _message personnel"
#: preferences.c:146
msgid "Widget _position in the buddy list"
msgstr "_Position de la barre dans la liste de contacts"
#: preferences.c:152
msgid "Hide _statusbox"
msgstr "Cacher le sélecteur d'é_tats"
#: preferences.c:153
msgid "_Ignore status changes"
msgstr "_Ignorer les changements d'états"
#: preferences.c:154
msgid "Use a frame for _entry"
msgstr "Utiliser un _cadre"
#: preferences.c:155
msgid "_Swap left and right click"
msgstr "_Inverser le clique gauche et droit"
#: preferences.c:156
msgid "Use a _compact bar"
msgstr "Utiliser une barre _compacte"
#: preferences.c:157
msgid "_Reset status messages"
msgstr "Réinitialiser les messages d'état"
#. preferences
#. preference root
#. empty messages to display at first installation
#: preferences.h:33
msgid "<Enter nickname here>"
msgstr "<Entrez votre pseudonyme ici>"
#: preferences.h:34
msgid "<Enter personal message here>"
msgstr "<Entrez votre message personnel ici>"
#: widget_gtk.c:94
msgid "Change nickname"
msgstr "Changer le pseudonyme"
#: widget_gtk.c:95
msgid "Enter your nickname here..."
msgstr "Entrez votre pseudonyme ici..."
#: widget_gtk.c:96
msgid "This will change your nickname for every account which supports it."
msgstr "Cela va changer votre pseudonyme pour tous les comptes qui le supportent."
#: widget_gtk.c:102 widget_gtk.c:246
msgid "OK"
msgstr "OK"
#: widget_gtk.c:104 widget_gtk.c:248
msgid "Cancel"
msgstr "_Annuler"
#: widget_gtk.c:197
msgid "_Mood message"
msgstr "Message pour l'_humeur"
#: widget_gtk.c:198
msgid "Current song"
msgstr "Morceau actuel"
#: widget_gtk.c:199
msgid "Song _title"
msgstr "_Titre"
#: widget_gtk.c:200
msgid "Song _artist"
msgstr "_Artiste"
#: widget_gtk.c:201
msgid "Song al_bum"
msgstr "_Album"
#: widget_gtk.c:202
msgid "MSN pecan extra attributes"
msgstr "Options supplémentaires pour MSN pecan"
#: widget_gtk.c:203
msgid "_Game name"
msgstr "_Jeu actuel"
#: widget_gtk.c:204
msgid "_Office app name"
msgstr "_Application"
#: widget_gtk.c:210
msgid "Status and mood message"
msgstr "Message d'états et d'humeur"
#: widget_gtk.c:214
msgid "_Personal message"
msgstr "Message _personnel"
#: widget_gtk.c:240
msgid "Change status messages"
msgstr "Changer le message d'état"
#: widget_gtk.c:241
msgid "Enter status message..."
msgstr "Entrez votre message d'état..."
#: widget_gtk.c:242
msgid "This will change some status messages for every account which supports it, please be advised that some are inconsistent between each other."
msgstr "Cela va changer certains messages d'états pour tous les comptes qui le supportent, notez toutefois que certains sont incompatibles entre eux."
#: widget_gtk.c:361
msgid "None"
msgstr "Aucun"
diff --git a/gtk.c b/gtk.c
index a0ff0b4..519f963 100644
--- a/gtk.c
+++ b/gtk.c
@@ -1,134 +1,134 @@
/* File: gtk.c
Time-stamp: <2011-02-11 01:29:58 gawen>
- Copyright (C) 2011 David Hauweele <[email protected]>
+ Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "gtk.h"
#if !GTK_CHECK_VERSION(2,18,0)
gboolean gtk_widget_get_visible(GtkWidget *widget)
{
return GTK_WIDGET_FLAGS(widget) & GTK_VISIBLE;
}
void gtk_widget_set_visible(GtkWidget *widget, gboolean visible)
{
if(visible)
gtk_widget_show(widget);
else
gtk_widget_hide(widget);
}
void gtk_widget_set_can_focus(GtkWidget *widget, gboolean can_focus)
{
if(can_focus)
GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_FOCUS);
else
GTK_WIDGET_UNSET_FLAGS(widget, GTK_CAN_FOCUS);
}
#endif /* GTK < 2.18 */
void gtk_connect_signals(struct pbar_widget *w,
const struct pbar_gtk_signal *sig_list,
gpointer data)
{
const struct pbar_gtk_signal *s = sig_list;
for(; s->signal ; s++) {
gulong handler_id = g_signal_connect(G_OBJECT(s->widget),
s->signal,
G_CALLBACK(s->callback),
data);
w->gtk_hnd = g_list_append(w->gtk_hnd, GINT_TO_POINTER(handler_id));
w->gtk_inst = g_list_append(w->gtk_inst, s->widget);
}
}
void gtk_destroy(struct pbar_widget *w)
{
GList *l, *i, *j;
/* disconnect gtk signals */
for(i = w->gtk_hnd, j = w->gtk_inst ; i && j ;
i = i->next, j = j->next)
g_signal_handler_disconnect(j->data, GPOINTER_TO_INT(i->data));
g_list_free(w->gtk_hnd);
g_list_free(w->gtk_inst);
/* destroy widgets */
for(j = w->main_widgets ; j ; j = j->next) {
GtkWidget *main_widget = (GtkWidget *)j->data;
l = gtk_container_get_children(GTK_CONTAINER(main_widget));
for(i = l ; i ; i = i->next) {
gtk_widget_destroy(i->data);
i->data = NULL;
}
gtk_widget_destroy(main_widget);
}
}
void gtk_add_main_widget(struct pbar_widget *w, GtkWidget *widget)
{ w->main_widgets = g_list_append(w->main_widgets, widget); }
GtkWidget * gtk_pidgin_dialog_box_new(const gchar *primary,
const gchar *secondary,
const gchar *icon)
{
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *img;
/* create initial pidgin box */
hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER);
vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER);
/* create dialog icon */
img = gtk_image_new_from_stock(icon,
gtk_icon_size_from_name(
PIDGIN_ICON_SIZE_TANGO_HUGE));
gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
if(primary) { /* create and setup primary */
GtkWidget *primary_label;
gchar *primary_esc = g_markup_escape_text(primary, -1);
gchar *label_text = g_strdup_printf(
"<span weight=\"bold\" size=\"larger\">%s</span>", primary_esc);
primary_label = gtk_label_new(NULL);
gtk_label_set_markup(GTK_LABEL(primary_label), label_text);
gtk_label_set_line_wrap(GTK_LABEL(primary_label), TRUE);
gtk_misc_set_alignment(GTK_MISC(primary_label), 0, 0);
g_free(label_text);
gtk_box_pack_start(GTK_BOX(vbox), primary_label, FALSE, FALSE, 0);
}
if(secondary) { /* create and setup secondary */
GtkWidget *secondary_label;
gchar *secondary_esc = g_markup_escape_text(secondary, -1);
secondary_label = gtk_label_new(NULL);
gtk_label_set_markup(GTK_LABEL(secondary_label), secondary_esc);
g_free(secondary_esc);
gtk_label_set_line_wrap(GTK_LABEL(secondary_label), TRUE);
gtk_misc_set_alignment(GTK_MISC(secondary_label), 0, 0);
gtk_box_pack_start(GTK_BOX(vbox), secondary_label, FALSE, FALSE, 0);
}
/* pack widgets into pidgin box */
gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
return hbox;
}
diff --git a/gtk.h b/gtk.h
index 7faf743..5c32ad2 100644
--- a/gtk.h
+++ b/gtk.h
@@ -1,55 +1,55 @@
/* File: gtk.h
Time-stamp: <2011-02-11 01:23:06 gawen>
- Copyright (C) 2011 David Hauweele <[email protected]>
+ Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _GTK_H_
#define _GTK_H_
#include "common.h"
#define PBAR_GTK_CALLBACK(func) ((void (*)(GtkWidget *, gpointer))func)
#define PBAR_WIDGET(widget) ((struct pbar_widget *)widget)
#define BEGIN_PBAR_WIDGET GList *gtk_hnd; \
GList *gtk_inst; \
GList *main_widgets
struct pbar_gtk_signal {
GtkWidget *widget;
const gchar *signal;
void (*callback)(GtkWidget *, gpointer);
};
struct pbar_widget {
BEGIN_PBAR_WIDGET; /* signals handlers and instance for disconnection */
};
#if !GTK_CHECK_VERSION(2,18,0)
gboolean gtk_widget_get_visible(GtkWidget *widget);
void gtk_widget_set_visible(GtkWidget *widget, gboolean visible);
void gtk_widget_set_can_focus(GtkWidget *widget, gboolean can_focus);
#endif /* GTK < 2.18 */
void gtk_destroy(struct pbar_widget *w);
void gtk_add_main_widget(struct pbar_widget *w, GtkWidget *widget);
void gtk_connect_signals(struct pbar_widget *w,
const struct pbar_gtk_signal *sig_list,
gpointer data);
GtkWidget * gtk_pidgin_dialog_box_new(const gchar *primary,
const gchar *secondary,
const gchar *icon);
#endif /* _GTK_H_ */
diff --git a/mood_dialog.c b/mood_dialog.c
index 0fe440c..1b67101 100644
--- a/mood_dialog.c
+++ b/mood_dialog.c
@@ -1,226 +1,226 @@
/* File: mood_dialog.c
Time-stamp: <2011-02-11 01:46:37 gawen>
- Copyright (C) 2011 David Hauweele <[email protected]>
+ Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "gtk.h"
#include "purple.h"
#include "preferences.h"
#include "mood_dialog.h"
static void cb_destroy_win(GtkWidget *widget, gpointer data);
static void cb_close_button(GtkWidget *widget, gpointer data);
static void cb_apply_button(GtkWidget *widget, gpointer date);
static void cb_refresh_button(GtkWidget *widget, gpointer data);
static void cb_row_activated(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data);
enum {
MOODICON_COLUMN,
MOOD_COLUMN,
N_COLUMN
};
static void cb_destroy_win(GtkWidget *widget, gpointer data)
{ destroy_mood_dialog((struct mood_dialog *)data); }
static void cb_row_activated(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data)
{ cb_apply_button(widget, data); }
static void cb_apply_button(GtkWidget *widget, gpointer data)
{
GtkTreeModel *model;
GtkTreeIter iter;
GtkTreeSelection *sel;
struct mood_dialog *s_diag = (struct mood_dialog *)data;
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(s_diag->list_view));
if(gtk_tree_selection_get_selected(sel, &model, &iter)) {
const gchar *mood;
gchar *name;
gtk_tree_model_get(model, &iter, MOOD_COLUMN, &name, -1);
mood = g_hash_table_lookup(s_diag->global_moods, name);
if(mood) { /* mood found */
gchar *path;
destroy_mood_dialog(s_diag); /* destroy dialog first */
set_status_with_mood_all(mood);
purple_prefs_set_string(PREF "/mood", mood);
path = get_mood_icon_path(mood);
set_widget_mood(path);
g_free(path);
purple_debug_info(NAME, "mood changed to \"%s\" by user\n", mood);
} else
purple_debug_info(NAME, "selected mood \"%s\" doesn't exists\n", name);
g_free(name);
} else
purple_debug_info(NAME, "no row selected\n");
}
static void cb_close_button(GtkWidget *widget, gpointer data)
{ destroy_mood_dialog((struct mood_dialog *)data); }
static void cb_refresh_button(GtkWidget *widget, gpointer data)
{
struct mood_dialog *s_diag = (struct mood_dialog *)data;
gtk_list_store_clear(s_diag->list_store);
init_mood_dialog(s_diag);
}
struct mood_dialog * create_mood_dialog()
{
struct mood_dialog *s_diag = g_malloc(sizeof(struct mood_dialog));
memset(s_diag, 0, sizeof(struct mood_dialog));
/* widgets that can be modifier along dialog lifetime */
s_diag->window = pidgin_create_dialog(_("Mood selection"),
PIDGIN_HIG_BORDER,
"mood-select",
TRUE);
s_diag->list_store = gtk_list_store_new(N_COLUMN,
GDK_TYPE_PIXBUF, /* MOODICON */
G_TYPE_STRING /* MOOD */ );
s_diag->list_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
s_diag->list_store));
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(s_diag), s_diag->window);
/* widgets that are not modified */
GtkWidget *pbox = gtk_pidgin_dialog_box_new(_("Select your mood..."),
_("This will change your mood for"
" every account which supports"
" it."),
PIDGIN_STOCK_DIALOG_QUESTION);
GtkWidget *vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(
s_diag->window),
FALSE,
PIDGIN_HIG_BORDER);
GtkWidget *hbox = pidgin_dialog_get_action_area(GTK_DIALOG(s_diag->window));
GtkWidget *refresh_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
GtkWidget *apply_button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
/* create view and model */
GtkTreeViewColumn *p_col = gtk_tree_view_column_new();
GtkCellRenderer *p_renderer;
gtk_tree_view_column_set_title(p_col, _("Mood"));
gtk_tree_view_append_column(GTK_TREE_VIEW(s_diag->list_view), p_col);
p_renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, FALSE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"pixbuf", MOODICON_COLUMN);
p_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, TRUE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"text", MOOD_COLUMN);
/* pack widgets */
gtk_box_pack_start(GTK_BOX(hbox), refresh_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), apply_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), pbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), s_diag->list_view, TRUE, TRUE, 0);
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ s_diag->window, "destroy", cb_destroy_win },
{ s_diag->list_view, "row-activated", PBAR_GTK_CALLBACK(cb_row_activated) },
{ refresh_button, "clicked", cb_refresh_button },
{ apply_button, "clicked", cb_apply_button },
{ close_button, "clicked", cb_close_button },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(s_diag), g_signal_connections, s_diag);
/* show everything */
gtk_widget_show_all(s_diag->window);
gtk_window_present(GTK_WINDOW(s_diag->window));
return s_diag;
}
void destroy_mood_dialog(struct mood_dialog *s_diag)
{
gtk_destroy(PBAR_WIDGET(s_diag)); /* destroy widgets */
g_hash_table_destroy(s_diag->global_moods); /* free global moods */
g_free(s_diag); /* free dialog */
}
void init_mood_dialog(struct mood_dialog *s_diag)
{
GtkTreeIter empty_iter;
GdkPixbuf *empty_pixbuf;
GtkWidget *empty_image;
const gchar *empty_mood;
gchar *empty_path;
PurpleMood *mood = get_global_moods();
if(!s_diag->global_moods)
s_diag->global_moods = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
/* add empty mood to mood list */
empty_mood = "";
empty_path = get_mood_icon_path(empty_mood);
empty_image = gtk_image_new_from_file(empty_path);
empty_pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(empty_image));
g_free(empty_path);
gtk_list_store_append(s_diag->list_store, &empty_iter);
gtk_list_store_set(s_diag->list_store, &empty_iter,
MOODICON_COLUMN, empty_pixbuf,
MOOD_COLUMN, _("None"),
-1);
g_hash_table_insert(s_diag->global_moods, (gpointer)_("None"),
(gpointer)empty_mood);
for(; mood->mood ; mood++) {
if(!mood->mood || !mood->description)
continue;
GtkTreeIter iter;
GtkWidget *image;
GdkPixbuf *pixbuf;
gchar *path = get_mood_icon_path(mood->mood);
g_hash_table_insert(s_diag->global_moods, (gpointer)_(mood->description),
(gpointer)mood->mood);
image = gtk_image_new_from_file(path);
pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(image));
g_free(path);
gtk_list_store_append(s_diag->list_store, &iter);
gtk_list_store_set(s_diag->list_store, &iter,
MOODICON_COLUMN, pixbuf,
MOOD_COLUMN, _(mood->description),
-1);
}
}
diff --git a/mood_dialog.h b/mood_dialog.h
index de68b99..c44c67f 100644
--- a/mood_dialog.h
+++ b/mood_dialog.h
@@ -1,42 +1,42 @@
/* File: mood_dialog.h
Time-stamp: <2011-02-10 17:09:37 gawen>
- Copyright (C) 2011 David Hauweele <[email protected]>
+ Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _MOOD_DIALOG_H_
#define _MOOD_DIALOG_H_
#include "common.h"
#include "gtk.h"
struct mood_dialog {
BEGIN_PBAR_WIDGET;
/* window and list */
GtkWidget *window;
GtkWidget *list_view;
GtkListStore *list_store;
/* global moods for selection */
GHashTable *global_moods;
};
struct mood_dialog * create_mood_dialog();
void destroy_mood_dialog(struct mood_dialog *s_diag);
void init_mood_dialog(struct mood_dialog *s_diag);
#endif /* _MOOD_DIALOG_H_ */
diff --git a/pbar.c b/pbar.c
index cbd31c4..b384159 100644
--- a/pbar.c
+++ b/pbar.c
@@ -1,134 +1,134 @@
/* File: pbar.c
Time-stamp: <2011-01-31 19:06:59 gawen>
- Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#define PURPLE_PLUGINS
#include "common.h"
#include "pbar.h"
#include "actions.h"
#include "preferences.h"
#include "widget.h"
#include "purple.h"
static gboolean plugin_load(PurplePlugin *plugin);
static gboolean plugin_unload(PurplePlugin *plugin);
static PidginPluginUiInfo ui_info = { get_config_frame };
static PurplePluginInfo info = {
PURPLE_PLUGIN_MAGIC,
PURPLE_MAJOR_VERSION,
PURPLE_MINOR_VERSION,
PURPLE_PLUGIN_STANDARD,
PIDGIN_PLUGIN_TYPE,
0,
NULL,
PURPLE_PRIORITY_DEFAULT,
PLUGIN_ID,
NULL, /* defined later for NLS */
PLUGIN_VERSION,
NULL, /* defined later for NLS */
NULL, /* defined later for NLS */
PLUGIN_AUTHOR,
PLUGIN_WEBSITE,
plugin_load,
plugin_unload,
NULL,
&ui_info,
NULL,
NULL,
create_actions,
NULL,
NULL,
NULL,
NULL
};
PurplePlugin *thisplugin;
/* we need this callback to catch
blist construction and install
widget when we may do so */
static void cb_blist_created(GtkWidget *widget, gpointer data)
{
/* create widget and
load preferences */
create_widget();
init_widget();
}
static gboolean plugin_load(PurplePlugin *plugin)
{
/* connect construction signal only when needed
as when installing the plugin after launching
pidgin there is no need to wait for blist
creation */
if(is_gtk_blist_created()) {
/* create widget and
load preferences */
create_widget();
init_widget();
}
else
/* connect construction signal */
purple_signal_connect(pidgin_blist_get_handle(),
"gtkblist-created",
plugin,
PURPLE_CALLBACK(cb_blist_created),
NULL);
purple_debug_info(NAME,"plugin initialized...\n");
return TRUE;
}
static gboolean plugin_unload(PurplePlugin *plugin)
{
/* destroy widget and free memory */
destroy_widget();
/* restore statusbox */
set_statusbox_visible(TRUE);
purple_debug_info(NAME,"plugin destroyed...\n");
return TRUE;
}
static void init_plugin(PurplePlugin *plugin)
{
thisplugin = plugin;
#ifdef ENABLE_NLS
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
#endif /* ENABLE_NLS */
/* translate name, summary and description */
info.name = _(PLUGIN_NAME);
info.summary = _(PLUGIN_SUMMARY);
info.description = _(PLUGIN_DESCRIPTION);
/* load or create preferences */
init_prefs();
}
PURPLE_INIT_PLUGIN(pbar, init_plugin, info)
diff --git a/pbar.h b/pbar.h
index c9fc95c..34a9400 100644
--- a/pbar.h
+++ b/pbar.h
@@ -1,61 +1,61 @@
/* File: pbar.h
Time-stamp: <2010-11-15 23:55:36 gawen>
- Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _PBAR_H_
#define _PBAR_H_
#include "common.h"
#ifndef G_GNUC_NULL_TERMINATED
# if __GNUC__ >= 4
# define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
# else
# define G_GNUC_NULL_TERMINATED
# endif /* __GNUC__ >= 4 */
#endif /* G_GNUC_NULL_TERMINATED */
/* name */
#define NAME "pbar" /* internal name */
#define DISP_NAME N_("PBar") /* displayed name */
#define VERSION "0.2-git" /* current version */
/* plugin information */
#define PLUGIN_ID "gtk-" NAME /* gtk plugin id */
#define PLUGIN_NAME DISP_NAME
#ifndef COMMIT
# define PLUGIN_VERSION VERSION
#else
# define PLUGIN_VERSION VERSION " (commit:" COMMIT ")" /* add git commit
when available */
#endif
#define PLUGIN_SUMMARY N_("A toolbar to update some account settings " \
"globally.")
#define PLUGIN_DESCRIPTION N_("Adds a toolbar to the buddy list to quickly " \
"update nickname, personal message, icon, " \
"status and mood. It also allows updating of " \
"the current song and other parameters which " \
"are updated globally on all accounts that " \
"support them.")
-#define PLUGIN_AUTHOR "David Hauweele <[email protected]>"
+#define PLUGIN_AUTHOR "David Hauweele <[email protected]>"
#define PLUGIN_WEBSITE "http://www.atlantysse.prout.be/~gawen/pidgin-pbar.html"
extern PurplePlugin *thisplugin;
#endif /* _PBAR_H_ */
diff --git a/preferences.c b/preferences.c
index 0756b9c..0e5f30c 100644
--- a/preferences.c
+++ b/preferences.c
@@ -1,376 +1,376 @@
/* File: prefs.c
- Time-stamp: <2010-11-15 23:14:54 gawen>
+ Time-stamp: <2011-04-02 16:25:35 gawen>
- Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "preferences.h"
#include "widget.h"
/* callback for preferences setting which set preferences and
update interface when needed */
static void cb_nickname_markup(GtkWidget *widget, gpointer data);
static void cb_nickname_markup_hover(GtkWidget *widget, gpointer data);
static void cb_personal_message_markup(GtkWidget *widget, gpointer data);
static void cb_personal_message_markup_hover(GtkWidget *widget, gpointer data);
static void cb_hide_statusbox(GtkWidget *widget, gpointer data);
static void cb_override_status(GtkWidget *widget, gpointer data);
static void cb_nickname_justify(GtkWidget *widget, gpointer data);
static void cb_personal_message_justify(GtkWidget *widget, gpointer data);
static void cb_compact(GtkWidget *widget, gpointer data);
static void cb_frame_entry(GtkWidget *widget, gpointer data);
static void cb_swap_click(GtkWidget *widget, gpointer data);
static void cb_reset_attrs(GtkWidget *widget, gpointer data);
static void cb_widget_position(GtkWidget *widget, gpointer data);
/* the following structures are defined here as global
since they are needed in combobox callback */
/* alias we will use for combobox */
static const struct i_alias {
const char *alias;
int value;
} alias_justify[] = {
{ N_("Left"), JUSTIFY_LEFT },
{ N_("Center"), JUSTIFY_CENTER },
{ N_("Right"), JUSTIFY_RIGHT },
{ NULL, 0 }
};
/* widget position in the buddy list */
static const struct i_alias alias_position[] = {
{ N_("Top"), POSITION_TOP },
{ N_("Bottom"), POSITION_BOTTOM },
{ NULL, 0 }
};
/* init preferences and set default values */
void init_prefs()
{
/* string preferences and default value */
const struct prefs_string {
const char *name;
const char *value;
} prefs_add_string[] = {
{ PREF "/personal-message-markup-hover", "<span color=\"DarkOliveGreen4\"><small><i>%p</i></small></span>" },
{ PREF "/personal-message-markup", "<small>%p</small>" },
{ PREF "/nickname-markup-hover", "<span color=\"DarkOliveGreen4\"><b>%n</b></span>" },
{ PREF "/nickname-markup", "<b>%n</b>" },
{ PREF "/personal-message", EMPTY_PM },
{ PREF "/tune-title", "" },
{ PREF "/tune-artist", "" },
{ PREF "/tune-album", "" },
{ PREF "/game-message", "" },
{ PREF "/office-message", "" },
{ PREF "/nickname", EMPTY_NAME },
{ PREF "/mood-message", "" },
{ PREF "/mood", "" },
{ NULL, NULL }
}; const struct prefs_string *s = prefs_add_string;
/* boolean preferences and default value */
const struct prefs_bool {
const char *name;
gboolean value;
} prefs_add_bool[] = {
{ PREF "/hide-statusbox", TRUE },
{ PREF "/override-status", FALSE },
{ PREF "/frame-entry", TRUE },
{ PREF "/swap-click", FALSE },
{ PREF "/reset-attrs", FALSE },
{ PREF "/compact", FALSE },
{ NULL, FALSE }
}; const struct prefs_bool *b = prefs_add_bool;
/* integer preferences and default value */
const struct prefs_int {
const char *name;
int value;
} prefs_add_int[] = {
{ PREF "/nickname-justify", JUSTIFY_LEFT },
{ PREF "/personal-message-justify", JUSTIFY_LEFT },
{ PREF "/widget-position", POSITION_TOP },
{ NULL, 0 }
}; const struct prefs_int *i = prefs_add_int;
/* add preferences */
purple_prefs_add_none(PREF);
for(; s->name ; s++)
purple_prefs_add_string(s->name, s->value);
for(; b->name ; b++)
purple_prefs_add_bool(b->name, b->value);
for(; i->name ; i++)
purple_prefs_add_int(i->name, i->value);
}
GtkWidget * get_config_frame(PurplePlugin *plugin)
{
/* entry widgets label, associated preference and callback */
const struct widget {
const char *name;
const char *prefs;
void (*callback)(GtkWidget *, gpointer);
} entry[] = {
{ N_("_Nickname markup"), PREF "/nickname-markup", cb_nickname_markup },
{ N_("Nickname markup _hovered"), PREF "/nickname-markup-hover", cb_nickname_markup_hover },
{ N_("Personal _message markup"), PREF "/personal-message-markup", cb_personal_message_markup },
{ N_("Personal message markup _hovered"), PREF "/personal-message-markup-hover", cb_personal_message_markup_hover },
{ NULL, NULL, NULL }
}; const struct widget *e = entry;
/* combobox widgets label, associated preference, alias and callback */
const struct i_widget {
const char *name;
const char *prefs;
const struct i_alias *alias;
void (*callback)(GtkWidget *, gpointer);
} combobox[] = {
{ N_("Align _nickname"), PREF "/nickname-justify", alias_justify, cb_nickname_justify },
{ N_("Align personal _message"), PREF "/personal-message-justify", alias_justify, cb_personal_message_justify },
{ N_("Widget _position in the buddy list"), PREF "/widget-position", alias_position, cb_widget_position },
{ NULL, NULL, NULL, NULL }
}; const struct i_widget *cbx = combobox;
/* check button widgets label, associated preference and callback */
const struct widget check_button[] = {
{ N_("Hide _statusbox"), PREF "/hide-statusbox", cb_hide_statusbox },
{ N_("_Ignore status changes"), PREF "/override-status", cb_override_status },
{ N_("Use a frame for _entry"), PREF "/frame-entry", cb_frame_entry },
{ N_("_Swap left and right click"), PREF "/swap-click", cb_swap_click },
{ N_("Use a _compact bar"), PREF "/compact", cb_compact },
{ N_("_Reset status messages"), PREF "/reset-attrs", cb_reset_attrs },
{ NULL, NULL, NULL }
}; const struct widget *cb = check_button;
/* create table */
GtkWidget *table = gtk_table_new(((sizeof(entry) - 2) +
sizeof(check_button) / 2 - 1) /
sizeof(struct widget),
2, FALSE);
/* load table and connect signals */
int x = 0, y = 0;
for(; e->name ; e++, y++) {
/* entry widgets */
GtkWidget *widget_label = gtk_label_new_with_mnemonic(_(e->name));
GtkWidget *widget_entry = gtk_entry_new();
const gchar *prefs_value = purple_prefs_get_string(e->prefs);
gtk_label_set_mnemonic_widget(GTK_LABEL(widget_label), widget_entry);
gtk_entry_set_text(GTK_ENTRY(widget_entry), prefs_value);
gtk_misc_set_alignment(GTK_MISC(widget_label), 0., .5);
gtk_table_attach(GTK_TABLE(table), widget_label, 0, 1, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
gtk_table_attach(GTK_TABLE(table), widget_entry, 1, 2, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
g_signal_connect(G_OBJECT(widget_entry), "activate", G_CALLBACK(e->callback),NULL);
g_signal_connect(G_OBJECT(widget_entry), "focus-out-event", G_CALLBACK(e->callback),NULL);
}
for(; cbx->name ; cbx++, y++) {
/* combobox widgets */
const struct i_alias *j;
GtkWidget *widget_label = gtk_label_new_with_mnemonic(_(cbx->name));
GtkWidget *widget_combo = gtk_combo_box_new_text();
int prefs_value = purple_prefs_get_int(cbx->prefs);
int i;
gtk_label_set_mnemonic_widget(GTK_LABEL(widget_label), widget_combo);
gtk_misc_set_alignment(GTK_MISC(widget_label), 0., .5);
gtk_table_attach(GTK_TABLE(table), widget_label, 0, 1, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
gtk_table_attach(GTK_TABLE(table), widget_combo, 1, 2, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
for(i = 0, j = cbx->alias ; j->alias ; j++, i++) {
gtk_combo_box_append_text(GTK_COMBO_BOX(widget_combo), _(j->alias));
if(j->value == prefs_value)
gtk_combo_box_set_active(GTK_COMBO_BOX(widget_combo), i);
}
g_signal_connect(G_OBJECT(widget_combo), "changed", G_CALLBACK(cbx->callback), (gpointer)cbx->alias);
}
for(; cb->name ; cb++, x = (x + 1) % 2) {
/* check button widgets */
GtkWidget *widget_cb = gtk_check_button_new_with_mnemonic(_(cb->name));
gboolean prefs_value = purple_prefs_get_bool(cb->prefs);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget_cb), prefs_value);
gtk_table_attach(GTK_TABLE(table), widget_cb, x, x+1, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
g_signal_connect(G_OBJECT(widget_cb), "toggled", G_CALLBACK(cb->callback),NULL);
if(x % 2)
y++;
}
return table; /* pidgin destroy this when closed */
}
static void cb_nickname_markup(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget));
purple_prefs_set_string(PREF "/nickname-markup", value);
if(!get_widget_name_hover_state()) {
const gchar *name = purple_prefs_get_string(PREF "/nickname");
set_widget_name(value, name);
}
purple_debug_info(NAME, "nickname markup changed\n");
}
static void cb_nickname_markup_hover(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget));
purple_prefs_set_string(PREF "/nickname-markup-hover", value);
if(get_widget_name_hover_state()) {
const gchar *name = purple_prefs_get_string(PREF "/nickname");
set_widget_name(value, name);
}
purple_debug_info(NAME, "nickname markup hover changed\n");
}
static void cb_personal_message_markup(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget));
purple_prefs_set_string(PREF "/personal-message-markup", value);
if(!get_widget_pm_hover_state()) {
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
set_widget_pm(value, pm);
}
purple_debug_info(NAME, "personal message markup hover changed\n");
}
static void cb_personal_message_markup_hover(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget));
purple_prefs_set_string(PREF "/personal-message-markup-hover", value);
if(get_widget_pm_hover_state()) {
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
set_widget_pm(value, pm);
}
purple_debug_info(NAME, "personal message markup hover changed\n");
}
static void cb_hide_statusbox(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/hide-statusbox", state);
set_statusbox_visible(!state);
purple_debug_info(NAME, "status box state changed\n");
}
static void cb_override_status(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/override-status", state);
purple_debug_info(NAME, "override status state changed\n");
}
static void cb_nickname_justify(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget));
const struct i_alias *j;
for(j = (struct i_alias *)data ; j->alias ; j++) {
if(!strcmp(value, _(j->alias))) {
purple_prefs_set_int(PREF "/nickname-justify", j->value);
set_widget_name_justify(j->value);
break;
}
}
purple_debug_info(NAME, "nickname justification changed\n");
}
static void cb_personal_message_justify(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget));
const struct i_alias *j;
for(j = (struct i_alias *)data ; j->alias ; j++) {
if(!strcmp(value, _(j->alias))) {
purple_prefs_set_int(PREF "/personal-message-justify", j->value);
set_widget_pm_justify(j->value);
break;
}
}
purple_debug_info(NAME, "personal message justification changed\n");
}
static void cb_compact(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/compact", state);
/* recreate bar since we need to repack everything */
destroy_widget();
create_widget();
init_widget();
purple_debug_info(NAME, "compact state changed\n");
}
static void cb_frame_entry(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/frame-entry", state);
set_widget_entry_frame(state);
purple_debug_info(NAME, "frame entry state changed\n");
}
static void cb_swap_click(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/swap-click", state);
purple_debug_info(NAME, "swap click state changed\n");
}
static void cb_reset_attrs(GtkWidget *widget, gpointer data)
{
gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
purple_prefs_set_bool(PREF "/reset-attrs", state);
set_widget_entry_frame(state);
purple_debug_info(NAME, "reset attributes state changed\n");
}
static void cb_widget_position(GtkWidget *widget, gpointer data)
{
const gchar *value = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget));
const struct i_alias *j;
for(j = (struct i_alias *)data ; j->alias ; j++) {
if(!strcmp(value, _(j->alias))) {
purple_prefs_set_int(PREF "/widget-position", j->value);
/* recreate bar since we need to repack everything */
destroy_widget();
create_widget();
init_widget();
break;
}
}
purple_debug_info(NAME, "personal message justification changed\n");
}
diff --git a/preferences.h b/preferences.h
index 56fe732..9eac7db 100644
--- a/preferences.h
+++ b/preferences.h
@@ -1,43 +1,43 @@
/* File: prefs.h
Time-stamp: <2010-11-14 01:30:53 gawen>
- Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _PREFERENCES_H_
#define _PREFERENCES_H_
#include "common.h"
#include "pbar.h"
#include "widget.h"
/* preferences */
#define PREF "/plugins/gtk/" NAME /* preference root */
/* empty messages to display at first installation */
#define EMPTY_NAME N_("<Enter nickname here>")
#define EMPTY_PM N_("<Enter personal message here>")
/* justification and alignment */
enum { JUSTIFY_LEFT, JUSTIFY_CENTER, JUSTIFY_RIGHT };
enum { POSITION_TOP, POSITION_BOTTOM };
void init_prefs();
GtkWidget * get_config_frame(PurplePlugin *plugin);
#endif /* _PREFERENCES_H_ */
diff --git a/protocol_features.c b/protocol_features.c
index bb0616b..36362a3 100644
--- a/protocol_features.c
+++ b/protocol_features.c
@@ -1,221 +1,221 @@
/* File: protocol_features.c
Time-stamp: <2011-02-11 01:39:18 gawen>
- Copyright (C) 2011 David Hauweele <[email protected]>
+ Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "pbar.h"
#include "purple.h"
#include "gtk.h"
#include "protocol_features.h"
static void cb_destroy_win(GtkWidget *widget, gpointer data);
static void cb_close_button(GtkWidget *widget, gpointer data);
static void cb_refresh_button(GtkWidget *widget, gpointer data);
enum {
PROTOCOLICON_COLUMN,
PROTOCOL_COLUMN,
NICKNAME_COLUMN,
PM_COLUMN,
ICON_COLUMN,
MOOD_COLUMN,
MOODMSG_COLUMN,
TUNE_COLUMN,
GAME_COLUMN,
APP_COLUMN,
N_COLUMN
};
static void cb_destroy_win(GtkWidget *widget, gpointer data)
{ destroy_protocol_features_dialog((struct protocol_features_dialog *)data); }
static void cb_close_button(GtkWidget *widget, gpointer data)
{ destroy_protocol_features_dialog((struct protocol_features_dialog *)data); }
static void cb_refresh_button(GtkWidget *widget, gpointer data)
{
struct protocol_features_dialog *f_diag = (struct protocol_features_dialog *)data;
gtk_list_store_clear(f_diag->list_store);
init_protocol_features_dialog(f_diag);
}
struct protocol_features_dialog * create_protocol_features_dialog()
{
struct protocol_features_dialog *f_diag = g_malloc(sizeof(struct protocol_features_dialog));
memset(f_diag, 0, sizeof(struct protocol_features_dialog));
/* widgets that can possibly be modified along dialog lifetime */
f_diag->window = pidgin_create_dialog(_("Protocol features"),
PIDGIN_HIG_BORDER,
"protocol-features",
TRUE);
f_diag->list_store = gtk_list_store_new(N_COLUMN,
GDK_TYPE_PIXBUF, /* PROTOCOLICON */
G_TYPE_STRING, /* PROTOCOL */
GDK_TYPE_PIXBUF, /* NICKNAME */
GDK_TYPE_PIXBUF, /* PM */
GDK_TYPE_PIXBUF, /* ICON */
GDK_TYPE_PIXBUF, /* MOOD */
GDK_TYPE_PIXBUF, /* MOODMSG */
GDK_TYPE_PIXBUF, /* TUNE */
GDK_TYPE_PIXBUF, /* GAME */
GDK_TYPE_PIXBUF /* APP */ );
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(f_diag), f_diag->window);
/* widgets that are not modified */
GtkWidget *pbox = gtk_pidgin_dialog_box_new(_("Available features..."),
_("The following list shows the"
" available features for each"
" protocol."),
PIDGIN_STOCK_DIALOG_INFO);
GtkWidget *vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(f_diag->window),
FALSE,
PIDGIN_HIG_BORDER);
GtkWidget *hbox = pidgin_dialog_get_action_area(GTK_DIALOG(f_diag->window));
GtkWidget *view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(f_diag->list_store));
GtkWidget *refresh_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
/* create view and model */
GtkTreeViewColumn *p_col = gtk_tree_view_column_new();
GtkCellRenderer *p_renderer;
gtk_tree_view_column_set_title(p_col, _("Protocol"));
gtk_tree_view_append_column(GTK_TREE_VIEW(view), p_col);
p_renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, FALSE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"pixbuf", PROTOCOLICON_COLUMN);
p_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, TRUE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"text", PROTOCOL_COLUMN);
const struct g_column {
const gchar *title; /* column title */
const gchar *attr_type; /* column type attribute */
GtkCellRenderer *(*gtk_cell_renderer_new)(); /* gtk cell renderer creation */
guint position; /* column position */
} columns[] = {
{ N_("Nickname"), "pixbuf", gtk_cell_renderer_pixbuf_new, NICKNAME_COLUMN },
{ N_("Status message"), "pixbuf", gtk_cell_renderer_pixbuf_new, PM_COLUMN },
{ N_("Buddy icon"), "pixbuf", gtk_cell_renderer_pixbuf_new, ICON_COLUMN },
{ N_("Mood"), "pixbuf", gtk_cell_renderer_pixbuf_new, MOOD_COLUMN },
{ N_("Mood message"), "pixbuf", gtk_cell_renderer_pixbuf_new, MOODMSG_COLUMN },
{ N_("Tune"), "pixbuf", gtk_cell_renderer_pixbuf_new, TUNE_COLUMN },
{ N_("Game"), "pixbuf", gtk_cell_renderer_pixbuf_new, GAME_COLUMN },
{ N_("App."), "pixbuf", gtk_cell_renderer_pixbuf_new, APP_COLUMN },
{ NULL, NULL, NULL, 0 }
}; const struct g_column *col = columns;
/* create columns */
for(; col->title ; col++) {
GtkCellRenderer *renderer = col->gtk_cell_renderer_new();
GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes(_(col->title),
renderer,
col->attr_type,
col->position,
NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
}
/* pack widgets */
gtk_box_pack_start(GTK_BOX(hbox), refresh_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), pbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), view, TRUE, TRUE, 0);
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ f_diag->window, "destroy", cb_destroy_win },
{ refresh_button, "clicked", cb_refresh_button },
{ close_button, "clicked", cb_close_button },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(f_diag), g_signal_connections, f_diag);
/* show everything */
gtk_widget_show_all(f_diag->window);
gtk_window_present(GTK_WINDOW(f_diag->window));
return f_diag;
}
void destroy_protocol_features_dialog(struct protocol_features_dialog *f_diag)
{
gtk_destroy(PBAR_WIDGET(f_diag)); /* destroy widgets */
g_free(f_diag); /* free dialog */
}
void init_protocol_features_dialog(struct protocol_features_dialog *f_diag)
{
GList *p = purple_plugins_get_protocols();
/* TODO: should be freed ? */
GdkPixbuf *yes = gtk_widget_render_icon(f_diag->window, GTK_STOCK_YES,
GTK_ICON_SIZE_MENU, NULL);
GdkPixbuf *no = gtk_widget_render_icon(f_diag->window, GTK_STOCK_NO,
GTK_ICON_SIZE_MENU, NULL);
for(; p ; p = p->next) {
PurplePlugin *plugin = p->data;
PurplePluginInfo *info = plugin->info;
PurplePluginProtocolInfo *protocol = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
if(info && info->name) {
GtkTreeIter iter;
GdkPixbuf *p_icon = create_prpl_icon_from_info(protocol,
PIDGIN_PRPL_ICON_MEDIUM);
GHashTable *attrs = get_protocol_attrs(protocol);
GdkPixbuf *nickname;
GdkPixbuf *mood = g_hash_table_lookup(attrs, "mood") ? yes : no;
GdkPixbuf *moodmsg = g_hash_table_lookup(attrs, "moodtext") ? yes : no;
GdkPixbuf *game = g_hash_table_lookup(attrs, "game") ? yes : no;
GdkPixbuf *app = g_hash_table_lookup(attrs, "office") ? yes : no;
GdkPixbuf *tune = (g_hash_table_lookup(attrs, "tune_title") &&
g_hash_table_lookup(attrs, "tune_artist") &&
g_hash_table_lookup(attrs, "tune_album")) ? yes : no;
g_hash_table_destroy(attrs);
/* exception for XMPP
nickname supported
manually */
if(!strcmp(info->name, "XMPP"))
nickname = yes;
else
nickname = protocol->set_public_alias ? yes : no;
gtk_list_store_append(f_diag->list_store, &iter);
gtk_list_store_set(f_diag->list_store, &iter,
PROTOCOL_COLUMN, info->name,
PROTOCOLICON_COLUMN, p_icon,
NICKNAME_COLUMN, nickname,
PM_COLUMN, protocol->set_status ? yes : no,
ICON_COLUMN, protocol->set_buddy_icon ? yes : no,
MOOD_COLUMN, mood,
MOODMSG_COLUMN, moodmsg,
TUNE_COLUMN, tune,
GAME_COLUMN, game,
APP_COLUMN, app,
-1);
}
}
}
diff --git a/protocol_features.h b/protocol_features.h
index b42f7f8..60f227b 100644
--- a/protocol_features.h
+++ b/protocol_features.h
@@ -1,38 +1,38 @@
/* File: protocol_features.h
Time-stamp: <2011-02-07 17:31:27 gawen>
- Copyright (C) 2011 David Hauweele <[email protected]>
+ Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _PROTOCOL_FEATURES_H_
#define _PROTOCOL_FEATURES_H_
#include "common.h"
#include "gtk.h"
struct protocol_features_dialog {
BEGIN_PBAR_WIDGET;
/* window and list storage */
GtkWidget *window;
GtkListStore *list_store;
};
struct protocol_features_dialog * create_protocol_features_dialog();
void destroy_protocol_features_dialog(struct protocol_features_dialog *f_diag);
void init_protocol_features_dialog(struct protocol_features_dialog *f_diag);
#endif /* _PROTOCOL_FEATURES_H_ */
diff --git a/purple.c b/purple.c
index 767f171..f4dccbf 100644
--- a/purple.c
+++ b/purple.c
@@ -1,402 +1,402 @@
/* File: purple.c
Time-stamp: <2011-02-10 17:54:01 gawen>
- Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* this file contains common functions for libpurple and pidgin */
#include "common.h"
#include "pbar.h"
#include "gtk.h"
#include "purple.h"
/* callbacks */
static void cb_global_moods_for_each(gpointer key, gpointer value,
gpointer user_data);
static void cb_set_alias_failure(PurpleAccount *account, const char *error);
static void cb_dummy();
/* check if default gtk blist is created */
gboolean is_gtk_blist_created()
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
if(!blist ||
!blist->vbox ||
!gtk_widget_get_visible(blist->vbox))
return FALSE;
return TRUE;
}
/* get buddy icon from statusbox widget */
GdkPixbuf * get_buddy_icon()
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
const PidginStatusBox *statusbox = PIDGIN_STATUS_BOX(blist->statusbox);
return statusbox->buddy_icon;
}
/* get buddy icon hovered from statusbox widget */
GdkPixbuf * get_buddy_icon_hover()
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
const PidginStatusBox *statusbox = PIDGIN_STATUS_BOX(blist->statusbox);
return statusbox->buddy_icon_hover;
}
/* create purple protocol icon from protocol info */
GdkPixbuf * create_prpl_icon_from_info(PurplePluginProtocolInfo *prpl_info,
PidginPrplIconSize size)
{
const char *protoname = NULL;
char *tmp;
char *filename = NULL;
GdkPixbuf *pixbuf;
if (prpl_info->list_icon == NULL)
return NULL;
protoname = prpl_info->list_icon(NULL, NULL);
if (protoname == NULL)
return NULL;
/*
* Status icons will be themeable too, and then it will look up
* protoname from the theme
*/
tmp = g_strconcat(protoname, ".png", NULL);
filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols",
size == PIDGIN_PRPL_ICON_SMALL ? "16" :
size == PIDGIN_PRPL_ICON_MEDIUM ? "22" : "48",
tmp, NULL);
g_free(tmp);
pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
g_free(filename);
return pixbuf;
}
/* get current status stock id */
const gchar * get_status_stock_id()
{
const PurpleSavedStatus *status = purple_savedstatus_get_current();
PurpleStatusPrimitive prim = purple_savedstatus_get_type(status);
return pidgin_stock_id_from_status_primitive(prim);
}
/* get mood icon path */
gchar * get_mood_icon_path(const gchar *mood)
{
gchar *path;
if(!mood || !strcmp(mood, ""))
path = g_build_filename(DATADIR, "pixmaps", "pidgin",
"toolbar", "16", "emote-select.png", NULL);
else if(!strcmp(mood, "busy"))
path = g_build_filename(DATADIR, "pixmaps", "pidgin",
"status", "16", "busy.png", NULL);
else if(!strcmp(mood, "hiptop"))
path = g_build_filename(DATADIR, "pixmaps", "pidgin",
"emblems", "16", "hiptop.png", NULL);
else {
gchar *filename = g_strdup_printf("%s.png", mood);
path = g_build_filename(DATADIR, "pixmaps", "pidgin",
"emotes", "small", filename, NULL);
g_free(filename);
}
return path;
}
/* get available attributes for a protocol
returned hashtable should be freed manually */
GHashTable * get_protocol_attrs(PurplePluginProtocolInfo *protocol)
{
if(!protocol->status_types)
return NULL;
GHashTable *attrs = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
GList *l = protocol->status_types(NULL);
for(; l ; l = l->next) {
PurpleStatusType *type = (PurpleStatusType *)l->data;
GList *k = purple_status_type_get_attrs(type);
for(; k ; k = k->next) {
struct _PurpleStatusAttr {
char *id;
char *name;
PurpleValue *value_type;
};
struct _PurpleStatusAttr *attr = (struct _PurpleStatusAttr *)k->data;
if(g_hash_table_lookup(attrs, attr->id))
continue;
else
g_hash_table_insert(attrs, (gpointer)attr->id,
GINT_TO_POINTER(TRUE));
}
}
return attrs;
}
/* get available attributes for an account
returned hashtable should be freed manally */
/* TODO: review this, now it does the same as get_protocol_attrs... */
GHashTable * get_account_attrs(PurpleAccount *account)
{
GHashTable *attrs = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
GList *l = purple_account_get_status_types(account);
for(; l ; l = l->next) {
PurpleStatusType *type = (PurpleStatusType *)l->data;
GList *k = purple_status_type_get_attrs(type);
for(; k ; k = k->next) {
struct _PurpleStatusAttr {
char *id;
char *name;
PurpleValue *value_type;
};
struct _PurpleStatusAttr *attr = (struct _PurpleStatusAttr *)k->data;
if(g_hash_table_lookup(attrs, attr->id))
continue;
else
g_hash_table_insert(attrs, (gpointer)attr->id,
GINT_TO_POINTER(TRUE));
}
}
return attrs;
}
/* get global moods */
PurpleMood * get_global_moods()
{
GHashTable *global_moods = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
GHashTable *mood_counts = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
GList *accounts = purple_accounts_get_all_active();
PurpleMood *result = NULL;
GList *out_moods = NULL;
int i = 0;
int num_accounts = 0;
for(; accounts ; accounts = g_list_delete_link(accounts, accounts)) {
PurpleAccount *account = (PurpleAccount *)accounts->data;
if(purple_account_is_connected(account)) {
PurpleConnection *gc = purple_account_get_connection(account);
if(gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS) {
PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(
gc->prpl);
PurpleMood *mood = NULL;
for(mood = prpl_info->get_moods(account) ;
mood->mood ; mood++) {
int mood_count = GPOINTER_TO_INT(g_hash_table_lookup(mood_counts,
mood->mood));
if(!g_hash_table_lookup(global_moods, mood->mood))
g_hash_table_insert(global_moods, (gpointer)mood->mood, mood);
g_hash_table_insert(mood_counts, (gpointer)mood->mood,
GINT_TO_POINTER(mood_count + 1));
}
num_accounts++;
}
}
}
g_hash_table_foreach(global_moods, cb_global_moods_for_each, &out_moods);
result = g_new0(PurpleMood, g_hash_table_size(global_moods) + 1);
while(out_moods) {
PurpleMood *mood = (PurpleMood *)out_moods->data;
int in_num_accounts = GPOINTER_TO_INT(g_hash_table_lookup(mood_counts,
mood->mood));
if(in_num_accounts == num_accounts) {
/* mood is present in all accounts supporting moods */
result[i].mood = mood->mood;
result[i].description = mood->description;
i++;
}
out_moods = g_list_delete_link(out_moods, out_moods);
}
g_hash_table_destroy(global_moods);
g_hash_table_destroy(mood_counts);
return result;
}
/* set status to the specified mood */
void set_status_with_mood(PurpleAccount *account, const gchar *mood)
{
purple_account_set_status(account, "mood", TRUE, PURPLE_MOOD_NAME, mood,
NULL);
}
/* set status to the specified mood for all accounts */
void set_status_with_mood_all(const gchar *mood)
{
GList *accts = purple_accounts_get_all_active();
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = (PurpleAccount *)accts->data;
PurpleConnection *gc = purple_account_get_connection(account);
if(gc && gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS)
set_status_with_mood(account, mood);
}
}
/* set exclusive status for all accounts */
void set_status_all(const gchar *status_id, GList *attrs)
{
GList *accts = purple_accounts_get_all_active();
/* empty list means we have nothing to do */
if(!attrs)
return;
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = accts->data;
if(!purple_account_is_connected(account))
continue;
purple_account_set_status_list(account, status_id, TRUE, attrs);
}
}
/* set display name for account */
void set_display_name(PurpleAccount *account, const gchar *name)
{
const gchar *id = purple_account_get_protocol_id(account);
/* exception for set_public_alias */
if(!strcmp(id, "prpl-jabber")) {
PurpleConnection *gc = account->gc;
gchar *iq_id = g_strdup_printf("purple%x", g_random_int());
xmlnode *iq, *pubsub, *publish, *nicknode;
gc = account->gc;
iq_id = g_strdup_printf("purple%x", g_random_int());
iq = xmlnode_new("iq");
xmlnode_set_attrib(iq, "type", "set");
xmlnode_set_attrib(iq, "id", iq_id);
pubsub = xmlnode_new("pubsub");
xmlnode_set_attrib(pubsub, "xmlns", "http://jabber.org/protocol/pubsub");
publish = xmlnode_new("publish");
xmlnode_set_attrib(publish,"node","http://jabber.org/protocol/nick");
nicknode = xmlnode_new_child(xmlnode_new_child(publish, "item"), "nick");
xmlnode_set_namespace(nicknode, "http://jabber.org/protocol/nick");
xmlnode_insert_data(nicknode, name, -1);
xmlnode_insert_child(pubsub, publish);
xmlnode_insert_child(iq, pubsub);
purple_signal_emit(purple_connection_get_prpl(gc),
"jabber-sending-xmlnode", gc, &iq);
g_free(iq_id);
}
else
/* provide dummy callback since some
protocols don't check before calling */
purple_account_set_public_alias(account, name, cb_dummy,
cb_set_alias_failure);
}
/* set display name for all connected accounts */
void set_display_name_all(const char *name)
{
GList *accts = purple_accounts_get_all_active();
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = accts->data;
if(!purple_account_is_connected(account))
continue;
set_display_name(account, name);
}
}
/* set status message (personal message) */
void set_status_message(const gchar *pm)
{
PurpleSavedStatus *status = purple_savedstatus_get_current();
purple_savedstatus_set_message(status, pm);
purple_savedstatus_activate(status);
}
void prpl_connect_signals(struct pbar_widget *w,
const struct pbar_prpl_signal *sig_list,
gpointer data)
{
const struct pbar_prpl_signal *s = sig_list;
for(; s->signal ; s++)
purple_signal_connect(s->instance,
s->signal,
w,
PURPLE_CALLBACK(s->callback),
data);
}
void prpl_prefs_connect_signals(struct pbar_widget *w,
const struct pbar_prpl_signal *sig_list,
gpointer data)
{
const struct pbar_prpl_signal *s = sig_list;
for(; s->signal ; s++)
purple_prefs_connect_callback(s->instance,
s->signal,
PURPLE_PREFS_CALLBACK(s->callback),
data);
}
void prpl_disconnect_signals(struct pbar_widget *w)
{ purple_signals_disconnect_by_handle(w); }
void prpl_prefs_disconnect_signals(struct pbar_widget *w)
{ purple_prefs_disconnect_by_handle(w); }
static void cb_global_moods_for_each(gpointer key, gpointer value,
gpointer user_data)
{
GList **out_moods = (GList **)user_data;
PurpleMood *mood = (PurpleMood *)value;
*out_moods = g_list_append(*out_moods, mood);
}
static void cb_set_alias_failure(PurpleAccount *account, const char *error)
{
const gchar *id = purple_account_get_protocol_id(account);
purple_debug_info(NAME, "aliases not supported by \"%s\"\n", id);
}
static void cb_dummy() {}
diff --git a/purple.h b/purple.h
index 9fdead9..4613dda 100644
--- a/purple.h
+++ b/purple.h
@@ -1,65 +1,65 @@
/* File: purple.h
Time-stamp: <2011-02-10 17:54:53 gawen>
- Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _PURPLE_H_
#define _PURPLE_H_
#include "common.h"
#include "gtk.h"
struct pbar_prpl_signal {
void *instance;
const char *signal;
void *callback;
};
/* not sure purple define that */
#ifndef PURPLE_PREFS_CALLBACK
# define PURPLE_PREFS_CALLBACK(func) ((PurplePrefCallback)func)
#endif
gboolean is_gtk_blist_created();
GdkPixbuf * create_prpl_icon_from_info(PurplePluginProtocolInfo *prpl_info,
PidginPrplIconSize size);
GdkPixbuf * get_buddy_icon();
GdkPixbuf * get_buddy_icon_hover();
GHashTable * get_protocol_attrs(PurplePluginProtocolInfo *protocol);
GHashTable * get_account_attrs(PurpleAccount *account);
const gchar * get_status_stock_id();
gchar * get_mood_icon_path();
PurpleMood * get_global_moods();
void set_status_message(const gchar *pm);
void set_status_all(const gchar *status_id, GList *attrs);
void set_status_with_mood(PurpleAccount *account, const gchar *mood);
void set_status_with_mood_all(const gchar *mood);
void set_display_name(PurpleAccount *account, const gchar *name);
void set_display_name_all(const gchar *name);
void prpl_disconnect_signals(struct pbar_widget *w);
void prpl_prefs_disconnect_signals(struct pbar_widget *w);
void prpl_connect_signals(struct pbar_widget *w,
const struct pbar_prpl_signal *sig_list,
gpointer data);
void prpl_prefs_connect_signals(struct pbar_widget *w,
const struct pbar_prpl_signal *sig_list,
gpointer data);
#endif /* _PURPLE_H_ */
diff --git a/status_dialog.c b/status_dialog.c
index 4da9436..812660f 100644
--- a/status_dialog.c
+++ b/status_dialog.c
@@ -1,225 +1,225 @@
/* File: status_dialog.c
Time-stamp: <2011-02-11 01:47:39 gawen>
- Copyright (C) 2011 David Hauweele <[email protected]>
+ Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "gtk.h"
#include "preferences.h"
#include "status_dialog.h"
static void cb_destroy_win(GtkWidget *widget, gpointer data);
static void cb_close_button(GtkWidget *widget, gpointer data);
static void cb_apply_button(GtkWidget *widget, gpointer date);
static void cb_refresh_button(GtkWidget *widget, gpointer data);
static void cb_row_activated(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data);
enum {
STATUSICON_COLUMN,
STATUS_COLUMN,
N_COLUMN
};
static void cb_destroy_win(GtkWidget *widget, gpointer data)
{ destroy_status_dialog((struct status_dialog *)data); }
static void cb_row_activated(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data)
{ cb_apply_button(widget, data); }
static void cb_apply_button(GtkWidget *widget, gpointer data)
{
GtkTreeModel *model;
GtkTreeIter iter;
GtkTreeSelection *sel;
struct status_dialog *s_diag = (struct status_dialog *)data;
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(s_diag->list_view));
if(gtk_tree_selection_get_selected(sel, &model, &iter)) {
PurpleStatusType *type;
gchar *name;
gtk_tree_model_get(model, &iter, STATUS_COLUMN, &name, -1);
type = g_hash_table_lookup(s_diag->global_status, name);
if(type) { /* status type found */
destroy_status_dialog(s_diag); /* destroy dialog first */
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
PurpleStatusPrimitive prim = purple_status_type_get_primitive(type);
PurpleSavedStatus *status = purple_savedstatus_get_current();
purple_savedstatus_set_type(status, prim);
purple_savedstatus_set_message(status, pm);
purple_savedstatus_activate(status);
purple_debug_info(NAME, "status changed to \"%s\" by user\n",
purple_status_type_get_name(type));
} else
purple_debug_info(NAME, "selected status \"%s\" doesn't exists\n", name);
g_free(name);
} else
purple_debug_info(NAME, "no row selected\n");
}
static void cb_close_button(GtkWidget *widget, gpointer data)
{ destroy_status_dialog((struct status_dialog *)data); }
static void cb_refresh_button(GtkWidget *widget, gpointer data)
{
struct status_dialog *s_diag = (struct status_dialog *)data;
gtk_list_store_clear(s_diag->list_store);
init_status_dialog(s_diag);
}
struct status_dialog * create_status_dialog()
{
struct status_dialog *s_diag = g_malloc(sizeof(struct status_dialog));
memset(s_diag, 0, sizeof(struct status_dialog));
/* widgets that can be modifier along dialog lifetime */
s_diag->window = pidgin_create_dialog(_("Status selection"),
PIDGIN_HIG_BORDER,
"status-select",
TRUE);
s_diag->list_store = gtk_list_store_new(N_COLUMN,
GDK_TYPE_PIXBUF, /* STATUSICON */
G_TYPE_STRING /* STATUS */ );
s_diag->list_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
s_diag->list_store));
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(s_diag), s_diag->window);
/* widgets that are not modified */
GtkWidget *pbox = gtk_pidgin_dialog_box_new(_("Select your status..."),
_("This will change your current"
" status for every account"
" which supports it."),
PIDGIN_STOCK_DIALOG_QUESTION);
GtkWidget *vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(
s_diag->window),
FALSE,
PIDGIN_HIG_BORDER);
GtkWidget *hbox = pidgin_dialog_get_action_area(GTK_DIALOG(s_diag->window));
GtkWidget *refresh_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
GtkWidget *apply_button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
/* create view and model */
GtkTreeViewColumn *p_col = gtk_tree_view_column_new();
GtkCellRenderer *p_renderer;
gtk_tree_view_column_set_title(p_col, _("Status"));
gtk_tree_view_append_column(GTK_TREE_VIEW(s_diag->list_view), p_col);
p_renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, FALSE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"pixbuf", STATUSICON_COLUMN);
p_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, TRUE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"text", STATUS_COLUMN);
/* pack widgets */
gtk_box_pack_start(GTK_BOX(hbox), refresh_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), apply_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), pbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), s_diag->list_view, TRUE, TRUE, 0);
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ s_diag->window, "destroy", cb_destroy_win },
{ s_diag->list_view, "row-activated", PBAR_GTK_CALLBACK(cb_row_activated) },
{ refresh_button, "clicked", cb_refresh_button },
{ apply_button, "clicked", cb_apply_button },
{ close_button, "clicked", cb_close_button },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(s_diag), g_signal_connections, s_diag);
/* show everything */
gtk_widget_show_all(s_diag->window);
gtk_window_present(GTK_WINDOW(s_diag->window));
return s_diag;
}
void destroy_status_dialog(struct status_dialog *s_diag)
{
gtk_destroy(PBAR_WIDGET(s_diag)); /* destroy widgets */
g_hash_table_destroy(s_diag->global_status); /* free global status */
g_free(s_diag); /* free dialog */
}
void init_status_dialog(struct status_dialog *s_diag)
{
GList *a = purple_accounts_get_all_active();
GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
if(!s_diag->global_status)
s_diag->global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
for(; a ; a = g_list_delete_link(a, a)) {
PurpleAccount *acct = (PurpleAccount *)a->data;
GList *types = purple_account_get_status_types(acct);
for(; types ; types = types->next) {
GtkTreeIter iter;
GdkPixbuf *icon;
PurpleStatusType *type = (PurpleStatusType *)types->data;
PurpleStatusPrimitive prim;
const gchar *stock, *status_name;
if(!purple_status_type_is_user_settable(type) ||
purple_status_type_is_independent(type))
continue;
prim = purple_status_type_get_primitive(type);
stock = pidgin_stock_id_from_status_primitive(prim);
if(g_hash_table_lookup(global_status, stock))
continue;
else
g_hash_table_insert(global_status, (gpointer)stock,
GINT_TO_POINTER(TRUE));
status_name = purple_status_type_get_name(type);
icon = gtk_widget_render_icon(s_diag->window, stock,
GTK_ICON_SIZE_MENU, NULL);
g_hash_table_insert(s_diag->global_status, (gpointer)_(status_name),
type);
gtk_list_store_append(s_diag->list_store, &iter);
gtk_list_store_set(s_diag->list_store, &iter,
STATUSICON_COLUMN, icon,
STATUS_COLUMN, status_name,
-1);
}
}
g_hash_table_destroy(global_status);
}
diff --git a/status_dialog.h b/status_dialog.h
index 965f948..65ee042 100644
--- a/status_dialog.h
+++ b/status_dialog.h
@@ -1,42 +1,42 @@
/* File: status_dialog.h
Time-stamp: <2011-02-10 15:42:51 gawen>
- Copyright (C) 2011 David Hauweele <[email protected]>
+ Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _STATUS_DIALOG_H_
#define _STATUS_DIALOG_H_
#include "common.h"
#include "gtk.h"
struct status_dialog {
BEGIN_PBAR_WIDGET;
/* window and list */
GtkWidget *window;
GtkWidget *list_view;
GtkListStore *list_store;
/* global status for selection */
GHashTable *global_status;
};
struct status_dialog * create_status_dialog();
void destroy_status_dialog(struct status_dialog *s_diag);
void init_status_dialog(struct status_dialog *s_diag);
#endif /* _STATUS_DIALOG_H_ */
diff --git a/widget.c b/widget.c
index 4371207..4fdd82d 100644
--- a/widget.c
+++ b/widget.c
@@ -1,516 +1,516 @@
/* File: widget.c
Time-stamp: <2011-02-08 19:42:07 gawen>
- Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "pbar.h"
#include "widget.h"
#include "widget_gtk.h"
#include "widget_prpl.h"
#include "preferences.h"
#include "purple.h"
#include "gtk.h"
/* we only have one widget per plugin
but this might change in the future */
struct widget *bar;
void create_widget()
{
/* this should occurs only once but
this way way we avoid memory leaks */
if(!bar)
bar = g_malloc(sizeof(struct widget));
memset(bar, 0, sizeof(struct widget));
/* widgets that can possibly be modified along plugin's execution */
bar->icon = gtk_image_new();
bar->status = gtk_button_new_from_stock(NULL);
bar->mood = gtk_button_new_from_stock(NULL);
bar->name_label = gtk_label_new(NULL);
bar->name_eventbox = gtk_event_box_new();
bar->name_entry = gtk_entry_new();
bar->pm_label = gtk_label_new(NULL);
bar->pm_eventbox = gtk_event_box_new();
bar->pm_entry = gtk_entry_new();
bar->hbox = gtk_hbox_new(FALSE, 2);
bar->icon_eventbox = gtk_event_box_new();
bar->status_menu = gtk_menu_new();
bar->mood_menu = gtk_menu_new();
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(bar), bar->hbox);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->status_menu);
gtk_add_main_widget(PBAR_WIDGET(bar), bar->mood_menu);
/* widgets that are not modified */
GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
GtkWidget *hbox1 = gtk_hbox_new(FALSE, 2);
GtkWidget *hbox2 = gtk_hbox_new(FALSE, 2);
/* setup widgets */
gtk_label_set_ellipsize(GTK_LABEL(bar->name_label), PANGO_ELLIPSIZE_END);
gtk_label_set_ellipsize(GTK_LABEL(bar->pm_label), PANGO_ELLIPSIZE_END);
gtk_label_set_max_width_chars(GTK_LABEL(bar->name_label), 50);
gtk_button_set_relief(GTK_BUTTON(bar->status), GTK_RELIEF_NONE);
gtk_button_set_relief(GTK_BUTTON(bar->mood), GTK_RELIEF_NONE);
gtk_widget_set_can_focus(bar->name_eventbox, FALSE);
gtk_widget_set_can_focus(bar->pm_eventbox, FALSE);
gtk_widget_set_can_focus(bar->status, FALSE);
gtk_widget_set_can_focus(bar->mood, FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->icon_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->name_eventbox), FALSE);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->pm_eventbox), FALSE);
/* pack widgets */
gtk_container_add(GTK_CONTAINER(bar->name_eventbox), bar->name_label);
gtk_container_add(GTK_CONTAINER(bar->pm_eventbox), bar->pm_label);
gtk_container_add(GTK_CONTAINER(bar->icon_eventbox), bar->icon);
if(purple_prefs_get_bool(PREF "/compact")) {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
}
else {
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_eventbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), bar->mood, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0);
}
gtk_box_pack_start(GTK_BOX(bar->hbox), bar->icon_eventbox, FALSE, FALSE, 5);
gtk_box_pack_start(GTK_BOX(bar->hbox), vbox, TRUE, TRUE, 0);
/* pack at top of the buddy list and fallback to top
if the position option is unknown */
void (*gtk_box_pack)(GtkBox *, GtkWidget *, gboolean, gboolean, guint) = gtk_box_pack_start;
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
switch(purple_prefs_get_int(PREF "/widget-position")) {
case(POSITION_TOP):
gtk_box_pack = gtk_box_pack_start;
break;
case(POSITION_BOTTOM):
gtk_box_pack = gtk_box_pack_end;
break;
};
gtk_box_pack(GTK_BOX(blist->vbox), bar->hbox, FALSE, TRUE, 2);
gtk_box_reorder_child(GTK_BOX(blist->vbox), bar->hbox, 0);
/* setup initial states */
bar->gtk_hnd = NULL;
bar->gtk_inst = NULL;
bar->hover_name = FALSE;
bar->hover_pm = FALSE;
bar->name_entry_activated = FALSE;
bar->pm_entry_activated = FALSE;
bar->name_dialog = FALSE;
bar->pm_dialog = FALSE;
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ bar->icon_eventbox, "button-press-event", cb_buddy_icon },
{ bar->icon_eventbox, "enter-notify-event", cb_buddy_icon_enter },
{ bar->icon_eventbox, "leave-notify-event", cb_buddy_icon_leave },
{ bar->name_eventbox, "button-press-event", cb_name },
{ bar->name_eventbox, "enter-notify-event", cb_name_enter },
{ bar->name_eventbox, "leave-notify-event", cb_name_leave },
{ bar->name_entry, "activate", cb_name_entry },
{ bar->name_entry, "focus-out-event", cb_name_entry_focus_out },
{ bar->pm_eventbox, "button-press-event", cb_pm },
{ bar->pm_eventbox, "enter-notify-event", cb_pm_enter },
{ bar->pm_eventbox, "leave-notify-event", cb_pm_leave },
{ bar->pm_entry, "activate", cb_pm_entry },
{ bar->pm_entry, "focus-out-event", cb_pm_entry_focus_out },
{ bar->status, "clicked", cb_status_button },
{ bar->mood, "clicked", cb_mood_button },
{ NULL, NULL, NULL }
};
/* purple signals and callback */
const struct pbar_prpl_signal p_signal_connections[] = {
{ purple_accounts_get_handle(), "account-status-changed", cb_status },
{ purple_connections_get_handle(), "signed-on", cb_signed_on },
{ NULL, NULL, NULL }
};
/* purple preferences signals and callback */
const struct pbar_prpl_signal pp_signal_connections[] = {
{ bar, PIDGIN_PREFS_ROOT "/accounts/buddyicon", cb_buddy_icon_update },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(bar), g_signal_connections, NULL);
prpl_connect_signals(PBAR_WIDGET(bar), p_signal_connections, NULL);
prpl_prefs_connect_signals(PBAR_WIDGET(bar), pp_signal_connections, NULL);
/* show everything */
gtk_widget_show_all(bar->hbox);
gtk_widget_hide(bar->name_entry);
gtk_widget_hide(bar->pm_entry);
/* inform that the bar is installed */
bar->installed = TRUE;
}
void destroy_widget()
{
g_return_if_fail(bar->installed);
bar->installed = FALSE;
/* disconnect purple and prefs signals */
prpl_disconnect_signals(PBAR_WIDGET(bar));
prpl_prefs_disconnect_signals(PBAR_WIDGET(bar));
gtk_destroy(PBAR_WIDGET(bar)); /* destroy widgets */
g_free(bar); /* free widget */
bar = NULL;
}
/* load preferences into our widget */
void init_widget()
{
g_return_if_fail(bar->installed);
/* entry frame */
gboolean state = purple_prefs_get_bool(PREF "/frame-entry");
set_widget_entry_frame(state);
/* nickname */
const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup");
const gchar *value = purple_prefs_get_string(PREF "/nickname");
int jtype = purple_prefs_get_int(PREF "/nickname-justify");
set_widget_name(markup, value);
set_widget_name_justify(jtype);
/* personal message */
markup = purple_prefs_get_string(PREF "/personal-message-markup");
value = purple_prefs_get_string(PREF "/personal-message");
jtype = purple_prefs_get_int(PREF "/personal-message-justify");
set_widget_pm(markup, value);
set_widget_pm_justify(jtype);
/* buddy icon */
GdkPixbuf *icon = get_buddy_icon();
set_widget_icon(icon);
/* mood image */
const gchar *current_mood = purple_prefs_get_string(PREF "/mood");
gchar *path = get_mood_icon_path(current_mood);
set_widget_mood(path);
g_free(path);
/* status image */
const gchar *stock = get_status_stock_id();
set_widget_status(stock);
/* fill status menu */
GList *accts = purple_accounts_get_all_active();
GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = (PurpleAccount *)accts->data;
GList *types = purple_account_get_status_types(account);
for(; types ; types = types->next) {
PurpleStatusType *type = (PurpleStatusType *)types->data;
PurpleStatusPrimitive prim;
const gchar *stock, *status_name;
GtkWidget *menu_item, *icon;
if(!purple_status_type_is_user_settable(type) ||
purple_status_type_is_independent(type))
continue;
prim = purple_status_type_get_primitive(type);
stock = pidgin_stock_id_from_status_primitive(prim);
if(g_hash_table_lookup(global_status, stock))
continue;
else
g_hash_table_insert(global_status, (gpointer)stock,
GINT_TO_POINTER(TRUE));
status_name = purple_status_type_get_name(type);
menu_item = gtk_image_menu_item_new_with_label(status_name);
icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), icon);
gtk_menu_shell_append(GTK_MENU_SHELL(bar->status_menu), menu_item);
g_signal_connect_swapped(menu_item, "activate",
G_CALLBACK(cb_status_menu),
(gpointer)type);
gtk_widget_show(menu_item);
}
}
g_hash_table_destroy(global_status);
/* statusbox hiding */
state = purple_prefs_get_bool(PREF "/hide-statusbox");
set_statusbox_visible(!state);
}
/* create a change name dialog */
void create_name_dialog()
{
const gchar *name = purple_prefs_get_string(PREF "/nickname");
if(!name || !strcmp(name, EMPTY_NAME))
name = "";
purple_request_input(thisplugin,
_("Change nickname"),
_("Enter your nickname here..."),
_("This will change your nickname "
"for every account which supports it."),
name,
FALSE,
FALSE,
NULL,
_("OK"),
G_CALLBACK(cb_name_apply),
_("Cancel"),
G_CALLBACK(cb_name_cancel),
NULL,
NULL,
NULL,
NULL);
bar->name_dialog = TRUE;
}
/* create a personal message dialog */
void create_pm_dialog()
{
PurpleRequestFields *fields;
PurpleRequestFieldGroup *group;
PurpleRequestField *field;
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
if(!pm || !strcmp(pm, EMPTY_PM))
pm = "";
const struct s_field {
const gchar *text;
const gchar *pref;
} groups[] = {
{ N_("_Mood message"), PREF "/mood-message" },
{ N_("Current song"), NULL },
{ N_("Song _title"), PREF "/tune-title" },
{ N_("Song _artist"), PREF "/tune-artist" },
{ N_("Song al_bum"), PREF "/tune-album" },
{ N_("MSN pecan extra attributes"), NULL },
{ N_("_Game name"), PREF "/game-message" },
{ N_("_Office app name"), PREF "/office-message" },
{ NULL, NULL },
{ NULL, NULL }
}; const struct s_field *g = groups;
fields = purple_request_fields_new();
group = purple_request_field_group_new(_("Status and mood message"));
purple_request_fields_add_group(fields, group);
field = purple_request_field_string_new(PREF "/personal-message",
_("_Personal message"),
pm,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
for(; g->pref ; g++) {
for(; g->pref ; g++) {
const gchar *message;
if(purple_prefs_get_bool(PREF "/reset-attrs"))
message = "";
else
message = purple_prefs_get_string(g->pref);
field = purple_request_field_string_new(g->pref,
_(g->text),
message,
FALSE);
purple_request_field_set_required(field, FALSE);
purple_request_field_group_add_field(group, field);
}
group = purple_request_field_group_new(_(g->text));
purple_request_fields_add_group(fields, group);
}
purple_request_fields(thisplugin,
_("Change status messages"),
_("Enter status message..."),
_("This will change some status messages for every "
"account which supports it, please be advised "
"that some are inconsistent between each other."),
fields,
_("OK"),
G_CALLBACK(cb_pm_apply),
_("Cancel"),
G_CALLBACK(cb_pm_cancel),
NULL, NULL, NULL, NULL);
bar->pm_dialog = TRUE;
}
/* replace format character <c><r> with <n> string and escape with <c><c> */
static gchar * g_strreplacefmt(const gchar *s, gchar c, gchar r, const gchar *n)
{
int sn = strlen(n);
int sr = strlen(s);
int index = 0;
gchar *ret = g_malloc(sr);
for(; *s != '\0' ; s++) {
if(*s == c) {
s++;
if(*s == r) {
const gchar *i = n;
sr += sn;
ret = g_realloc(ret, sr);
for(; *i != '\0' ; i++, index++)
ret[index] = *i;
continue;
}
else if(*s != c || *s == '\0')
s--;
}
ret[index] = *s;
index++;
}
ret[index] = '\0';
return ret;
}
void set_widget_name(const gchar *markup, const gchar *name)
{
g_return_if_fail(markup && name && bar->installed);
gchar *escaped_name, *new;
/* translate name if needed */
if(!strcmp(name, EMPTY_NAME))
name = _(EMPTY_NAME);
escaped_name = g_markup_printf_escaped("%s", name);
new = g_strreplacefmt(markup, '%', 'n', escaped_name);
g_free(escaped_name);
gtk_label_set_markup(GTK_LABEL(bar->name_label), new);
g_free(new);
}
void set_widget_pm(const gchar *markup, const gchar *pm)
{
g_return_if_fail(markup && pm && bar->installed);
gchar *escaped_pm, *new;
/* translate pm if needed */
if(!strcmp(pm, EMPTY_PM))
pm = _(EMPTY_PM);
escaped_pm = g_markup_printf_escaped("%s", pm);
new = g_strreplacefmt(markup, '%', 'p', escaped_pm);
g_free(escaped_pm);
gtk_label_set_markup(GTK_LABEL(bar->pm_label), new);
g_free(new);
}
void set_widget_status(const gchar *stock)
{
g_return_if_fail(stock && bar->installed);
GtkWidget *icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
gtk_button_set_image(GTK_BUTTON(bar->status), icon);
gtk_button_set_label(GTK_BUTTON(bar->status), "");
}
void set_widget_mood(const gchar *path)
{
g_return_if_fail(path && bar->installed);
GtkWidget *mood = gtk_image_new_from_file(path);
gtk_button_set_image(GTK_BUTTON(bar->mood), mood);
gtk_button_set_label(GTK_BUTTON(bar->mood), "");
}
void set_widget_icon(GdkPixbuf *icon)
{
g_return_if_fail(bar->installed);
if(icon)
gtk_image_set_from_pixbuf(GTK_IMAGE(bar->icon), icon);
else
gtk_image_set_from_stock(GTK_IMAGE(bar->icon), GTK_STOCK_MISSING_IMAGE, 48);
}
/* convertion of int justification
to float justification for
gtk_misc_set_alignment */
static float int_jtype_to_float_jtype(int justify)
{
float ret = 0.; /* default to left */
switch(justify) {
case(JUSTIFY_LEFT):
ret = 0.;
break;
case(JUSTIFY_CENTER):
ret = .5;
break;
case(JUSTIFY_RIGHT):
ret = 1.;
break;
}
return ret;
}
void set_widget_name_justify(int justify)
{
g_return_if_fail(bar->installed);
float jtype = int_jtype_to_float_jtype(justify);
gtk_misc_set_alignment(GTK_MISC(bar->name_label), jtype, .5);
}
void set_widget_pm_justify(int justify)
{
g_return_if_fail(bar->installed);
float jtype = int_jtype_to_float_jtype(justify);
gtk_misc_set_alignment(GTK_MISC(bar->pm_label), jtype, .5);
}
void set_widget_entry_frame(gboolean use_frame)
diff --git a/widget.h b/widget.h
index c2f1f8e..8e6f627 100644
--- a/widget.h
+++ b/widget.h
@@ -1,86 +1,86 @@
/* File: widget.h
Time-stamp: <2011-02-08 19:39:51 gawen>
- Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _WIDGET_H_
#define _WIDGET_H_
#include "common.h"
#include "gtk.h"
struct widget {
BEGIN_PBAR_WIDGET;
/* icon and status */
GtkWidget *icon;
GtkWidget *icon_eventbox;
GtkWidget *status;
GtkWidget *status_menu;
/* mood */
GtkWidget *mood;
GtkWidget *mood_menu;
/* nickname */
GtkWidget *name_label;
GtkWidget *name_eventbox;
GtkWidget *name_entry;
/* personal message */
GtkWidget *pm_label;
GtkWidget *pm_eventbox;
GtkWidget *pm_entry;
GtkWidget *hbox; /* contains the widget */
gboolean installed; /* widget installed or not */
gboolean hover_name; /* name hovered or not */
gboolean hover_pm; /* pm hovered or not */
/* avoid setting status and name twice
with focus-out-event */
gboolean name_entry_activated;
gboolean pm_entry_activated;
/* avoid activating entry with dialog */
gboolean name_dialog;
gboolean pm_dialog;
};
extern struct widget *bar;
void create_widget();
void destroy_widget();
void init_widget();
void create_name_dialog();
void create_pm_dialog();
void set_widget_name(const gchar *markup, const gchar *name);
void set_widget_pm(const gchar *markup, const gchar *pm);
void set_widget_status(const gchar *stock);
void set_widget_mood(const gchar *path);
void set_widget_icon(GdkPixbuf *icon);
void set_widget_name_justify(int justify);
void set_widget_pm_justify(int justify);
void set_widget_entry_frame(gboolean use_frame);
void set_statusbox_visible(gboolean visible);
gboolean get_widget_name_hover_state();
gboolean get_widget_pm_hover_state();
#endif /* _WIDGET_H_ */
diff --git a/widget_gtk.c b/widget_gtk.c
index 593be72..cb2f629 100644
--- a/widget_gtk.c
+++ b/widget_gtk.c
@@ -1,324 +1,324 @@
/* File: widget_gtk.c
Time-stamp: <2011-02-10 17:54:23 gawen>
- Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "preferences.h"
#include "widget_prpl.h"
#include "widget_gtk.h"
#include "widget.h"
#include "purple.h"
static void cb_icon_choose(const gchar *path, gpointer data)
{
g_return_if_fail(path);
purple_prefs_set_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon", path);
}
void cb_buddy_icon(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
GtkWidget *chooser = pidgin_buddy_icon_chooser_new(GTK_WINDOW
(gtk_widget_get_toplevel
(GTK_WIDGET(blist))),
cb_icon_choose,
NULL);
gtk_widget_show(chooser);
}
void cb_buddy_icon_enter(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
GdkPixbuf *icon = get_buddy_icon_hover();
set_widget_icon(icon);
pidgin_set_cursor(bar->icon_eventbox, GDK_HAND2);
}
void cb_buddy_icon_leave(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
GdkPixbuf *icon = get_buddy_icon();
set_widget_icon(icon);
pidgin_clear_cursor(bar->icon_eventbox);
}
void cb_name(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *name = purple_prefs_get_string(PREF "/nickname");
GdkEventButton *event = (GdkEventButton *)gtk_get_current_event();
gboolean swap = (event->button == 1);
swap = purple_prefs_get_bool(PREF "/swap-click") ? !swap : swap;
if(!name || !strcmp(name, EMPTY_NAME))
name = "";
if(swap && !bar->name_dialog) {
gtk_entry_set_text(GTK_ENTRY(bar->name_entry), name);
if(purple_prefs_get_bool(PREF "/compact"))
gtk_widget_hide(bar->pm_eventbox);
gtk_widget_hide(bar->name_eventbox);
gtk_widget_show(bar->name_entry);
gtk_widget_grab_focus(bar->name_entry);
}
else if(!bar->name_dialog)
create_name_dialog();
}
void cb_name_enter(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup-hover");
const gchar *name = purple_prefs_get_string(PREF "/nickname");
bar->hover_name = TRUE;
set_widget_name(markup, name);
}
void cb_name_leave(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup");
const gchar *name = purple_prefs_get_string(PREF "/nickname");
bar->hover_name = FALSE;
set_widget_name(markup, name);
}
void cb_name_entry(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *name = gtk_entry_get_text(GTK_ENTRY(widget));
const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup");
set_widget_name(markup, name);
purple_prefs_set_string(PREF "/nickname", name);
set_display_name_all(name);
bar->name_entry_activated = TRUE;
if(purple_prefs_get_bool(PREF "/compact"))
gtk_widget_show(bar->pm_eventbox);
gtk_widget_hide(bar->name_entry);
gtk_widget_show(bar->name_eventbox);
purple_debug_info(NAME, "nickname changed to \"%s\" by user\n", name);
}
void cb_name_entry_focus_out(GtkWidget *widget, gpointer data)
{
if(!bar->name_entry_activated)
cb_name_entry(widget, data);
bar->name_entry_activated = FALSE;
}
void cb_pm(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
GdkEventButton *event = (GdkEventButton *)gtk_get_current_event();
gboolean swap = (event->button == 1);
swap = purple_prefs_get_bool(PREF "/swap-click") ? !swap : swap;
if(!pm || !strcmp(pm, EMPTY_PM))
pm = "";
if(swap && !bar->pm_dialog) {
gtk_entry_set_text(GTK_ENTRY(bar->pm_entry), pm);
if(purple_prefs_get_bool(PREF "/compact"))
gtk_widget_hide(bar->name_eventbox);
gtk_widget_hide(bar->pm_eventbox);
gtk_widget_show(bar->pm_entry);
gtk_widget_grab_focus(bar->pm_entry);
}
else if(!bar->pm_dialog)
create_pm_dialog();
}
void cb_pm_enter(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *markup = purple_prefs_get_string(PREF "/personal-message-markup-hover");
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
bar->hover_pm = TRUE;
set_widget_pm(markup, pm);
}
void cb_pm_leave(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *markup = purple_prefs_get_string(PREF "/personal-message-markup");
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
bar->hover_pm = FALSE;
set_widget_pm(markup, pm);
}
void cb_pm_entry(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *markup = purple_prefs_get_string(PREF "/personal-message-markup");
const gchar *pm = gtk_entry_get_text(GTK_ENTRY(widget));
purple_prefs_set_string(PREF "/personal-message", pm);
/* set personal message for all protocols */
set_status_message(pm);
set_widget_pm(markup, pm);
bar->pm_entry_activated = TRUE;
if(purple_prefs_get_bool(PREF "/compact"))
gtk_widget_show(bar->name_eventbox);
gtk_widget_hide(bar->pm_entry);
gtk_widget_show(bar->pm_eventbox);
purple_debug_info(NAME, "personal message changed to \"%s\" by user\n", pm);
}
void cb_pm_entry_focus_out(GtkWidget *widget, gpointer data)
{
if(!bar->pm_entry_activated)
cb_pm_entry(widget, data);
bar->pm_entry_activated = FALSE;
}
void cb_status_button(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
GdkEventButton *event = (GdkEventButton *)gtk_get_current_event();
gtk_menu_popup(GTK_MENU(bar->status_menu), NULL, NULL, NULL, NULL,
event->button, event->time);
}
void cb_status_menu(gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
PurpleStatusType *status_type = (PurpleStatusType *)data;
PurpleStatusPrimitive type_prim = purple_status_type_get_primitive(status_type);
PurpleSavedStatus *status = purple_savedstatus_get_current();
purple_savedstatus_set_type(status, type_prim);
purple_savedstatus_set_message(status, pm);
purple_savedstatus_activate(status);
purple_debug_info(NAME, "status changed to \"%s\" by user\n",
purple_status_type_get_name(status_type));
}
void cb_mood_button(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *empty_mood;
GtkWidget *menu_item, *icon;
PurpleMood *mood = get_global_moods();
GdkEventButton *event;
GList *l, *i;
gchar *path;
/* destroy dop down mood menu and create a new one */
l = gtk_container_get_children(GTK_CONTAINER(bar->mood_menu));
for(i = l ; i ; i = i->next) {
gtk_widget_destroy(l->data);
l->data = NULL;
}
gtk_widget_destroy(bar->mood_menu);
bar->mood_menu = gtk_menu_new();
/* add empty mood to mood menu */
empty_mood = "";
path = get_mood_icon_path(empty_mood);
icon = gtk_image_new_from_file(path);
menu_item = gtk_image_menu_item_new_with_label(_("None"));
g_free(path);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), icon);
gtk_menu_shell_append(GTK_MENU_SHELL(bar->mood_menu), menu_item);
g_signal_connect_swapped(menu_item, "activate",
G_CALLBACK(cb_mood_menu),
(gpointer)empty_mood);
gtk_widget_show(menu_item);
/* fill mood menu */
for( ; mood->mood ; mood++) {
if(!mood->mood || !mood->description)
continue;
path = get_mood_icon_path(mood->mood);
icon = gtk_image_new_from_file(path);
menu_item = gtk_image_menu_item_new_with_label(_(mood->description));
g_free(path);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), icon);
gtk_menu_shell_append(GTK_MENU_SHELL(bar->mood_menu), menu_item);
g_signal_connect_swapped(menu_item, "activate",
G_CALLBACK(cb_mood_menu),
(gpointer)mood->mood);
gtk_widget_show(menu_item);
}
event = (GdkEventButton *)gtk_get_current_event();
gtk_menu_popup(GTK_MENU(bar->mood_menu), NULL, NULL, NULL, NULL,
event->button, event->time);
}
void cb_mood_menu(gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *mood = (const gchar *)data;
gchar *path;
set_status_with_mood_all(mood);
purple_prefs_set_string(PREF "/mood", mood);
path = get_mood_icon_path(mood);
set_widget_mood(path);
g_free(path);
purple_debug_info(NAME, "mood changed to \"%s\" by user\n", mood);
}
diff --git a/widget_gtk.h b/widget_gtk.h
index b7d6fb2..e88cd2b 100644
--- a/widget_gtk.h
+++ b/widget_gtk.h
@@ -1,48 +1,48 @@
/* File: widget_gtk.h
Time-stamp: <2010-10-28 01:03:07 gawen>
- Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _WIDGET_GTK_H_
#define _WIDGET_GTK_H_
#include "common.h"
void cb_buddy_icon(GtkWidget *widget, gpointer data);
void cb_buddy_icon_enter(GtkWidget *widget, gpointer data);
void cb_buddy_icon_leave(GtkWidget *widget, gpointer data);
void cb_name(GtkWidget *widget, gpointer data);
void cb_name_enter(GtkWidget *widget, gpointer data);
void cb_name_leave(GtkWidget *widget, gpointer data);
void cb_name_entry(GtkWidget *widget, gpointer data);
void cb_name_entry_focus_out(GtkWidget *widget, gpointer data);
void cb_pm(GtkWidget *widget, gpointer data);
void cb_pm_enter(GtkWidget *widget, gpointer data);
void cb_pm_leave(GtkWidget *widget, gpointer data);
void cb_pm_entry(GtkWidget *widget, gpointer data);
void cb_pm_entry_focus_out(GtkWidget *widget, gpointer data);
void cb_status_button(GtkWidget *widget, gpointer data);
void cb_status_menu(gpointer data);
void cb_mood_button(GtkWidget *widget, gpointer data);
void cb_mood_menu(gpointer data);
#endif /* _WIDGET_GTK_H_ */
diff --git a/widget_prpl.c b/widget_prpl.c
index 0fcd0bf..6d9ea25 100644
--- a/widget_prpl.c
+++ b/widget_prpl.c
@@ -1,229 +1,229 @@
/* File: widget_prpl.c
Time-stamp: <2010-11-15 18:03:20 gawen>
- Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "preferences.h"
#include "widget.h"
#include "widget_prpl.h"
#include "purple.h"
void cb_status(PurpleAccount *account, PurpleStatus *old, PurpleStatus *new)
{
g_return_if_fail(bar->installed);
PurpleStatusPrimitive prim;
const gchar *stock, *pm;
PurpleSavedStatus *status = purple_savedstatus_get_current();
if(purple_prefs_get_bool(PREF "/override-status")) {
pm = purple_prefs_get_string(PREF "/personal-message");
purple_savedstatus_set_message(status,pm);
purple_savedstatus_activate(status);
}
else {
const gchar *markup;
markup = purple_prefs_get_string(PREF "/personal-message-markup");
pm = purple_savedstatus_get_message(status);
if(!pm)
pm = "";
set_widget_pm(markup, pm);
purple_prefs_set_string(PREF "/personal-message", pm);
}
prim = purple_savedstatus_get_type(status);
stock = pidgin_stock_id_from_status_primitive(prim);
set_widget_status(stock);
}
void cb_signed_on(PurpleConnection *gc)
{
const gchar *name = purple_prefs_get_string(PREF "/nickname");
PurpleAccount *account = purple_connection_get_account(gc);
set_display_name(account, name);
purple_debug_info(NAME, "nickname changed to \"%s\" by signed-on account\n",
name);
if(gc && gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS) {
const gchar *mood = purple_prefs_get_string(PREF "/mood");
set_status_with_mood(account, mood);
purple_debug_info(NAME, "mood changed to \"%s\" by signed-on account\n",
mood);
}
/* load tune and stuff */
GList *a_tune = NULL;
GList *a_mood = NULL;
const struct attrs {
const gchar *pref;
const gchar *attr;
GList **list;
} attrs[] = {
{ PREF "/mood-message", PURPLE_MOOD_COMMENT, &a_mood },
{ PREF "/tune-title", PURPLE_TUNE_TITLE, &a_tune },
{ PREF "/tune-artist", PURPLE_TUNE_ARTIST, &a_tune },
{ PREF "/tune-album", PURPLE_TUNE_ALBUM, &a_tune },
{ PREF "/game-message", "game", &a_tune },
{ PREF "/office-message", "office", &a_tune },
{ NULL, NULL, NULL }
}; const register struct attrs *a = attrs;
for(; a->pref ; a++) {
const gchar *value;
if(purple_prefs_get_bool(PREF "/reset-attrs"))
value = NULL;
else
value = purple_prefs_get_string(a->pref);
if(value && !strcmp(value, ""))
value = NULL;
else
purple_debug_info(NAME, "%s message changed to \"%s\" by signed-on account\n",
a->attr, value);
*(a->list) = g_list_append(*(a->list), (gpointer)a->attr);
*(a->list) = g_list_append(*(a->list), (gpointer)value);
}
const struct status_list {
const gchar *status_id;
GList *list;
gboolean cont;
} status[] = {
{ "tune", a_tune, TRUE },
{ "mood", a_mood, TRUE },
{ NULL, NULL, FALSE}
}; register const struct status_list *s = status;
for(; s->cont ; s++) {
purple_account_set_status_list(account, s->status_id, TRUE, s->list);
g_list_free(s->list);
}
}
void cb_buddy_icon_update(const char *name, PurplePrefType type,
gconstpointer val, gpointer data)
{
g_return_if_fail(bar->installed);
GdkPixbuf *icon;
icon = get_buddy_icon();
set_widget_icon(icon);
}
void cb_name_apply(PurpleAccount *account, const char *user_info)
{
g_return_if_fail(bar->installed);
const gchar *markup, *name;
name = user_info;
markup = purple_prefs_get_string(PREF "/nickname-markup");
set_widget_name(markup, name);
purple_prefs_set_string(PREF "/nickname", name);
set_display_name_all(name);
bar->name_dialog = FALSE;
purple_debug_info(NAME, "nickname changed to \"%s\" by user\n", name);
}
void cb_name_cancel(PurpleAccount *account, const char *user_info)
{
g_return_if_fail(bar->installed);
bar->name_dialog = FALSE;
}
void cb_pm_apply(gpointer data, PurpleRequestFields *fields)
{
g_return_if_fail(bar->installed);
/* attrs */
GList *a_tune = NULL;
GList *a_mood = NULL;
/* just to update widget */
const gchar *pm = purple_request_fields_get_string(fields, PREF "/personal-message");
const gchar *markup = purple_prefs_get_string(PREF "/personal-message-markup");
set_status_message(pm);
set_widget_pm(markup, pm);
purple_debug_info(NAME, "personal message changed to \"%s\" by user\n", pm);
const struct r_field {
const gchar *id;
const gchar *attr;
GList **list;
} r_fields[] = {
{ PREF "/mood-message", PURPLE_MOOD_COMMENT, &a_mood },
{ PREF "/tune-title", PURPLE_TUNE_TITLE, &a_tune },
{ PREF "/tune-artist", PURPLE_TUNE_ARTIST, &a_tune },
{ PREF "/tune-album", PURPLE_TUNE_ALBUM, &a_tune },
{ PREF "/game-message", "game", &a_tune },
{ PREF "/office-message", "office", &a_tune },
{ NULL, NULL, NULL }
}; const register struct r_field *rf = r_fields;
for(; rf->id ; rf++) {
const gchar *value = purple_request_fields_get_string(fields, rf->id);
if(!purple_prefs_get_bool(PREF "/reset-attrs"))
purple_prefs_set_string(rf->id, value);
if(value && !strcmp(value, ""))
value = NULL;
else
purple_debug_info(NAME, "%s message changed to \"%s\" by user\n",
rf->attr, value);
*(rf->list) = g_list_append(*(rf->list), (gpointer)rf->attr);
*(rf->list) = g_list_append(*(rf->list), (gpointer)value);
}
const struct status_list {
const gchar *status_id;
GList *list;
gboolean cont;
} status[] = {
{ "tune", a_tune, TRUE },
{ "mood", a_mood, TRUE },
{ NULL, NULL, FALSE}
}; register const struct status_list *s = status;
for(; s->cont ; s++) {
set_status_all(s->status_id, s->list);
g_list_free(s->list);
}
bar->pm_dialog = FALSE;
}
void cb_pm_cancel(gpointer data, PurpleRequestFields *fields)
{
g_return_if_fail(bar->installed);
bar->pm_dialog = FALSE;
}
diff --git a/widget_prpl.h b/widget_prpl.h
index 332bb6e..a25fade 100644
--- a/widget_prpl.h
+++ b/widget_prpl.h
@@ -1,35 +1,35 @@
/* File: widget_prpl.h
Time-stamp: <2010-11-08 18:51:46 gawen>
- Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _WIDGET_PRPL_H_
#define _WIDGET_PRPL_H_
#include "common.h"
void cb_name_apply(PurpleAccount *account, const char *user_info);
void cb_name_cancel(PurpleAccount *account, const char *user_info);
void cb_pm_apply(gpointer data, PurpleRequestFields *fields);
void cb_pm_cancel(gpointer data, PurpleRequestFields *fields);
void cb_status(PurpleAccount *account, PurpleStatus *old, PurpleStatus *new);
void cb_signed_on(PurpleConnection *gc);
void cb_buddy_icon_update(const char *name, PurplePrefType type,
gconstpointer val, gpointer data);
#endif /* _WIDGET_PRPL_H_ */
|
gawen947/pidgin-pbar
|
b8c2db3fbc753c4a0bf18b6bc0732a977a4a2353
|
Dialogs appearance enhancement
|
diff --git a/acct_features.c b/acct_features.c
index 32822cf..54a2028 100644
--- a/acct_features.c
+++ b/acct_features.c
@@ -1,271 +1,281 @@
+
/* File: acct_features.c
- Time-stamp: <2011-02-09 18:15:19 gawen>
+ Time-stamp: <2011-02-11 01:41:03 gawen>
Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "pbar.h"
#include "purple.h"
#include "gtk.h"
#include "acct_features.h"
static void cb_destroy_win(GtkWidget *widget, gpointer data);
static void cb_close_button(GtkWidget *widget, gpointer data);
static void cb_refresh_button(GtkWidget *widget, gpointer data);
enum {
ACCTICON_COLUMN,
ACCT_COLUMN,
NICKNAME_COLUMN,
PM_COLUMN,
ICON_COLUMN,
MOOD_COLUMN,
MOODMSG_COLUMN,
TUNE_COLUMN,
GAME_COLUMN,
APP_COLUMN,
N_COLUMN
};
static void cb_destroy_win(GtkWidget *widget, gpointer data)
{ destroy_acct_features_dialog((struct acct_features_dialog *)data); }
static void cb_close_button(GtkWidget *widget, gpointer data)
{ destroy_acct_features_dialog((struct acct_features_dialog *)data); }
static void cb_refresh_button(GtkWidget *widget, gpointer data)
{
struct acct_features_dialog *f_diag = (struct acct_features_dialog *)data;
gtk_list_store_clear(f_diag->list_store);
init_acct_features_dialog(f_diag);
}
struct acct_features_dialog * create_acct_features_dialog()
{
struct acct_features_dialog *f_diag = g_malloc(sizeof(struct acct_features_dialog));
memset(f_diag, 0, sizeof(struct acct_features_dialog));
/* widgets that can possibly be modified along dialog lifetime */
f_diag->window = pidgin_create_dialog(_("Account features"),
PIDGIN_HIG_BORDER,
"acct-features",
TRUE);
f_diag->list_store = gtk_list_store_new(N_COLUMN,
GDK_TYPE_PIXBUF, /* ACCTICON */
G_TYPE_STRING, /* ACCT */
GDK_TYPE_PIXBUF, /* NICKNAME */
GDK_TYPE_PIXBUF, /* PM */
GDK_TYPE_PIXBUF, /* ICON */
GDK_TYPE_PIXBUF, /* MOOD */
GDK_TYPE_PIXBUF, /* MOODMSG */
GDK_TYPE_PIXBUF, /* TUNE */
GDK_TYPE_PIXBUF, /* GAME */
GDK_TYPE_PIXBUF /* APP */ );
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(f_diag), f_diag->window);
/* widgets that are not modified */
+ GtkWidget *pbox = gtk_pidgin_dialog_box_new(_("Available features..."),
+ _("The following list shows the"
+ " available features for each"
+ " activated account. The last"
+ " line summarizes features"
+ " that have an impact on at"
+ " least one account."),
+ PIDGIN_STOCK_DIALOG_INFO);
GtkWidget *vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(f_diag->window),
FALSE,
PIDGIN_HIG_BORDER);
GtkWidget *hbox = pidgin_dialog_get_action_area(GTK_DIALOG(f_diag->window));
GtkWidget *view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(f_diag->list_store));
GtkWidget *refresh_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
/* create view and model */
GtkTreeViewColumn *p_col = gtk_tree_view_column_new();
GtkCellRenderer *p_renderer;
gtk_tree_view_column_set_title(p_col, _("Account"));
gtk_tree_view_append_column(GTK_TREE_VIEW(view), p_col);
p_renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, FALSE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"pixbuf", ACCTICON_COLUMN);
p_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, TRUE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"text", ACCT_COLUMN);
const struct g_column {
const gchar *title; /* column title */
const gchar *attr_type; /* column type attribute */
GtkCellRenderer *(*gtk_cell_renderer_new)(); /* gtk cell renderer creation */
guint position; /* column position */
} columns[] = {
{ N_("Nickname"), "pixbuf", gtk_cell_renderer_pixbuf_new, NICKNAME_COLUMN },
{ N_("Status message"), "pixbuf", gtk_cell_renderer_pixbuf_new, PM_COLUMN },
{ N_("Buddy icon"), "pixbuf", gtk_cell_renderer_pixbuf_new, ICON_COLUMN },
{ N_("Mood"), "pixbuf", gtk_cell_renderer_pixbuf_new, MOOD_COLUMN },
{ N_("Mood message"), "pixbuf", gtk_cell_renderer_pixbuf_new, MOODMSG_COLUMN },
{ N_("Tune"), "pixbuf", gtk_cell_renderer_pixbuf_new, TUNE_COLUMN },
{ N_("Game"), "pixbuf", gtk_cell_renderer_pixbuf_new, GAME_COLUMN },
{ N_("App."), "pixbuf", gtk_cell_renderer_pixbuf_new, APP_COLUMN },
{ NULL, NULL, NULL, 0 }
}; const struct g_column *col = columns;
/* create columns */
for(; col->title ; col++) {
GtkCellRenderer *renderer = col->gtk_cell_renderer_new();
GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes(_(col->title),
renderer,
col->attr_type,
col->position,
NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
}
/* pack widgets */
gtk_box_pack_start(GTK_BOX(hbox), refresh_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), pbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), view, TRUE, TRUE, 0);
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ f_diag->window, "destroy", cb_destroy_win },
{ refresh_button, "clicked", cb_refresh_button },
{ close_button, "clicked", cb_close_button },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(f_diag), g_signal_connections, f_diag);
/* show everything */
gtk_widget_show_all(f_diag->window);
gtk_window_present(GTK_WINDOW(f_diag->window));
return f_diag;
}
void destroy_acct_features_dialog(struct acct_features_dialog *f_diag)
{
gtk_destroy(PBAR_WIDGET(f_diag)); /* destroy widgets */
g_free(f_diag); /* free dialog */
}
void init_acct_features_dialog(struct acct_features_dialog *f_diag)
{
GList *a = purple_accounts_get_all_active();
/* TODO: should be freed ? */
GdkPixbuf *yes = gtk_widget_render_icon(f_diag->window, GTK_STOCK_YES,
GTK_ICON_SIZE_MENU, NULL);
GdkPixbuf *no = gtk_widget_render_icon(f_diag->window, GTK_STOCK_NO,
GTK_ICON_SIZE_MENU, NULL);
/* last line summarize all available features */
GtkTreeIter e_iter;
GdkPixbuf *e_icon = gtk_widget_render_icon(f_diag->window,
PIDGIN_STOCK_INFO,
GTK_ICON_SIZE_MENU,
NULL);
GdkPixbuf *e_pm = no;
GdkPixbuf *e_buddyicon = no;
GdkPixbuf *e_nickname = no;
GdkPixbuf *e_mood = no;
GdkPixbuf *e_moodmsg = no;
GdkPixbuf *e_game = no;
GdkPixbuf *e_app = no;
GdkPixbuf *e_tune = no;
for(; a ; a = a->next) {
PurpleAccount *acct = (PurpleAccount *)a->data;
PurplePlugin *plugin = purple_find_prpl(acct->protocol_id);
PurplePluginProtocolInfo *protocol = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
GtkTreeIter iter;
gchar *username = g_strdup_printf("%s (%s)",
purple_account_get_username(acct),
purple_account_get_protocol_name(acct));
GdkPixbuf *a_icon = pidgin_create_prpl_icon(acct, PIDGIN_PRPL_ICON_MEDIUM);
GHashTable *attrs = get_account_attrs(acct);
GdkPixbuf *nickname, *mood, *moodmsg, *game, *app, *tune, *pm, *buddyicon;
if(g_hash_table_lookup(attrs, "mood"))
e_mood = mood = yes;
else
mood = no;
if(g_hash_table_lookup(attrs, "moodtext"))
e_moodmsg = moodmsg = yes;
else
moodmsg = no;
if(g_hash_table_lookup(attrs, "game"))
e_game = game = yes;
else
game = no;
if(g_hash_table_lookup(attrs, "office"))
e_app = app = yes;
else
app = no;
if((g_hash_table_lookup(attrs, "tune_title") &&
g_hash_table_lookup(attrs, "tune_artist") &&
g_hash_table_lookup(attrs, "tune_album")))
e_tune = tune = yes;
else
tune = no;
g_hash_table_destroy(attrs);
if(protocol->set_status)
e_pm = pm = yes;
else
pm = no;
if(protocol->set_buddy_icon)
e_buddyicon = buddyicon = yes;
else
buddyicon = no;
/* exception for XMPP
nickname supported
manually
FIXME: however some XMPP account don't support nickname extension */
if(!strcmp(acct->protocol_id, "prpl-jabber") || protocol->set_public_alias)
e_nickname = nickname = yes;
else
nickname = no;
gtk_list_store_append(f_diag->list_store, &iter);
gtk_list_store_set(f_diag->list_store, &iter,
ACCT_COLUMN, username,
ACCTICON_COLUMN, a_icon,
NICKNAME_COLUMN, nickname,
PM_COLUMN, pm,
ICON_COLUMN, buddyicon,
MOOD_COLUMN, mood,
MOODMSG_COLUMN, moodmsg,
TUNE_COLUMN, tune,
GAME_COLUMN, game,
APP_COLUMN, app,
-1);
g_free(username);
}
/* last line summarize all available features */
gtk_list_store_append(f_diag->list_store, &e_iter);
gtk_list_store_set(f_diag->list_store, &e_iter,
ACCT_COLUMN, "Available features",
ACCTICON_COLUMN, e_icon,
NICKNAME_COLUMN, e_nickname,
PM_COLUMN, e_pm,
ICON_COLUMN, e_buddyicon,
MOOD_COLUMN, e_mood,
MOODMSG_COLUMN, e_moodmsg,
TUNE_COLUMN, e_tune,
GAME_COLUMN, e_game,
APP_COLUMN, e_app,
-1);
}
diff --git a/gtk.c b/gtk.c
index f921d41..a0ff0b4 100644
--- a/gtk.c
+++ b/gtk.c
@@ -1,86 +1,134 @@
/* File: gtk.c
- Time-stamp: <2011-02-07 18:49:30 gawen>
+ Time-stamp: <2011-02-11 01:29:58 gawen>
Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "gtk.h"
#if !GTK_CHECK_VERSION(2,18,0)
gboolean gtk_widget_get_visible(GtkWidget *widget)
{
return GTK_WIDGET_FLAGS(widget) & GTK_VISIBLE;
}
void gtk_widget_set_visible(GtkWidget *widget, gboolean visible)
{
if(visible)
gtk_widget_show(widget);
else
gtk_widget_hide(widget);
}
void gtk_widget_set_can_focus(GtkWidget *widget, gboolean can_focus)
{
if(can_focus)
GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_FOCUS);
else
GTK_WIDGET_UNSET_FLAGS(widget, GTK_CAN_FOCUS);
}
#endif /* GTK < 2.18 */
void gtk_connect_signals(struct pbar_widget *w,
const struct pbar_gtk_signal *sig_list,
gpointer data)
{
const struct pbar_gtk_signal *s = sig_list;
for(; s->signal ; s++) {
gulong handler_id = g_signal_connect(G_OBJECT(s->widget),
s->signal,
G_CALLBACK(s->callback),
data);
w->gtk_hnd = g_list_append(w->gtk_hnd, GINT_TO_POINTER(handler_id));
w->gtk_inst = g_list_append(w->gtk_inst, s->widget);
}
}
void gtk_destroy(struct pbar_widget *w)
{
GList *l, *i, *j;
/* disconnect gtk signals */
for(i = w->gtk_hnd, j = w->gtk_inst ; i && j ;
i = i->next, j = j->next)
g_signal_handler_disconnect(j->data, GPOINTER_TO_INT(i->data));
g_list_free(w->gtk_hnd);
g_list_free(w->gtk_inst);
/* destroy widgets */
for(j = w->main_widgets ; j ; j = j->next) {
GtkWidget *main_widget = (GtkWidget *)j->data;
l = gtk_container_get_children(GTK_CONTAINER(main_widget));
for(i = l ; i ; i = i->next) {
gtk_widget_destroy(i->data);
i->data = NULL;
}
gtk_widget_destroy(main_widget);
}
}
void gtk_add_main_widget(struct pbar_widget *w, GtkWidget *widget)
{ w->main_widgets = g_list_append(w->main_widgets, widget); }
+
+GtkWidget * gtk_pidgin_dialog_box_new(const gchar *primary,
+ const gchar *secondary,
+ const gchar *icon)
+{
+ GtkWidget *hbox;
+ GtkWidget *vbox;
+ GtkWidget *img;
+
+ /* create initial pidgin box */
+ hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER);
+ vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER);
+
+ /* create dialog icon */
+ img = gtk_image_new_from_stock(icon,
+ gtk_icon_size_from_name(
+ PIDGIN_ICON_SIZE_TANGO_HUGE));
+ gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
+
+ if(primary) { /* create and setup primary */
+ GtkWidget *primary_label;
+ gchar *primary_esc = g_markup_escape_text(primary, -1);
+ gchar *label_text = g_strdup_printf(
+ "<span weight=\"bold\" size=\"larger\">%s</span>", primary_esc);
+ primary_label = gtk_label_new(NULL);
+ gtk_label_set_markup(GTK_LABEL(primary_label), label_text);
+ gtk_label_set_line_wrap(GTK_LABEL(primary_label), TRUE);
+ gtk_misc_set_alignment(GTK_MISC(primary_label), 0, 0);
+ g_free(label_text);
+ gtk_box_pack_start(GTK_BOX(vbox), primary_label, FALSE, FALSE, 0);
+ }
+ if(secondary) { /* create and setup secondary */
+ GtkWidget *secondary_label;
+ gchar *secondary_esc = g_markup_escape_text(secondary, -1);
+ secondary_label = gtk_label_new(NULL);
+ gtk_label_set_markup(GTK_LABEL(secondary_label), secondary_esc);
+ g_free(secondary_esc);
+ gtk_label_set_line_wrap(GTK_LABEL(secondary_label), TRUE);
+ gtk_misc_set_alignment(GTK_MISC(secondary_label), 0, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), secondary_label, FALSE, FALSE, 0);
+ }
+
+ /* pack widgets into pidgin box */
+ gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
+
+ return hbox;
+}
diff --git a/gtk.h b/gtk.h
index db8c406..7faf743 100644
--- a/gtk.h
+++ b/gtk.h
@@ -1,52 +1,55 @@
/* File: gtk.h
- Time-stamp: <2011-02-10 16:52:27 gawen>
+ Time-stamp: <2011-02-11 01:23:06 gawen>
Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _GTK_H_
#define _GTK_H_
#include "common.h"
#define PBAR_GTK_CALLBACK(func) ((void (*)(GtkWidget *, gpointer))func)
#define PBAR_WIDGET(widget) ((struct pbar_widget *)widget)
#define BEGIN_PBAR_WIDGET GList *gtk_hnd; \
GList *gtk_inst; \
GList *main_widgets
struct pbar_gtk_signal {
GtkWidget *widget;
const gchar *signal;
void (*callback)(GtkWidget *, gpointer);
};
struct pbar_widget {
BEGIN_PBAR_WIDGET; /* signals handlers and instance for disconnection */
};
#if !GTK_CHECK_VERSION(2,18,0)
gboolean gtk_widget_get_visible(GtkWidget *widget);
void gtk_widget_set_visible(GtkWidget *widget, gboolean visible);
void gtk_widget_set_can_focus(GtkWidget *widget, gboolean can_focus);
#endif /* GTK < 2.18 */
void gtk_destroy(struct pbar_widget *w);
void gtk_add_main_widget(struct pbar_widget *w, GtkWidget *widget);
void gtk_connect_signals(struct pbar_widget *w,
const struct pbar_gtk_signal *sig_list,
gpointer data);
+GtkWidget * gtk_pidgin_dialog_box_new(const gchar *primary,
+ const gchar *secondary,
+ const gchar *icon);
#endif /* _GTK_H_ */
diff --git a/mood_dialog.c b/mood_dialog.c
index aff90e6..0fe440c 100644
--- a/mood_dialog.c
+++ b/mood_dialog.c
@@ -1,220 +1,226 @@
/* File: mood_dialog.c
- Time-stamp: <2011-02-10 17:58:48 gawen>
+ Time-stamp: <2011-02-11 01:46:37 gawen>
Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "gtk.h"
#include "purple.h"
#include "preferences.h"
#include "mood_dialog.h"
static void cb_destroy_win(GtkWidget *widget, gpointer data);
static void cb_close_button(GtkWidget *widget, gpointer data);
static void cb_apply_button(GtkWidget *widget, gpointer date);
static void cb_refresh_button(GtkWidget *widget, gpointer data);
static void cb_row_activated(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data);
enum {
MOODICON_COLUMN,
MOOD_COLUMN,
N_COLUMN
};
static void cb_destroy_win(GtkWidget *widget, gpointer data)
{ destroy_mood_dialog((struct mood_dialog *)data); }
static void cb_row_activated(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data)
{ cb_apply_button(widget, data); }
static void cb_apply_button(GtkWidget *widget, gpointer data)
{
GtkTreeModel *model;
GtkTreeIter iter;
GtkTreeSelection *sel;
struct mood_dialog *s_diag = (struct mood_dialog *)data;
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(s_diag->list_view));
if(gtk_tree_selection_get_selected(sel, &model, &iter)) {
const gchar *mood;
gchar *name;
gtk_tree_model_get(model, &iter, MOOD_COLUMN, &name, -1);
mood = g_hash_table_lookup(s_diag->global_moods, name);
if(mood) { /* mood found */
gchar *path;
destroy_mood_dialog(s_diag); /* destroy dialog first */
set_status_with_mood_all(mood);
purple_prefs_set_string(PREF "/mood", mood);
path = get_mood_icon_path(mood);
set_widget_mood(path);
g_free(path);
purple_debug_info(NAME, "mood changed to \"%s\" by user\n", mood);
} else
purple_debug_info(NAME, "selected mood \"%s\" doesn't exists\n", name);
g_free(name);
} else
purple_debug_info(NAME, "no row selected\n");
}
static void cb_close_button(GtkWidget *widget, gpointer data)
{ destroy_mood_dialog((struct mood_dialog *)data); }
static void cb_refresh_button(GtkWidget *widget, gpointer data)
{
struct mood_dialog *s_diag = (struct mood_dialog *)data;
gtk_list_store_clear(s_diag->list_store);
init_mood_dialog(s_diag);
}
struct mood_dialog * create_mood_dialog()
{
struct mood_dialog *s_diag = g_malloc(sizeof(struct mood_dialog));
memset(s_diag, 0, sizeof(struct mood_dialog));
/* widgets that can be modifier along dialog lifetime */
s_diag->window = pidgin_create_dialog(_("Mood selection"),
PIDGIN_HIG_BORDER,
"mood-select",
TRUE);
s_diag->list_store = gtk_list_store_new(N_COLUMN,
GDK_TYPE_PIXBUF, /* MOODICON */
G_TYPE_STRING /* MOOD */ );
s_diag->list_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
s_diag->list_store));
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(s_diag), s_diag->window);
/* widgets that are not modified */
+ GtkWidget *pbox = gtk_pidgin_dialog_box_new(_("Select your mood..."),
+ _("This will change your mood for"
+ " every account which supports"
+ " it."),
+ PIDGIN_STOCK_DIALOG_QUESTION);
GtkWidget *vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(
s_diag->window),
FALSE,
PIDGIN_HIG_BORDER);
GtkWidget *hbox = pidgin_dialog_get_action_area(GTK_DIALOG(s_diag->window));
GtkWidget *refresh_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
GtkWidget *apply_button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
/* create view and model */
GtkTreeViewColumn *p_col = gtk_tree_view_column_new();
GtkCellRenderer *p_renderer;
gtk_tree_view_column_set_title(p_col, _("Mood"));
gtk_tree_view_append_column(GTK_TREE_VIEW(s_diag->list_view), p_col);
p_renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, FALSE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"pixbuf", MOODICON_COLUMN);
p_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, TRUE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"text", MOOD_COLUMN);
/* pack widgets */
gtk_box_pack_start(GTK_BOX(hbox), refresh_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), apply_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), pbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), s_diag->list_view, TRUE, TRUE, 0);
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ s_diag->window, "destroy", cb_destroy_win },
{ s_diag->list_view, "row-activated", PBAR_GTK_CALLBACK(cb_row_activated) },
{ refresh_button, "clicked", cb_refresh_button },
{ apply_button, "clicked", cb_apply_button },
{ close_button, "clicked", cb_close_button },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(s_diag), g_signal_connections, s_diag);
/* show everything */
gtk_widget_show_all(s_diag->window);
gtk_window_present(GTK_WINDOW(s_diag->window));
return s_diag;
}
void destroy_mood_dialog(struct mood_dialog *s_diag)
{
gtk_destroy(PBAR_WIDGET(s_diag)); /* destroy widgets */
g_hash_table_destroy(s_diag->global_moods); /* free global moods */
g_free(s_diag); /* free dialog */
}
void init_mood_dialog(struct mood_dialog *s_diag)
{
GtkTreeIter empty_iter;
GdkPixbuf *empty_pixbuf;
GtkWidget *empty_image;
const gchar *empty_mood;
gchar *empty_path;
PurpleMood *mood = get_global_moods();
if(!s_diag->global_moods)
s_diag->global_moods = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
/* add empty mood to mood list */
empty_mood = "";
empty_path = get_mood_icon_path(empty_mood);
empty_image = gtk_image_new_from_file(empty_path);
empty_pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(empty_image));
g_free(empty_path);
gtk_list_store_append(s_diag->list_store, &empty_iter);
gtk_list_store_set(s_diag->list_store, &empty_iter,
MOODICON_COLUMN, empty_pixbuf,
MOOD_COLUMN, _("None"),
-1);
g_hash_table_insert(s_diag->global_moods, (gpointer)_("None"),
(gpointer)empty_mood);
for(; mood->mood ; mood++) {
if(!mood->mood || !mood->description)
continue;
GtkTreeIter iter;
GtkWidget *image;
GdkPixbuf *pixbuf;
gchar *path = get_mood_icon_path(mood->mood);
g_hash_table_insert(s_diag->global_moods, (gpointer)_(mood->description),
(gpointer)mood->mood);
image = gtk_image_new_from_file(path);
pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(image));
g_free(path);
gtk_list_store_append(s_diag->list_store, &iter);
gtk_list_store_set(s_diag->list_store, &iter,
MOODICON_COLUMN, pixbuf,
MOOD_COLUMN, _(mood->description),
-1);
}
}
diff --git a/protocol_features.c b/protocol_features.c
index c45d406..bb0616b 100644
--- a/protocol_features.c
+++ b/protocol_features.c
@@ -1,214 +1,221 @@
/* File: protocol_features.c
- Time-stamp: <2011-02-07 19:05:53 gawen>
+ Time-stamp: <2011-02-11 01:39:18 gawen>
Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "pbar.h"
#include "purple.h"
#include "gtk.h"
#include "protocol_features.h"
static void cb_destroy_win(GtkWidget *widget, gpointer data);
static void cb_close_button(GtkWidget *widget, gpointer data);
static void cb_refresh_button(GtkWidget *widget, gpointer data);
enum {
PROTOCOLICON_COLUMN,
PROTOCOL_COLUMN,
NICKNAME_COLUMN,
PM_COLUMN,
ICON_COLUMN,
MOOD_COLUMN,
MOODMSG_COLUMN,
TUNE_COLUMN,
GAME_COLUMN,
APP_COLUMN,
N_COLUMN
};
static void cb_destroy_win(GtkWidget *widget, gpointer data)
{ destroy_protocol_features_dialog((struct protocol_features_dialog *)data); }
static void cb_close_button(GtkWidget *widget, gpointer data)
{ destroy_protocol_features_dialog((struct protocol_features_dialog *)data); }
static void cb_refresh_button(GtkWidget *widget, gpointer data)
{
struct protocol_features_dialog *f_diag = (struct protocol_features_dialog *)data;
gtk_list_store_clear(f_diag->list_store);
init_protocol_features_dialog(f_diag);
}
struct protocol_features_dialog * create_protocol_features_dialog()
{
struct protocol_features_dialog *f_diag = g_malloc(sizeof(struct protocol_features_dialog));
memset(f_diag, 0, sizeof(struct protocol_features_dialog));
/* widgets that can possibly be modified along dialog lifetime */
f_diag->window = pidgin_create_dialog(_("Protocol features"),
PIDGIN_HIG_BORDER,
"protocol-features",
TRUE);
f_diag->list_store = gtk_list_store_new(N_COLUMN,
GDK_TYPE_PIXBUF, /* PROTOCOLICON */
G_TYPE_STRING, /* PROTOCOL */
GDK_TYPE_PIXBUF, /* NICKNAME */
GDK_TYPE_PIXBUF, /* PM */
GDK_TYPE_PIXBUF, /* ICON */
GDK_TYPE_PIXBUF, /* MOOD */
GDK_TYPE_PIXBUF, /* MOODMSG */
GDK_TYPE_PIXBUF, /* TUNE */
GDK_TYPE_PIXBUF, /* GAME */
GDK_TYPE_PIXBUF /* APP */ );
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(f_diag), f_diag->window);
/* widgets that are not modified */
+ GtkWidget *pbox = gtk_pidgin_dialog_box_new(_("Available features..."),
+ _("The following list shows the"
+ " available features for each"
+ " protocol."),
+ PIDGIN_STOCK_DIALOG_INFO);
+
GtkWidget *vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(f_diag->window),
FALSE,
PIDGIN_HIG_BORDER);
GtkWidget *hbox = pidgin_dialog_get_action_area(GTK_DIALOG(f_diag->window));
GtkWidget *view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(f_diag->list_store));
GtkWidget *refresh_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
/* create view and model */
GtkTreeViewColumn *p_col = gtk_tree_view_column_new();
GtkCellRenderer *p_renderer;
gtk_tree_view_column_set_title(p_col, _("Protocol"));
gtk_tree_view_append_column(GTK_TREE_VIEW(view), p_col);
p_renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, FALSE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"pixbuf", PROTOCOLICON_COLUMN);
p_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, TRUE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"text", PROTOCOL_COLUMN);
const struct g_column {
const gchar *title; /* column title */
const gchar *attr_type; /* column type attribute */
GtkCellRenderer *(*gtk_cell_renderer_new)(); /* gtk cell renderer creation */
guint position; /* column position */
} columns[] = {
{ N_("Nickname"), "pixbuf", gtk_cell_renderer_pixbuf_new, NICKNAME_COLUMN },
{ N_("Status message"), "pixbuf", gtk_cell_renderer_pixbuf_new, PM_COLUMN },
{ N_("Buddy icon"), "pixbuf", gtk_cell_renderer_pixbuf_new, ICON_COLUMN },
{ N_("Mood"), "pixbuf", gtk_cell_renderer_pixbuf_new, MOOD_COLUMN },
{ N_("Mood message"), "pixbuf", gtk_cell_renderer_pixbuf_new, MOODMSG_COLUMN },
{ N_("Tune"), "pixbuf", gtk_cell_renderer_pixbuf_new, TUNE_COLUMN },
{ N_("Game"), "pixbuf", gtk_cell_renderer_pixbuf_new, GAME_COLUMN },
{ N_("App."), "pixbuf", gtk_cell_renderer_pixbuf_new, APP_COLUMN },
{ NULL, NULL, NULL, 0 }
}; const struct g_column *col = columns;
/* create columns */
for(; col->title ; col++) {
GtkCellRenderer *renderer = col->gtk_cell_renderer_new();
GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes(_(col->title),
renderer,
col->attr_type,
col->position,
NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
}
/* pack widgets */
gtk_box_pack_start(GTK_BOX(hbox), refresh_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), pbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), view, TRUE, TRUE, 0);
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ f_diag->window, "destroy", cb_destroy_win },
{ refresh_button, "clicked", cb_refresh_button },
{ close_button, "clicked", cb_close_button },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(f_diag), g_signal_connections, f_diag);
/* show everything */
gtk_widget_show_all(f_diag->window);
gtk_window_present(GTK_WINDOW(f_diag->window));
return f_diag;
}
void destroy_protocol_features_dialog(struct protocol_features_dialog *f_diag)
{
gtk_destroy(PBAR_WIDGET(f_diag)); /* destroy widgets */
g_free(f_diag); /* free dialog */
}
void init_protocol_features_dialog(struct protocol_features_dialog *f_diag)
{
GList *p = purple_plugins_get_protocols();
/* TODO: should be freed ? */
GdkPixbuf *yes = gtk_widget_render_icon(f_diag->window, GTK_STOCK_YES,
GTK_ICON_SIZE_MENU, NULL);
GdkPixbuf *no = gtk_widget_render_icon(f_diag->window, GTK_STOCK_NO,
GTK_ICON_SIZE_MENU, NULL);
for(; p ; p = p->next) {
PurplePlugin *plugin = p->data;
PurplePluginInfo *info = plugin->info;
PurplePluginProtocolInfo *protocol = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
if(info && info->name) {
GtkTreeIter iter;
GdkPixbuf *p_icon = create_prpl_icon_from_info(protocol,
PIDGIN_PRPL_ICON_MEDIUM);
GHashTable *attrs = get_protocol_attrs(protocol);
GdkPixbuf *nickname;
GdkPixbuf *mood = g_hash_table_lookup(attrs, "mood") ? yes : no;
GdkPixbuf *moodmsg = g_hash_table_lookup(attrs, "moodtext") ? yes : no;
GdkPixbuf *game = g_hash_table_lookup(attrs, "game") ? yes : no;
GdkPixbuf *app = g_hash_table_lookup(attrs, "office") ? yes : no;
GdkPixbuf *tune = (g_hash_table_lookup(attrs, "tune_title") &&
g_hash_table_lookup(attrs, "tune_artist") &&
g_hash_table_lookup(attrs, "tune_album")) ? yes : no;
g_hash_table_destroy(attrs);
/* exception for XMPP
nickname supported
manually */
if(!strcmp(info->name, "XMPP"))
nickname = yes;
else
nickname = protocol->set_public_alias ? yes : no;
gtk_list_store_append(f_diag->list_store, &iter);
gtk_list_store_set(f_diag->list_store, &iter,
PROTOCOL_COLUMN, info->name,
PROTOCOLICON_COLUMN, p_icon,
NICKNAME_COLUMN, nickname,
PM_COLUMN, protocol->set_status ? yes : no,
ICON_COLUMN, protocol->set_buddy_icon ? yes : no,
MOOD_COLUMN, mood,
MOODMSG_COLUMN, moodmsg,
TUNE_COLUMN, tune,
GAME_COLUMN, game,
APP_COLUMN, app,
-1);
}
}
}
diff --git a/status_dialog.c b/status_dialog.c
index 2d3de64..4da9436 100644
--- a/status_dialog.c
+++ b/status_dialog.c
@@ -1,219 +1,225 @@
/* File: status_dialog.c
- Time-stamp: <2011-02-10 17:48:54 gawen>
+ Time-stamp: <2011-02-11 01:47:39 gawen>
Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "gtk.h"
#include "preferences.h"
#include "status_dialog.h"
static void cb_destroy_win(GtkWidget *widget, gpointer data);
static void cb_close_button(GtkWidget *widget, gpointer data);
static void cb_apply_button(GtkWidget *widget, gpointer date);
static void cb_refresh_button(GtkWidget *widget, gpointer data);
static void cb_row_activated(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data);
enum {
STATUSICON_COLUMN,
STATUS_COLUMN,
N_COLUMN
};
static void cb_destroy_win(GtkWidget *widget, gpointer data)
{ destroy_status_dialog((struct status_dialog *)data); }
static void cb_row_activated(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data)
{ cb_apply_button(widget, data); }
static void cb_apply_button(GtkWidget *widget, gpointer data)
{
GtkTreeModel *model;
GtkTreeIter iter;
GtkTreeSelection *sel;
struct status_dialog *s_diag = (struct status_dialog *)data;
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(s_diag->list_view));
if(gtk_tree_selection_get_selected(sel, &model, &iter)) {
PurpleStatusType *type;
gchar *name;
gtk_tree_model_get(model, &iter, STATUS_COLUMN, &name, -1);
type = g_hash_table_lookup(s_diag->global_status, name);
if(type) { /* status type found */
destroy_status_dialog(s_diag); /* destroy dialog first */
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
PurpleStatusPrimitive prim = purple_status_type_get_primitive(type);
PurpleSavedStatus *status = purple_savedstatus_get_current();
purple_savedstatus_set_type(status, prim);
purple_savedstatus_set_message(status, pm);
purple_savedstatus_activate(status);
purple_debug_info(NAME, "status changed to \"%s\" by user\n",
purple_status_type_get_name(type));
} else
purple_debug_info(NAME, "selected status \"%s\" doesn't exists\n", name);
g_free(name);
} else
purple_debug_info(NAME, "no row selected\n");
}
static void cb_close_button(GtkWidget *widget, gpointer data)
{ destroy_status_dialog((struct status_dialog *)data); }
static void cb_refresh_button(GtkWidget *widget, gpointer data)
{
struct status_dialog *s_diag = (struct status_dialog *)data;
gtk_list_store_clear(s_diag->list_store);
init_status_dialog(s_diag);
}
struct status_dialog * create_status_dialog()
{
struct status_dialog *s_diag = g_malloc(sizeof(struct status_dialog));
memset(s_diag, 0, sizeof(struct status_dialog));
/* widgets that can be modifier along dialog lifetime */
s_diag->window = pidgin_create_dialog(_("Status selection"),
PIDGIN_HIG_BORDER,
"status-select",
TRUE);
s_diag->list_store = gtk_list_store_new(N_COLUMN,
GDK_TYPE_PIXBUF, /* STATUSICON */
G_TYPE_STRING /* STATUS */ );
s_diag->list_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
s_diag->list_store));
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(s_diag), s_diag->window);
/* widgets that are not modified */
+ GtkWidget *pbox = gtk_pidgin_dialog_box_new(_("Select your status..."),
+ _("This will change your current"
+ " status for every account"
+ " which supports it."),
+ PIDGIN_STOCK_DIALOG_QUESTION);
GtkWidget *vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(
s_diag->window),
FALSE,
PIDGIN_HIG_BORDER);
GtkWidget *hbox = pidgin_dialog_get_action_area(GTK_DIALOG(s_diag->window));
GtkWidget *refresh_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
GtkWidget *apply_button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
/* create view and model */
GtkTreeViewColumn *p_col = gtk_tree_view_column_new();
GtkCellRenderer *p_renderer;
gtk_tree_view_column_set_title(p_col, _("Status"));
gtk_tree_view_append_column(GTK_TREE_VIEW(s_diag->list_view), p_col);
p_renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, FALSE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"pixbuf", STATUSICON_COLUMN);
p_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, TRUE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"text", STATUS_COLUMN);
/* pack widgets */
gtk_box_pack_start(GTK_BOX(hbox), refresh_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), apply_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), pbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), s_diag->list_view, TRUE, TRUE, 0);
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ s_diag->window, "destroy", cb_destroy_win },
{ s_diag->list_view, "row-activated", PBAR_GTK_CALLBACK(cb_row_activated) },
{ refresh_button, "clicked", cb_refresh_button },
{ apply_button, "clicked", cb_apply_button },
{ close_button, "clicked", cb_close_button },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(s_diag), g_signal_connections, s_diag);
/* show everything */
gtk_widget_show_all(s_diag->window);
gtk_window_present(GTK_WINDOW(s_diag->window));
return s_diag;
}
void destroy_status_dialog(struct status_dialog *s_diag)
{
gtk_destroy(PBAR_WIDGET(s_diag)); /* destroy widgets */
g_hash_table_destroy(s_diag->global_status); /* free global status */
g_free(s_diag); /* free dialog */
}
void init_status_dialog(struct status_dialog *s_diag)
{
GList *a = purple_accounts_get_all_active();
GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
if(!s_diag->global_status)
s_diag->global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
for(; a ; a = g_list_delete_link(a, a)) {
PurpleAccount *acct = (PurpleAccount *)a->data;
GList *types = purple_account_get_status_types(acct);
for(; types ; types = types->next) {
GtkTreeIter iter;
GdkPixbuf *icon;
PurpleStatusType *type = (PurpleStatusType *)types->data;
PurpleStatusPrimitive prim;
const gchar *stock, *status_name;
if(!purple_status_type_is_user_settable(type) ||
purple_status_type_is_independent(type))
continue;
prim = purple_status_type_get_primitive(type);
stock = pidgin_stock_id_from_status_primitive(prim);
if(g_hash_table_lookup(global_status, stock))
continue;
else
g_hash_table_insert(global_status, (gpointer)stock,
GINT_TO_POINTER(TRUE));
status_name = purple_status_type_get_name(type);
icon = gtk_widget_render_icon(s_diag->window, stock,
GTK_ICON_SIZE_MENU, NULL);
g_hash_table_insert(s_diag->global_status, (gpointer)_(status_name),
type);
gtk_list_store_append(s_diag->list_store, &iter);
gtk_list_store_set(s_diag->list_store, &iter,
STATUSICON_COLUMN, icon,
STATUS_COLUMN, status_name,
-1);
}
}
g_hash_table_destroy(global_status);
}
|
gawen947/pidgin-pbar
|
24c8c7f1c273968896bfe86beb5addab8d853e35
|
Remove old comments
|
diff --git a/mood_dialog.c b/mood_dialog.c
index 9f863c4..aff90e6 100644
--- a/mood_dialog.c
+++ b/mood_dialog.c
@@ -1,221 +1,220 @@
/* File: mood_dialog.c
- Time-stamp: <2011-02-10 17:55:48 gawen>
+ Time-stamp: <2011-02-10 17:58:48 gawen>
Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "gtk.h"
#include "purple.h"
#include "preferences.h"
#include "mood_dialog.h"
static void cb_destroy_win(GtkWidget *widget, gpointer data);
static void cb_close_button(GtkWidget *widget, gpointer data);
static void cb_apply_button(GtkWidget *widget, gpointer date);
static void cb_refresh_button(GtkWidget *widget, gpointer data);
static void cb_row_activated(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data);
enum {
MOODICON_COLUMN,
MOOD_COLUMN,
N_COLUMN
};
static void cb_destroy_win(GtkWidget *widget, gpointer data)
{ destroy_mood_dialog((struct mood_dialog *)data); }
static void cb_row_activated(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data)
{ cb_apply_button(widget, data); }
static void cb_apply_button(GtkWidget *widget, gpointer data)
{
GtkTreeModel *model;
GtkTreeIter iter;
GtkTreeSelection *sel;
struct mood_dialog *s_diag = (struct mood_dialog *)data;
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(s_diag->list_view));
if(gtk_tree_selection_get_selected(sel, &model, &iter)) {
- /* TODO: factorisation, use set_mood_all or similar */
const gchar *mood;
gchar *name;
gtk_tree_model_get(model, &iter, MOOD_COLUMN, &name, -1);
mood = g_hash_table_lookup(s_diag->global_moods, name);
if(mood) { /* mood found */
gchar *path;
destroy_mood_dialog(s_diag); /* destroy dialog first */
set_status_with_mood_all(mood);
purple_prefs_set_string(PREF "/mood", mood);
path = get_mood_icon_path(mood);
set_widget_mood(path);
g_free(path);
purple_debug_info(NAME, "mood changed to \"%s\" by user\n", mood);
} else
purple_debug_info(NAME, "selected mood \"%s\" doesn't exists\n", name);
g_free(name);
} else
purple_debug_info(NAME, "no row selected\n");
}
static void cb_close_button(GtkWidget *widget, gpointer data)
{ destroy_mood_dialog((struct mood_dialog *)data); }
static void cb_refresh_button(GtkWidget *widget, gpointer data)
{
struct mood_dialog *s_diag = (struct mood_dialog *)data;
gtk_list_store_clear(s_diag->list_store);
init_mood_dialog(s_diag);
}
struct mood_dialog * create_mood_dialog()
{
struct mood_dialog *s_diag = g_malloc(sizeof(struct mood_dialog));
memset(s_diag, 0, sizeof(struct mood_dialog));
/* widgets that can be modifier along dialog lifetime */
s_diag->window = pidgin_create_dialog(_("Mood selection"),
PIDGIN_HIG_BORDER,
"mood-select",
TRUE);
s_diag->list_store = gtk_list_store_new(N_COLUMN,
GDK_TYPE_PIXBUF, /* MOODICON */
G_TYPE_STRING /* MOOD */ );
s_diag->list_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
s_diag->list_store));
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(s_diag), s_diag->window);
/* widgets that are not modified */
GtkWidget *vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(
s_diag->window),
FALSE,
PIDGIN_HIG_BORDER);
GtkWidget *hbox = pidgin_dialog_get_action_area(GTK_DIALOG(s_diag->window));
GtkWidget *refresh_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
GtkWidget *apply_button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
/* create view and model */
GtkTreeViewColumn *p_col = gtk_tree_view_column_new();
GtkCellRenderer *p_renderer;
gtk_tree_view_column_set_title(p_col, _("Mood"));
gtk_tree_view_append_column(GTK_TREE_VIEW(s_diag->list_view), p_col);
p_renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, FALSE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"pixbuf", MOODICON_COLUMN);
p_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, TRUE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"text", MOOD_COLUMN);
/* pack widgets */
gtk_box_pack_start(GTK_BOX(hbox), refresh_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), apply_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), s_diag->list_view, TRUE, TRUE, 0);
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ s_diag->window, "destroy", cb_destroy_win },
{ s_diag->list_view, "row-activated", PBAR_GTK_CALLBACK(cb_row_activated) },
{ refresh_button, "clicked", cb_refresh_button },
{ apply_button, "clicked", cb_apply_button },
{ close_button, "clicked", cb_close_button },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(s_diag), g_signal_connections, s_diag);
/* show everything */
gtk_widget_show_all(s_diag->window);
gtk_window_present(GTK_WINDOW(s_diag->window));
return s_diag;
}
void destroy_mood_dialog(struct mood_dialog *s_diag)
{
gtk_destroy(PBAR_WIDGET(s_diag)); /* destroy widgets */
g_hash_table_destroy(s_diag->global_moods); /* free global moods */
g_free(s_diag); /* free dialog */
}
void init_mood_dialog(struct mood_dialog *s_diag)
{
GtkTreeIter empty_iter;
GdkPixbuf *empty_pixbuf;
GtkWidget *empty_image;
const gchar *empty_mood;
gchar *empty_path;
PurpleMood *mood = get_global_moods();
if(!s_diag->global_moods)
s_diag->global_moods = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
/* add empty mood to mood list */
empty_mood = "";
empty_path = get_mood_icon_path(empty_mood);
empty_image = gtk_image_new_from_file(empty_path);
empty_pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(empty_image));
g_free(empty_path);
gtk_list_store_append(s_diag->list_store, &empty_iter);
gtk_list_store_set(s_diag->list_store, &empty_iter,
MOODICON_COLUMN, empty_pixbuf,
MOOD_COLUMN, _("None"),
-1);
g_hash_table_insert(s_diag->global_moods, (gpointer)_("None"),
(gpointer)empty_mood);
for(; mood->mood ; mood++) {
if(!mood->mood || !mood->description)
continue;
GtkTreeIter iter;
GtkWidget *image;
GdkPixbuf *pixbuf;
gchar *path = get_mood_icon_path(mood->mood);
g_hash_table_insert(s_diag->global_moods, (gpointer)_(mood->description),
(gpointer)mood->mood);
image = gtk_image_new_from_file(path);
pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(image));
g_free(path);
gtk_list_store_append(s_diag->list_store, &iter);
gtk_list_store_set(s_diag->list_store, &iter,
MOODICON_COLUMN, pixbuf,
MOOD_COLUMN, _(mood->description),
-1);
}
}
|
gawen947/pidgin-pbar
|
046909b660470d510b51d29f78de5de8786ac425
|
Use set_status_with_mood_all (factorisation)
|
diff --git a/mood_dialog.c b/mood_dialog.c
index cd9aae9..9f863c4 100644
--- a/mood_dialog.c
+++ b/mood_dialog.c
@@ -1,229 +1,221 @@
/* File: mood_dialog.c
- Time-stamp: <2011-02-10 17:48:14 gawen>
+ Time-stamp: <2011-02-10 17:55:48 gawen>
Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "gtk.h"
#include "purple.h"
#include "preferences.h"
#include "mood_dialog.h"
static void cb_destroy_win(GtkWidget *widget, gpointer data);
static void cb_close_button(GtkWidget *widget, gpointer data);
static void cb_apply_button(GtkWidget *widget, gpointer date);
static void cb_refresh_button(GtkWidget *widget, gpointer data);
static void cb_row_activated(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data);
enum {
MOODICON_COLUMN,
MOOD_COLUMN,
N_COLUMN
};
static void cb_destroy_win(GtkWidget *widget, gpointer data)
{ destroy_mood_dialog((struct mood_dialog *)data); }
static void cb_row_activated(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data)
{ cb_apply_button(widget, data); }
static void cb_apply_button(GtkWidget *widget, gpointer data)
{
GtkTreeModel *model;
GtkTreeIter iter;
GtkTreeSelection *sel;
struct mood_dialog *s_diag = (struct mood_dialog *)data;
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(s_diag->list_view));
if(gtk_tree_selection_get_selected(sel, &model, &iter)) {
/* TODO: factorisation, use set_mood_all or similar */
const gchar *mood;
gchar *name;
gtk_tree_model_get(model, &iter, MOOD_COLUMN, &name, -1);
mood = g_hash_table_lookup(s_diag->global_moods, name);
if(mood) { /* mood found */
- GList *accts = purple_accounts_get_all_active();
gchar *path;
destroy_mood_dialog(s_diag); /* destroy dialog first */
- for(; accts ; accts = g_list_delete_link(accts, accts)) {
- PurpleAccount *account = (PurpleAccount *)accts->data;
- PurpleConnection *gc = purple_account_get_connection(account);
-
- if(gc && gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS)
- set_status_with_mood(account, mood);
- }
-
+ set_status_with_mood_all(mood);
purple_prefs_set_string(PREF "/mood", mood);
path = get_mood_icon_path(mood);
set_widget_mood(path);
g_free(path);
purple_debug_info(NAME, "mood changed to \"%s\" by user\n", mood);
} else
purple_debug_info(NAME, "selected mood \"%s\" doesn't exists\n", name);
g_free(name);
} else
purple_debug_info(NAME, "no row selected\n");
}
static void cb_close_button(GtkWidget *widget, gpointer data)
{ destroy_mood_dialog((struct mood_dialog *)data); }
static void cb_refresh_button(GtkWidget *widget, gpointer data)
{
struct mood_dialog *s_diag = (struct mood_dialog *)data;
gtk_list_store_clear(s_diag->list_store);
init_mood_dialog(s_diag);
}
struct mood_dialog * create_mood_dialog()
{
struct mood_dialog *s_diag = g_malloc(sizeof(struct mood_dialog));
memset(s_diag, 0, sizeof(struct mood_dialog));
/* widgets that can be modifier along dialog lifetime */
s_diag->window = pidgin_create_dialog(_("Mood selection"),
PIDGIN_HIG_BORDER,
"mood-select",
TRUE);
s_diag->list_store = gtk_list_store_new(N_COLUMN,
GDK_TYPE_PIXBUF, /* MOODICON */
G_TYPE_STRING /* MOOD */ );
s_diag->list_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
s_diag->list_store));
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(s_diag), s_diag->window);
/* widgets that are not modified */
GtkWidget *vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(
s_diag->window),
FALSE,
PIDGIN_HIG_BORDER);
GtkWidget *hbox = pidgin_dialog_get_action_area(GTK_DIALOG(s_diag->window));
GtkWidget *refresh_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
GtkWidget *apply_button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
/* create view and model */
GtkTreeViewColumn *p_col = gtk_tree_view_column_new();
GtkCellRenderer *p_renderer;
gtk_tree_view_column_set_title(p_col, _("Mood"));
gtk_tree_view_append_column(GTK_TREE_VIEW(s_diag->list_view), p_col);
p_renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, FALSE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"pixbuf", MOODICON_COLUMN);
p_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, TRUE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"text", MOOD_COLUMN);
/* pack widgets */
gtk_box_pack_start(GTK_BOX(hbox), refresh_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), apply_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), s_diag->list_view, TRUE, TRUE, 0);
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ s_diag->window, "destroy", cb_destroy_win },
{ s_diag->list_view, "row-activated", PBAR_GTK_CALLBACK(cb_row_activated) },
{ refresh_button, "clicked", cb_refresh_button },
{ apply_button, "clicked", cb_apply_button },
{ close_button, "clicked", cb_close_button },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(s_diag), g_signal_connections, s_diag);
/* show everything */
gtk_widget_show_all(s_diag->window);
gtk_window_present(GTK_WINDOW(s_diag->window));
return s_diag;
}
void destroy_mood_dialog(struct mood_dialog *s_diag)
{
gtk_destroy(PBAR_WIDGET(s_diag)); /* destroy widgets */
g_hash_table_destroy(s_diag->global_moods); /* free global moods */
g_free(s_diag); /* free dialog */
}
void init_mood_dialog(struct mood_dialog *s_diag)
{
GtkTreeIter empty_iter;
GdkPixbuf *empty_pixbuf;
GtkWidget *empty_image;
const gchar *empty_mood;
gchar *empty_path;
PurpleMood *mood = get_global_moods();
if(!s_diag->global_moods)
s_diag->global_moods = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
/* add empty mood to mood list */
empty_mood = "";
empty_path = get_mood_icon_path(empty_mood);
empty_image = gtk_image_new_from_file(empty_path);
empty_pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(empty_image));
g_free(empty_path);
gtk_list_store_append(s_diag->list_store, &empty_iter);
gtk_list_store_set(s_diag->list_store, &empty_iter,
MOODICON_COLUMN, empty_pixbuf,
MOOD_COLUMN, _("None"),
-1);
g_hash_table_insert(s_diag->global_moods, (gpointer)_("None"),
(gpointer)empty_mood);
for(; mood->mood ; mood++) {
if(!mood->mood || !mood->description)
continue;
GtkTreeIter iter;
GtkWidget *image;
GdkPixbuf *pixbuf;
gchar *path = get_mood_icon_path(mood->mood);
g_hash_table_insert(s_diag->global_moods, (gpointer)_(mood->description),
(gpointer)mood->mood);
image = gtk_image_new_from_file(path);
pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(image));
g_free(path);
gtk_list_store_append(s_diag->list_store, &iter);
gtk_list_store_set(s_diag->list_store, &iter,
MOODICON_COLUMN, pixbuf,
MOOD_COLUMN, _(mood->description),
-1);
}
}
diff --git a/purple.c b/purple.c
index bf47ca8..767f171 100644
--- a/purple.c
+++ b/purple.c
@@ -1,386 +1,402 @@
/* File: purple.c
- Time-stamp: <2011-02-07 20:11:54 gawen>
+ Time-stamp: <2011-02-10 17:54:01 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* this file contains common functions for libpurple and pidgin */
#include "common.h"
#include "pbar.h"
#include "gtk.h"
#include "purple.h"
/* callbacks */
static void cb_global_moods_for_each(gpointer key, gpointer value,
gpointer user_data);
static void cb_set_alias_failure(PurpleAccount *account, const char *error);
static void cb_dummy();
/* check if default gtk blist is created */
gboolean is_gtk_blist_created()
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
if(!blist ||
!blist->vbox ||
!gtk_widget_get_visible(blist->vbox))
return FALSE;
return TRUE;
}
/* get buddy icon from statusbox widget */
GdkPixbuf * get_buddy_icon()
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
const PidginStatusBox *statusbox = PIDGIN_STATUS_BOX(blist->statusbox);
return statusbox->buddy_icon;
}
/* get buddy icon hovered from statusbox widget */
GdkPixbuf * get_buddy_icon_hover()
{
const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
const PidginStatusBox *statusbox = PIDGIN_STATUS_BOX(blist->statusbox);
return statusbox->buddy_icon_hover;
}
/* create purple protocol icon from protocol info */
GdkPixbuf * create_prpl_icon_from_info(PurplePluginProtocolInfo *prpl_info,
PidginPrplIconSize size)
{
const char *protoname = NULL;
char *tmp;
char *filename = NULL;
GdkPixbuf *pixbuf;
if (prpl_info->list_icon == NULL)
return NULL;
protoname = prpl_info->list_icon(NULL, NULL);
if (protoname == NULL)
return NULL;
/*
* Status icons will be themeable too, and then it will look up
* protoname from the theme
*/
tmp = g_strconcat(protoname, ".png", NULL);
filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols",
size == PIDGIN_PRPL_ICON_SMALL ? "16" :
size == PIDGIN_PRPL_ICON_MEDIUM ? "22" : "48",
tmp, NULL);
g_free(tmp);
pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
g_free(filename);
return pixbuf;
}
/* get current status stock id */
const gchar * get_status_stock_id()
{
const PurpleSavedStatus *status = purple_savedstatus_get_current();
PurpleStatusPrimitive prim = purple_savedstatus_get_type(status);
return pidgin_stock_id_from_status_primitive(prim);
}
/* get mood icon path */
gchar * get_mood_icon_path(const gchar *mood)
{
gchar *path;
if(!mood || !strcmp(mood, ""))
path = g_build_filename(DATADIR, "pixmaps", "pidgin",
"toolbar", "16", "emote-select.png", NULL);
else if(!strcmp(mood, "busy"))
path = g_build_filename(DATADIR, "pixmaps", "pidgin",
"status", "16", "busy.png", NULL);
else if(!strcmp(mood, "hiptop"))
path = g_build_filename(DATADIR, "pixmaps", "pidgin",
"emblems", "16", "hiptop.png", NULL);
else {
gchar *filename = g_strdup_printf("%s.png", mood);
path = g_build_filename(DATADIR, "pixmaps", "pidgin",
"emotes", "small", filename, NULL);
g_free(filename);
}
return path;
}
/* get available attributes for a protocol
returned hashtable should be freed manually */
GHashTable * get_protocol_attrs(PurplePluginProtocolInfo *protocol)
{
if(!protocol->status_types)
return NULL;
GHashTable *attrs = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
GList *l = protocol->status_types(NULL);
for(; l ; l = l->next) {
PurpleStatusType *type = (PurpleStatusType *)l->data;
GList *k = purple_status_type_get_attrs(type);
for(; k ; k = k->next) {
struct _PurpleStatusAttr {
char *id;
char *name;
PurpleValue *value_type;
};
struct _PurpleStatusAttr *attr = (struct _PurpleStatusAttr *)k->data;
if(g_hash_table_lookup(attrs, attr->id))
continue;
else
g_hash_table_insert(attrs, (gpointer)attr->id,
GINT_TO_POINTER(TRUE));
}
}
return attrs;
}
/* get available attributes for an account
returned hashtable should be freed manally */
/* TODO: review this, now it does the same as get_protocol_attrs... */
GHashTable * get_account_attrs(PurpleAccount *account)
{
- GHashTable *attrs = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
+ GHashTable *attrs = g_hash_table_new_full(g_str_hash, g_str_equal,
+ NULL, NULL);
GList *l = purple_account_get_status_types(account);
for(; l ; l = l->next) {
PurpleStatusType *type = (PurpleStatusType *)l->data;
GList *k = purple_status_type_get_attrs(type);
for(; k ; k = k->next) {
struct _PurpleStatusAttr {
char *id;
char *name;
PurpleValue *value_type;
};
struct _PurpleStatusAttr *attr = (struct _PurpleStatusAttr *)k->data;
if(g_hash_table_lookup(attrs, attr->id))
continue;
else
g_hash_table_insert(attrs, (gpointer)attr->id,
GINT_TO_POINTER(TRUE));
}
}
return attrs;
}
/* get global moods */
PurpleMood * get_global_moods()
{
GHashTable *global_moods = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
GHashTable *mood_counts = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
GList *accounts = purple_accounts_get_all_active();
PurpleMood *result = NULL;
GList *out_moods = NULL;
int i = 0;
int num_accounts = 0;
for(; accounts ; accounts = g_list_delete_link(accounts, accounts)) {
PurpleAccount *account = (PurpleAccount *)accounts->data;
if(purple_account_is_connected(account)) {
PurpleConnection *gc = purple_account_get_connection(account);
if(gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS) {
- PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
+ PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(
+ gc->prpl);
PurpleMood *mood = NULL;
for(mood = prpl_info->get_moods(account) ;
mood->mood ; mood++) {
int mood_count = GPOINTER_TO_INT(g_hash_table_lookup(mood_counts,
mood->mood));
if(!g_hash_table_lookup(global_moods, mood->mood))
g_hash_table_insert(global_moods, (gpointer)mood->mood, mood);
g_hash_table_insert(mood_counts, (gpointer)mood->mood,
GINT_TO_POINTER(mood_count + 1));
}
num_accounts++;
}
}
}
g_hash_table_foreach(global_moods, cb_global_moods_for_each, &out_moods);
result = g_new0(PurpleMood, g_hash_table_size(global_moods) + 1);
while(out_moods) {
PurpleMood *mood = (PurpleMood *)out_moods->data;
int in_num_accounts = GPOINTER_TO_INT(g_hash_table_lookup(mood_counts,
mood->mood));
if(in_num_accounts == num_accounts) {
/* mood is present in all accounts supporting moods */
result[i].mood = mood->mood;
result[i].description = mood->description;
i++;
}
out_moods = g_list_delete_link(out_moods, out_moods);
}
g_hash_table_destroy(global_moods);
g_hash_table_destroy(mood_counts);
return result;
}
/* set status to the specified mood */
void set_status_with_mood(PurpleAccount *account, const gchar *mood)
{
purple_account_set_status(account, "mood", TRUE, PURPLE_MOOD_NAME, mood,
NULL);
}
-/* set exclusive status for all account */
+/* set status to the specified mood for all accounts */
+void set_status_with_mood_all(const gchar *mood)
+{
+ GList *accts = purple_accounts_get_all_active();
+ for(; accts ; accts = g_list_delete_link(accts, accts)) {
+ PurpleAccount *account = (PurpleAccount *)accts->data;
+ PurpleConnection *gc = purple_account_get_connection(account);
+
+ if(gc && gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS)
+ set_status_with_mood(account, mood);
+ }
+}
+
+
+/* set exclusive status for all accounts */
void set_status_all(const gchar *status_id, GList *attrs)
{
GList *accts = purple_accounts_get_all_active();
/* empty list means we have nothing to do */
if(!attrs)
return;
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = accts->data;
if(!purple_account_is_connected(account))
continue;
purple_account_set_status_list(account, status_id, TRUE, attrs);
}
}
/* set display name for account */
void set_display_name(PurpleAccount *account, const gchar *name)
{
const gchar *id = purple_account_get_protocol_id(account);
/* exception for set_public_alias */
if(!strcmp(id, "prpl-jabber")) {
PurpleConnection *gc = account->gc;
gchar *iq_id = g_strdup_printf("purple%x", g_random_int());
xmlnode *iq, *pubsub, *publish, *nicknode;
gc = account->gc;
iq_id = g_strdup_printf("purple%x", g_random_int());
iq = xmlnode_new("iq");
xmlnode_set_attrib(iq, "type", "set");
xmlnode_set_attrib(iq, "id", iq_id);
pubsub = xmlnode_new("pubsub");
xmlnode_set_attrib(pubsub, "xmlns", "http://jabber.org/protocol/pubsub");
publish = xmlnode_new("publish");
xmlnode_set_attrib(publish,"node","http://jabber.org/protocol/nick");
nicknode = xmlnode_new_child(xmlnode_new_child(publish, "item"), "nick");
xmlnode_set_namespace(nicknode, "http://jabber.org/protocol/nick");
xmlnode_insert_data(nicknode, name, -1);
xmlnode_insert_child(pubsub, publish);
xmlnode_insert_child(iq, pubsub);
purple_signal_emit(purple_connection_get_prpl(gc),
"jabber-sending-xmlnode", gc, &iq);
g_free(iq_id);
}
else
/* provide dummy callback since some
protocols don't check before calling */
purple_account_set_public_alias(account, name, cb_dummy,
cb_set_alias_failure);
}
/* set display name for all connected accounts */
void set_display_name_all(const char *name)
{
GList *accts = purple_accounts_get_all_active();
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = accts->data;
if(!purple_account_is_connected(account))
continue;
set_display_name(account, name);
}
}
/* set status message (personal message) */
void set_status_message(const gchar *pm)
{
PurpleSavedStatus *status = purple_savedstatus_get_current();
purple_savedstatus_set_message(status, pm);
purple_savedstatus_activate(status);
}
void prpl_connect_signals(struct pbar_widget *w,
const struct pbar_prpl_signal *sig_list,
gpointer data)
{
const struct pbar_prpl_signal *s = sig_list;
for(; s->signal ; s++)
purple_signal_connect(s->instance,
s->signal,
w,
PURPLE_CALLBACK(s->callback),
data);
}
void prpl_prefs_connect_signals(struct pbar_widget *w,
const struct pbar_prpl_signal *sig_list,
gpointer data)
{
const struct pbar_prpl_signal *s = sig_list;
for(; s->signal ; s++)
purple_prefs_connect_callback(s->instance,
s->signal,
PURPLE_PREFS_CALLBACK(s->callback),
data);
}
void prpl_disconnect_signals(struct pbar_widget *w)
{ purple_signals_disconnect_by_handle(w); }
void prpl_prefs_disconnect_signals(struct pbar_widget *w)
{ purple_prefs_disconnect_by_handle(w); }
static void cb_global_moods_for_each(gpointer key, gpointer value,
gpointer user_data)
{
GList **out_moods = (GList **)user_data;
PurpleMood *mood = (PurpleMood *)value;
*out_moods = g_list_append(*out_moods, mood);
}
static void cb_set_alias_failure(PurpleAccount *account, const char *error)
{
const gchar *id = purple_account_get_protocol_id(account);
purple_debug_info(NAME, "aliases not supported by \"%s\"\n", id);
}
static void cb_dummy() {}
diff --git a/purple.h b/purple.h
index 646e60d..9fdead9 100644
--- a/purple.h
+++ b/purple.h
@@ -1,64 +1,65 @@
/* File: purple.h
- Time-stamp: <2011-02-07 20:12:06 gawen>
+ Time-stamp: <2011-02-10 17:54:53 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _PURPLE_H_
#define _PURPLE_H_
#include "common.h"
#include "gtk.h"
struct pbar_prpl_signal {
void *instance;
const char *signal;
void *callback;
};
/* not sure purple define that */
#ifndef PURPLE_PREFS_CALLBACK
# define PURPLE_PREFS_CALLBACK(func) ((PurplePrefCallback)func)
#endif
gboolean is_gtk_blist_created();
GdkPixbuf * create_prpl_icon_from_info(PurplePluginProtocolInfo *prpl_info,
PidginPrplIconSize size);
GdkPixbuf * get_buddy_icon();
GdkPixbuf * get_buddy_icon_hover();
GHashTable * get_protocol_attrs(PurplePluginProtocolInfo *protocol);
GHashTable * get_account_attrs(PurpleAccount *account);
const gchar * get_status_stock_id();
gchar * get_mood_icon_path();
PurpleMood * get_global_moods();
void set_status_message(const gchar *pm);
void set_status_all(const gchar *status_id, GList *attrs);
void set_status_with_mood(PurpleAccount *account, const gchar *mood);
+void set_status_with_mood_all(const gchar *mood);
void set_display_name(PurpleAccount *account, const gchar *name);
void set_display_name_all(const gchar *name);
void prpl_disconnect_signals(struct pbar_widget *w);
void prpl_prefs_disconnect_signals(struct pbar_widget *w);
void prpl_connect_signals(struct pbar_widget *w,
const struct pbar_prpl_signal *sig_list,
gpointer data);
void prpl_prefs_connect_signals(struct pbar_widget *w,
const struct pbar_prpl_signal *sig_list,
gpointer data);
#endif /* _PURPLE_H_ */
diff --git a/widget_gtk.c b/widget_gtk.c
index be3b0ac..593be72 100644
--- a/widget_gtk.c
+++ b/widget_gtk.c
@@ -1,332 +1,324 @@
/* File: widget_gtk.c
- Time-stamp: <2011-02-08 19:38:55 gawen>
+ Time-stamp: <2011-02-10 17:54:23 gawen>
Copyright (C) 2010 David Hauweele <[email protected]>
Copyright (C) 2008,2009 Craig Harding <[email protected]>
Wolter Hellmund <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "preferences.h"
#include "widget_prpl.h"
#include "widget_gtk.h"
#include "widget.h"
#include "purple.h"
static void cb_icon_choose(const gchar *path, gpointer data)
{
g_return_if_fail(path);
purple_prefs_set_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon", path);
}
void cb_buddy_icon(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
GtkWidget *chooser = pidgin_buddy_icon_chooser_new(GTK_WINDOW
(gtk_widget_get_toplevel
(GTK_WIDGET(blist))),
cb_icon_choose,
NULL);
gtk_widget_show(chooser);
}
void cb_buddy_icon_enter(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
GdkPixbuf *icon = get_buddy_icon_hover();
set_widget_icon(icon);
pidgin_set_cursor(bar->icon_eventbox, GDK_HAND2);
}
void cb_buddy_icon_leave(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
GdkPixbuf *icon = get_buddy_icon();
set_widget_icon(icon);
pidgin_clear_cursor(bar->icon_eventbox);
}
void cb_name(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *name = purple_prefs_get_string(PREF "/nickname");
GdkEventButton *event = (GdkEventButton *)gtk_get_current_event();
gboolean swap = (event->button == 1);
swap = purple_prefs_get_bool(PREF "/swap-click") ? !swap : swap;
if(!name || !strcmp(name, EMPTY_NAME))
name = "";
if(swap && !bar->name_dialog) {
gtk_entry_set_text(GTK_ENTRY(bar->name_entry), name);
if(purple_prefs_get_bool(PREF "/compact"))
gtk_widget_hide(bar->pm_eventbox);
gtk_widget_hide(bar->name_eventbox);
gtk_widget_show(bar->name_entry);
gtk_widget_grab_focus(bar->name_entry);
}
else if(!bar->name_dialog)
create_name_dialog();
}
void cb_name_enter(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup-hover");
const gchar *name = purple_prefs_get_string(PREF "/nickname");
bar->hover_name = TRUE;
set_widget_name(markup, name);
}
void cb_name_leave(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup");
const gchar *name = purple_prefs_get_string(PREF "/nickname");
bar->hover_name = FALSE;
set_widget_name(markup, name);
}
void cb_name_entry(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *name = gtk_entry_get_text(GTK_ENTRY(widget));
const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup");
set_widget_name(markup, name);
purple_prefs_set_string(PREF "/nickname", name);
set_display_name_all(name);
bar->name_entry_activated = TRUE;
if(purple_prefs_get_bool(PREF "/compact"))
gtk_widget_show(bar->pm_eventbox);
gtk_widget_hide(bar->name_entry);
gtk_widget_show(bar->name_eventbox);
purple_debug_info(NAME, "nickname changed to \"%s\" by user\n", name);
}
void cb_name_entry_focus_out(GtkWidget *widget, gpointer data)
{
if(!bar->name_entry_activated)
cb_name_entry(widget, data);
bar->name_entry_activated = FALSE;
}
void cb_pm(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
GdkEventButton *event = (GdkEventButton *)gtk_get_current_event();
gboolean swap = (event->button == 1);
swap = purple_prefs_get_bool(PREF "/swap-click") ? !swap : swap;
if(!pm || !strcmp(pm, EMPTY_PM))
pm = "";
if(swap && !bar->pm_dialog) {
gtk_entry_set_text(GTK_ENTRY(bar->pm_entry), pm);
if(purple_prefs_get_bool(PREF "/compact"))
gtk_widget_hide(bar->name_eventbox);
gtk_widget_hide(bar->pm_eventbox);
gtk_widget_show(bar->pm_entry);
gtk_widget_grab_focus(bar->pm_entry);
}
else if(!bar->pm_dialog)
create_pm_dialog();
}
void cb_pm_enter(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *markup = purple_prefs_get_string(PREF "/personal-message-markup-hover");
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
bar->hover_pm = TRUE;
set_widget_pm(markup, pm);
}
void cb_pm_leave(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *markup = purple_prefs_get_string(PREF "/personal-message-markup");
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
bar->hover_pm = FALSE;
set_widget_pm(markup, pm);
}
void cb_pm_entry(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *markup = purple_prefs_get_string(PREF "/personal-message-markup");
const gchar *pm = gtk_entry_get_text(GTK_ENTRY(widget));
purple_prefs_set_string(PREF "/personal-message", pm);
/* set personal message for all protocols */
set_status_message(pm);
set_widget_pm(markup, pm);
bar->pm_entry_activated = TRUE;
if(purple_prefs_get_bool(PREF "/compact"))
gtk_widget_show(bar->name_eventbox);
gtk_widget_hide(bar->pm_entry);
gtk_widget_show(bar->pm_eventbox);
purple_debug_info(NAME, "personal message changed to \"%s\" by user\n", pm);
}
void cb_pm_entry_focus_out(GtkWidget *widget, gpointer data)
{
if(!bar->pm_entry_activated)
cb_pm_entry(widget, data);
bar->pm_entry_activated = FALSE;
}
void cb_status_button(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
GdkEventButton *event = (GdkEventButton *)gtk_get_current_event();
gtk_menu_popup(GTK_MENU(bar->status_menu), NULL, NULL, NULL, NULL,
event->button, event->time);
}
void cb_status_menu(gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
PurpleStatusType *status_type = (PurpleStatusType *)data;
PurpleStatusPrimitive type_prim = purple_status_type_get_primitive(status_type);
PurpleSavedStatus *status = purple_savedstatus_get_current();
purple_savedstatus_set_type(status, type_prim);
purple_savedstatus_set_message(status, pm);
purple_savedstatus_activate(status);
purple_debug_info(NAME, "status changed to \"%s\" by user\n",
purple_status_type_get_name(status_type));
}
void cb_mood_button(GtkWidget *widget, gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *empty_mood;
GtkWidget *menu_item, *icon;
PurpleMood *mood = get_global_moods();
GdkEventButton *event;
GList *l, *i;
gchar *path;
/* destroy dop down mood menu and create a new one */
l = gtk_container_get_children(GTK_CONTAINER(bar->mood_menu));
for(i = l ; i ; i = i->next) {
gtk_widget_destroy(l->data);
l->data = NULL;
}
gtk_widget_destroy(bar->mood_menu);
bar->mood_menu = gtk_menu_new();
/* add empty mood to mood menu */
empty_mood = "";
path = get_mood_icon_path(empty_mood);
icon = gtk_image_new_from_file(path);
menu_item = gtk_image_menu_item_new_with_label(_("None"));
g_free(path);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), icon);
gtk_menu_shell_append(GTK_MENU_SHELL(bar->mood_menu), menu_item);
g_signal_connect_swapped(menu_item, "activate",
G_CALLBACK(cb_mood_menu),
(gpointer)empty_mood);
gtk_widget_show(menu_item);
/* fill mood menu */
for( ; mood->mood ; mood++) {
if(!mood->mood || !mood->description)
continue;
path = get_mood_icon_path(mood->mood);
icon = gtk_image_new_from_file(path);
menu_item = gtk_image_menu_item_new_with_label(_(mood->description));
g_free(path);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), icon);
gtk_menu_shell_append(GTK_MENU_SHELL(bar->mood_menu), menu_item);
g_signal_connect_swapped(menu_item, "activate",
G_CALLBACK(cb_mood_menu),
(gpointer)mood->mood);
gtk_widget_show(menu_item);
}
event = (GdkEventButton *)gtk_get_current_event();
gtk_menu_popup(GTK_MENU(bar->mood_menu), NULL, NULL, NULL, NULL,
event->button, event->time);
}
void cb_mood_menu(gpointer data)
{
g_return_if_fail(bar->installed);
const gchar *mood = (const gchar *)data;
- GList *accts = purple_accounts_get_all_active();
gchar *path;
- for(; accts ; accts = g_list_delete_link(accts, accts)) {
- PurpleAccount *account = (PurpleAccount *)accts->data;
- PurpleConnection *gc = purple_account_get_connection(account);
-
- if(gc && gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS)
- set_status_with_mood(account, mood);
- }
-
+ set_status_with_mood_all(mood);
purple_prefs_set_string(PREF "/mood", mood);
path = get_mood_icon_path(mood);
set_widget_mood(path);
g_free(path);
purple_debug_info(NAME, "mood changed to \"%s\" by user\n", mood);
}
|
gawen947/pidgin-pbar
|
4523992442bdf3ed2ba76aadb4568c9893161479
|
Fix invalid global status for selection
|
diff --git a/status_dialog.c b/status_dialog.c
index 2f33043..2d3de64 100644
--- a/status_dialog.c
+++ b/status_dialog.c
@@ -1,218 +1,219 @@
/* File: status_dialog.c
- Time-stamp: <2011-02-10 16:58:30 gawen>
+ Time-stamp: <2011-02-10 17:48:54 gawen>
Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "gtk.h"
#include "preferences.h"
#include "status_dialog.h"
static void cb_destroy_win(GtkWidget *widget, gpointer data);
static void cb_close_button(GtkWidget *widget, gpointer data);
static void cb_apply_button(GtkWidget *widget, gpointer date);
static void cb_refresh_button(GtkWidget *widget, gpointer data);
static void cb_row_activated(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data);
enum {
STATUSICON_COLUMN,
STATUS_COLUMN,
N_COLUMN
};
static void cb_destroy_win(GtkWidget *widget, gpointer data)
{ destroy_status_dialog((struct status_dialog *)data); }
static void cb_row_activated(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data)
{ cb_apply_button(widget, data); }
static void cb_apply_button(GtkWidget *widget, gpointer data)
{
GtkTreeModel *model;
GtkTreeIter iter;
GtkTreeSelection *sel;
struct status_dialog *s_diag = (struct status_dialog *)data;
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(s_diag->list_view));
if(gtk_tree_selection_get_selected(sel, &model, &iter)) {
PurpleStatusType *type;
gchar *name;
gtk_tree_model_get(model, &iter, STATUS_COLUMN, &name, -1);
type = g_hash_table_lookup(s_diag->global_status, name);
if(type) { /* status type found */
destroy_status_dialog(s_diag); /* destroy dialog first */
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
PurpleStatusPrimitive prim = purple_status_type_get_primitive(type);
PurpleSavedStatus *status = purple_savedstatus_get_current();
purple_savedstatus_set_type(status, prim);
purple_savedstatus_set_message(status, pm);
purple_savedstatus_activate(status);
purple_debug_info(NAME, "status changed to \"%s\" by user\n",
purple_status_type_get_name(type));
} else
purple_debug_info(NAME, "selected status \"%s\" doesn't exists\n", name);
g_free(name);
} else
purple_debug_info(NAME, "no row selected\n");
}
static void cb_close_button(GtkWidget *widget, gpointer data)
{ destroy_status_dialog((struct status_dialog *)data); }
static void cb_refresh_button(GtkWidget *widget, gpointer data)
{
struct status_dialog *s_diag = (struct status_dialog *)data;
gtk_list_store_clear(s_diag->list_store);
init_status_dialog(s_diag);
}
struct status_dialog * create_status_dialog()
{
struct status_dialog *s_diag = g_malloc(sizeof(struct status_dialog));
memset(s_diag, 0, sizeof(struct status_dialog));
/* widgets that can be modifier along dialog lifetime */
s_diag->window = pidgin_create_dialog(_("Status selection"),
PIDGIN_HIG_BORDER,
"status-select",
TRUE);
s_diag->list_store = gtk_list_store_new(N_COLUMN,
GDK_TYPE_PIXBUF, /* STATUSICON */
G_TYPE_STRING /* STATUS */ );
s_diag->list_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
s_diag->list_store));
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(s_diag), s_diag->window);
/* widgets that are not modified */
GtkWidget *vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(
s_diag->window),
FALSE,
PIDGIN_HIG_BORDER);
GtkWidget *hbox = pidgin_dialog_get_action_area(GTK_DIALOG(s_diag->window));
GtkWidget *refresh_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
GtkWidget *apply_button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
/* create view and model */
GtkTreeViewColumn *p_col = gtk_tree_view_column_new();
GtkCellRenderer *p_renderer;
gtk_tree_view_column_set_title(p_col, _("Status"));
gtk_tree_view_append_column(GTK_TREE_VIEW(s_diag->list_view), p_col);
p_renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, FALSE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"pixbuf", STATUSICON_COLUMN);
p_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, TRUE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"text", STATUS_COLUMN);
/* pack widgets */
gtk_box_pack_start(GTK_BOX(hbox), refresh_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), apply_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), s_diag->list_view, TRUE, TRUE, 0);
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ s_diag->window, "destroy", cb_destroy_win },
{ s_diag->list_view, "row-activated", PBAR_GTK_CALLBACK(cb_row_activated) },
{ refresh_button, "clicked", cb_refresh_button },
{ apply_button, "clicked", cb_apply_button },
{ close_button, "clicked", cb_close_button },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(s_diag), g_signal_connections, s_diag);
/* show everything */
gtk_widget_show_all(s_diag->window);
gtk_window_present(GTK_WINDOW(s_diag->window));
return s_diag;
}
void destroy_status_dialog(struct status_dialog *s_diag)
{
gtk_destroy(PBAR_WIDGET(s_diag)); /* destroy widgets */
g_hash_table_destroy(s_diag->global_status); /* free global status */
g_free(s_diag); /* free dialog */
}
void init_status_dialog(struct status_dialog *s_diag)
{
GList *a = purple_accounts_get_all_active();
GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
if(!s_diag->global_status)
s_diag->global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
for(; a ; a = g_list_delete_link(a, a)) {
PurpleAccount *acct = (PurpleAccount *)a->data;
GList *types = purple_account_get_status_types(acct);
for(; types ; types = types->next) {
GtkTreeIter iter;
GdkPixbuf *icon;
PurpleStatusType *type = (PurpleStatusType *)types->data;
PurpleStatusPrimitive prim;
const gchar *stock, *status_name;
if(!purple_status_type_is_user_settable(type) ||
purple_status_type_is_independent(type))
continue;
prim = purple_status_type_get_primitive(type);
stock = pidgin_stock_id_from_status_primitive(prim);
if(g_hash_table_lookup(global_status, stock))
continue;
else
g_hash_table_insert(global_status, (gpointer)stock,
GINT_TO_POINTER(TRUE));
status_name = purple_status_type_get_name(type);
icon = gtk_widget_render_icon(s_diag->window, stock,
GTK_ICON_SIZE_MENU, NULL);
- g_hash_table_insert(s_diag->global_status, (gpointer)status_name, type);
+ g_hash_table_insert(s_diag->global_status, (gpointer)_(status_name),
+ type);
gtk_list_store_append(s_diag->list_store, &iter);
gtk_list_store_set(s_diag->list_store, &iter,
STATUSICON_COLUMN, icon,
STATUS_COLUMN, status_name,
-1);
}
}
g_hash_table_destroy(global_status);
}
|
gawen947/pidgin-pbar
|
bcf3632518b566d60662c1f423a1e956d3e66a72
|
Fix typo
|
diff --git a/mood_dialog.c b/mood_dialog.c
index fd5f04b..cd9aae9 100644
--- a/mood_dialog.c
+++ b/mood_dialog.c
@@ -1,230 +1,229 @@
/* File: mood_dialog.c
- Time-stamp: <2011-02-10 17:45:26 gawen>
+ Time-stamp: <2011-02-10 17:48:14 gawen>
Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "gtk.h"
#include "purple.h"
#include "preferences.h"
#include "mood_dialog.h"
static void cb_destroy_win(GtkWidget *widget, gpointer data);
static void cb_close_button(GtkWidget *widget, gpointer data);
static void cb_apply_button(GtkWidget *widget, gpointer date);
static void cb_refresh_button(GtkWidget *widget, gpointer data);
static void cb_row_activated(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data);
enum {
MOODICON_COLUMN,
MOOD_COLUMN,
N_COLUMN
};
static void cb_destroy_win(GtkWidget *widget, gpointer data)
{ destroy_mood_dialog((struct mood_dialog *)data); }
static void cb_row_activated(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data)
{ cb_apply_button(widget, data); }
static void cb_apply_button(GtkWidget *widget, gpointer data)
{
GtkTreeModel *model;
GtkTreeIter iter;
GtkTreeSelection *sel;
struct mood_dialog *s_diag = (struct mood_dialog *)data;
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(s_diag->list_view));
if(gtk_tree_selection_get_selected(sel, &model, &iter)) {
/* TODO: factorisation, use set_mood_all or similar */
const gchar *mood;
gchar *name;
gtk_tree_model_get(model, &iter, MOOD_COLUMN, &name, -1);
mood = g_hash_table_lookup(s_diag->global_moods, name);
if(mood) { /* mood found */
GList *accts = purple_accounts_get_all_active();
gchar *path;
destroy_mood_dialog(s_diag); /* destroy dialog first */
for(; accts ; accts = g_list_delete_link(accts, accts)) {
PurpleAccount *account = (PurpleAccount *)accts->data;
PurpleConnection *gc = purple_account_get_connection(account);
if(gc && gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS)
set_status_with_mood(account, mood);
}
purple_prefs_set_string(PREF "/mood", mood);
path = get_mood_icon_path(mood);
set_widget_mood(path);
g_free(path);
purple_debug_info(NAME, "mood changed to \"%s\" by user\n", mood);
} else
purple_debug_info(NAME, "selected mood \"%s\" doesn't exists\n", name);
g_free(name);
} else
purple_debug_info(NAME, "no row selected\n");
}
static void cb_close_button(GtkWidget *widget, gpointer data)
{ destroy_mood_dialog((struct mood_dialog *)data); }
static void cb_refresh_button(GtkWidget *widget, gpointer data)
{
struct mood_dialog *s_diag = (struct mood_dialog *)data;
gtk_list_store_clear(s_diag->list_store);
init_mood_dialog(s_diag);
}
struct mood_dialog * create_mood_dialog()
{
struct mood_dialog *s_diag = g_malloc(sizeof(struct mood_dialog));
memset(s_diag, 0, sizeof(struct mood_dialog));
/* widgets that can be modifier along dialog lifetime */
s_diag->window = pidgin_create_dialog(_("Mood selection"),
PIDGIN_HIG_BORDER,
"mood-select",
TRUE);
s_diag->list_store = gtk_list_store_new(N_COLUMN,
GDK_TYPE_PIXBUF, /* MOODICON */
G_TYPE_STRING /* MOOD */ );
s_diag->list_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
s_diag->list_store));
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(s_diag), s_diag->window);
/* widgets that are not modified */
GtkWidget *vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(
s_diag->window),
FALSE,
PIDGIN_HIG_BORDER);
GtkWidget *hbox = pidgin_dialog_get_action_area(GTK_DIALOG(s_diag->window));
GtkWidget *refresh_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
GtkWidget *apply_button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
/* create view and model */
GtkTreeViewColumn *p_col = gtk_tree_view_column_new();
GtkCellRenderer *p_renderer;
gtk_tree_view_column_set_title(p_col, _("Mood"));
gtk_tree_view_append_column(GTK_TREE_VIEW(s_diag->list_view), p_col);
p_renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, FALSE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"pixbuf", MOODICON_COLUMN);
p_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, TRUE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"text", MOOD_COLUMN);
/* pack widgets */
gtk_box_pack_start(GTK_BOX(hbox), refresh_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), apply_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), s_diag->list_view, TRUE, TRUE, 0);
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ s_diag->window, "destroy", cb_destroy_win },
{ s_diag->list_view, "row-activated", PBAR_GTK_CALLBACK(cb_row_activated) },
{ refresh_button, "clicked", cb_refresh_button },
{ apply_button, "clicked", cb_apply_button },
{ close_button, "clicked", cb_close_button },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(s_diag), g_signal_connections, s_diag);
/* show everything */
gtk_widget_show_all(s_diag->window);
gtk_window_present(GTK_WINDOW(s_diag->window));
return s_diag;
}
void destroy_mood_dialog(struct mood_dialog *s_diag)
{
gtk_destroy(PBAR_WIDGET(s_diag)); /* destroy widgets */
g_hash_table_destroy(s_diag->global_moods); /* free global moods */
g_free(s_diag); /* free dialog */
}
void init_mood_dialog(struct mood_dialog *s_diag)
{
GtkTreeIter empty_iter;
GdkPixbuf *empty_pixbuf;
GtkWidget *empty_image;
const gchar *empty_mood;
gchar *empty_path;
PurpleMood *mood = get_global_moods();
if(!s_diag->global_moods)
s_diag->global_moods = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
/* add empty mood to mood list */
empty_mood = "";
empty_path = get_mood_icon_path(empty_mood);
empty_image = gtk_image_new_from_file(empty_path);
empty_pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(empty_image));
g_free(empty_path);
gtk_list_store_append(s_diag->list_store, &empty_iter);
gtk_list_store_set(s_diag->list_store, &empty_iter,
MOODICON_COLUMN, empty_pixbuf,
MOOD_COLUMN, _("None"),
-1);
g_hash_table_insert(s_diag->global_moods, (gpointer)_("None"),
(gpointer)empty_mood);
-
for(; mood->mood ; mood++) {
if(!mood->mood || !mood->description)
continue;
GtkTreeIter iter;
GtkWidget *image;
GdkPixbuf *pixbuf;
gchar *path = get_mood_icon_path(mood->mood);
g_hash_table_insert(s_diag->global_moods, (gpointer)_(mood->description),
(gpointer)mood->mood);
image = gtk_image_new_from_file(path);
pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(image));
g_free(path);
gtk_list_store_append(s_diag->list_store, &iter);
gtk_list_store_set(s_diag->list_store, &iter,
MOODICON_COLUMN, pixbuf,
MOOD_COLUMN, _(mood->description),
-1);
}
}
|
gawen947/pidgin-pbar
|
ead2b78a605a0ca80672412cf2dc4dbcf7afabe0
|
Add mood dialog
|
diff --git a/actions.c b/actions.c
index 19cd229..60b5ad5 100644
--- a/actions.c
+++ b/actions.c
@@ -1,101 +1,104 @@
/* File: actions.c
- Time-stamp: <2011-02-09 20:11:28 gawen>
+ Time-stamp: <2011-02-10 17:40:19 gawen>
Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "pbar.h"
#include "widget.h"
#include "purple.h"
#include "protocol_features.h"
#include "acct_features.h"
#include "status_dialog.h"
+#include "mood_dialog.h"
static void cb_icon_choose(const gchar *path, gpointer data)
{
g_return_if_fail(path);
purple_prefs_set_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon", path);
}
static void protocol_features(PurplePluginAction *act)
{
struct protocol_features_dialog *f_diag = create_protocol_features_dialog();
init_protocol_features_dialog(f_diag);
}
static void acct_features(PurplePluginAction *act)
{
struct acct_features_dialog *f_diag = create_acct_features_dialog();
init_acct_features_dialog(f_diag);
}
static void change_nickname(PurplePluginAction *act)
{ create_name_dialog(); }
static void change_pm(PurplePluginAction *act)
{ create_pm_dialog(); }
static void change_status(PurplePluginAction *act)
{
struct status_dialog *s_diag = create_status_dialog();
init_status_dialog(s_diag);
}
static void change_mood(PurplePluginAction *act)
{
+ struct mood_dialog *s_diag = create_mood_dialog();
+ init_mood_dialog(s_diag);
}
static void change_icon(PurplePluginAction *act)
{
g_return_if_fail(bar->installed);
PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
GtkWidget *chooser = pidgin_buddy_icon_chooser_new(GTK_WINDOW
(gtk_widget_get_toplevel
(GTK_WIDGET(blist))),
cb_icon_choose,
NULL);
gtk_widget_show(chooser);
}
GList * create_actions(PurplePlugin *plugin, gpointer ctx)
{
GList *l = NULL;
const struct action {
const gchar *title;
void (*action)(PurplePluginAction *);
} actions[] = {
{ N_("Change nickname"), change_nickname },
{ N_("Change personal message"), change_pm },
{ N_("Change status"), change_status },
{ N_("Change mood"), change_mood },
{ N_("Change icon"), change_icon },
{ N_("Protocol features"), protocol_features },
{ N_("Account features"), acct_features },
{ NULL, NULL }
}; const struct action *acts = actions;
for(; acts->title ; acts++) {
PurplePluginAction *act = purple_plugin_action_new(_(acts->title),
acts->action);
l = g_list_append(l, act);
}
return l;
}
diff --git a/mood_dialog.c b/mood_dialog.c
new file mode 100644
index 0000000..fd5f04b
--- /dev/null
+++ b/mood_dialog.c
@@ -0,0 +1,230 @@
+/* File: mood_dialog.c
+ Time-stamp: <2011-02-10 17:45:26 gawen>
+
+ Copyright (C) 2011 David Hauweele <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "common.h"
+
+#include "gtk.h"
+#include "purple.h"
+#include "preferences.h"
+#include "mood_dialog.h"
+
+static void cb_destroy_win(GtkWidget *widget, gpointer data);
+static void cb_close_button(GtkWidget *widget, gpointer data);
+static void cb_apply_button(GtkWidget *widget, gpointer date);
+static void cb_refresh_button(GtkWidget *widget, gpointer data);
+static void cb_row_activated(GtkWidget *widget,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ gpointer data);
+
+enum {
+ MOODICON_COLUMN,
+ MOOD_COLUMN,
+ N_COLUMN
+};
+
+static void cb_destroy_win(GtkWidget *widget, gpointer data)
+{ destroy_mood_dialog((struct mood_dialog *)data); }
+
+static void cb_row_activated(GtkWidget *widget,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ gpointer data)
+{ cb_apply_button(widget, data); }
+
+static void cb_apply_button(GtkWidget *widget, gpointer data)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreeSelection *sel;
+ struct mood_dialog *s_diag = (struct mood_dialog *)data;
+
+ sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(s_diag->list_view));
+ if(gtk_tree_selection_get_selected(sel, &model, &iter)) {
+ /* TODO: factorisation, use set_mood_all or similar */
+ const gchar *mood;
+ gchar *name;
+
+ gtk_tree_model_get(model, &iter, MOOD_COLUMN, &name, -1);
+ mood = g_hash_table_lookup(s_diag->global_moods, name);
+
+ if(mood) { /* mood found */
+ GList *accts = purple_accounts_get_all_active();
+ gchar *path;
+
+ destroy_mood_dialog(s_diag); /* destroy dialog first */
+
+ for(; accts ; accts = g_list_delete_link(accts, accts)) {
+ PurpleAccount *account = (PurpleAccount *)accts->data;
+ PurpleConnection *gc = purple_account_get_connection(account);
+
+ if(gc && gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS)
+ set_status_with_mood(account, mood);
+ }
+
+ purple_prefs_set_string(PREF "/mood", mood);
+ path = get_mood_icon_path(mood);
+ set_widget_mood(path);
+ g_free(path);
+
+ purple_debug_info(NAME, "mood changed to \"%s\" by user\n", mood);
+ } else
+ purple_debug_info(NAME, "selected mood \"%s\" doesn't exists\n", name);
+ g_free(name);
+ } else
+ purple_debug_info(NAME, "no row selected\n");
+}
+
+static void cb_close_button(GtkWidget *widget, gpointer data)
+
+{ destroy_mood_dialog((struct mood_dialog *)data); }
+
+static void cb_refresh_button(GtkWidget *widget, gpointer data)
+{
+ struct mood_dialog *s_diag = (struct mood_dialog *)data;
+ gtk_list_store_clear(s_diag->list_store);
+ init_mood_dialog(s_diag);
+}
+
+struct mood_dialog * create_mood_dialog()
+{
+ struct mood_dialog *s_diag = g_malloc(sizeof(struct mood_dialog));
+ memset(s_diag, 0, sizeof(struct mood_dialog));
+
+ /* widgets that can be modifier along dialog lifetime */
+ s_diag->window = pidgin_create_dialog(_("Mood selection"),
+ PIDGIN_HIG_BORDER,
+ "mood-select",
+ TRUE);
+ s_diag->list_store = gtk_list_store_new(N_COLUMN,
+ GDK_TYPE_PIXBUF, /* MOODICON */
+ G_TYPE_STRING /* MOOD */ );
+ s_diag->list_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
+ s_diag->list_store));
+
+
+ /* add main widgets */
+ gtk_add_main_widget(PBAR_WIDGET(s_diag), s_diag->window);
+
+ /* widgets that are not modified */
+ GtkWidget *vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(
+ s_diag->window),
+ FALSE,
+ PIDGIN_HIG_BORDER);
+ GtkWidget *hbox = pidgin_dialog_get_action_area(GTK_DIALOG(s_diag->window));
+ GtkWidget *refresh_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
+ GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
+ GtkWidget *apply_button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
+
+ /* create view and model */
+ GtkTreeViewColumn *p_col = gtk_tree_view_column_new();
+ GtkCellRenderer *p_renderer;
+ gtk_tree_view_column_set_title(p_col, _("Mood"));
+ gtk_tree_view_append_column(GTK_TREE_VIEW(s_diag->list_view), p_col);
+ p_renderer = gtk_cell_renderer_pixbuf_new();
+ gtk_tree_view_column_pack_start(p_col, p_renderer, FALSE);
+ gtk_tree_view_column_add_attribute(p_col, p_renderer,
+ "pixbuf", MOODICON_COLUMN);
+ p_renderer = gtk_cell_renderer_text_new();
+ gtk_tree_view_column_pack_start(p_col, p_renderer, TRUE);
+ gtk_tree_view_column_add_attribute(p_col, p_renderer,
+ "text", MOOD_COLUMN);
+
+ /* pack widgets */
+ gtk_box_pack_start(GTK_BOX(hbox), refresh_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), apply_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), s_diag->list_view, TRUE, TRUE, 0);
+
+ /* gtk signals and callback */
+ const struct pbar_gtk_signal g_signal_connections[] = {
+ { s_diag->window, "destroy", cb_destroy_win },
+ { s_diag->list_view, "row-activated", PBAR_GTK_CALLBACK(cb_row_activated) },
+ { refresh_button, "clicked", cb_refresh_button },
+ { apply_button, "clicked", cb_apply_button },
+ { close_button, "clicked", cb_close_button },
+ { NULL, NULL, NULL }
+ };
+
+ /* connect signals and save handlers and instance when needed
+ to disconnect those signals when the widget is destroyed */
+ gtk_connect_signals(PBAR_WIDGET(s_diag), g_signal_connections, s_diag);
+
+ /* show everything */
+ gtk_widget_show_all(s_diag->window);
+ gtk_window_present(GTK_WINDOW(s_diag->window));
+
+ return s_diag;
+}
+
+void destroy_mood_dialog(struct mood_dialog *s_diag)
+{
+ gtk_destroy(PBAR_WIDGET(s_diag)); /* destroy widgets */
+ g_hash_table_destroy(s_diag->global_moods); /* free global moods */
+ g_free(s_diag); /* free dialog */
+}
+
+void init_mood_dialog(struct mood_dialog *s_diag)
+{
+ GtkTreeIter empty_iter;
+ GdkPixbuf *empty_pixbuf;
+ GtkWidget *empty_image;
+ const gchar *empty_mood;
+ gchar *empty_path;
+ PurpleMood *mood = get_global_moods();
+
+ if(!s_diag->global_moods)
+ s_diag->global_moods = g_hash_table_new_full(g_str_hash, g_str_equal,
+ NULL, NULL);
+
+ /* add empty mood to mood list */
+ empty_mood = "";
+ empty_path = get_mood_icon_path(empty_mood);
+ empty_image = gtk_image_new_from_file(empty_path);
+ empty_pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(empty_image));
+ g_free(empty_path);
+ gtk_list_store_append(s_diag->list_store, &empty_iter);
+ gtk_list_store_set(s_diag->list_store, &empty_iter,
+ MOODICON_COLUMN, empty_pixbuf,
+ MOOD_COLUMN, _("None"),
+ -1);
+ g_hash_table_insert(s_diag->global_moods, (gpointer)_("None"),
+ (gpointer)empty_mood);
+
+
+ for(; mood->mood ; mood++) {
+ if(!mood->mood || !mood->description)
+ continue;
+ GtkTreeIter iter;
+ GtkWidget *image;
+ GdkPixbuf *pixbuf;
+ gchar *path = get_mood_icon_path(mood->mood);
+
+ g_hash_table_insert(s_diag->global_moods, (gpointer)_(mood->description),
+ (gpointer)mood->mood);
+ image = gtk_image_new_from_file(path);
+ pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(image));
+ g_free(path);
+
+ gtk_list_store_append(s_diag->list_store, &iter);
+ gtk_list_store_set(s_diag->list_store, &iter,
+ MOODICON_COLUMN, pixbuf,
+ MOOD_COLUMN, _(mood->description),
+ -1);
+ }
+}
diff --git a/mood_dialog.h b/mood_dialog.h
new file mode 100644
index 0000000..de68b99
--- /dev/null
+++ b/mood_dialog.h
@@ -0,0 +1,42 @@
+/* File: mood_dialog.h
+ Time-stamp: <2011-02-10 17:09:37 gawen>
+
+ Copyright (C) 2011 David Hauweele <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _MOOD_DIALOG_H_
+#define _MOOD_DIALOG_H_
+
+#include "common.h"
+
+#include "gtk.h"
+
+struct mood_dialog {
+ BEGIN_PBAR_WIDGET;
+
+ /* window and list */
+ GtkWidget *window;
+ GtkWidget *list_view;
+ GtkListStore *list_store;
+
+ /* global moods for selection */
+ GHashTable *global_moods;
+};
+
+struct mood_dialog * create_mood_dialog();
+void destroy_mood_dialog(struct mood_dialog *s_diag);
+void init_mood_dialog(struct mood_dialog *s_diag);
+
+#endif /* _MOOD_DIALOG_H_ */
|
gawen947/pidgin-pbar
|
d128d788ae63cba30668cab6652abe6e6ff70511
|
Fix typo
|
diff --git a/status_dialog.c b/status_dialog.c
index ba52b86..2f33043 100644
--- a/status_dialog.c
+++ b/status_dialog.c
@@ -1,218 +1,218 @@
/* File: status_dialog.c
- Time-stamp: <2011-02-10 16:52:56 gawen>
+ Time-stamp: <2011-02-10 16:58:30 gawen>
Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "gtk.h"
#include "preferences.h"
#include "status_dialog.h"
static void cb_destroy_win(GtkWidget *widget, gpointer data);
static void cb_close_button(GtkWidget *widget, gpointer data);
static void cb_apply_button(GtkWidget *widget, gpointer date);
static void cb_refresh_button(GtkWidget *widget, gpointer data);
static void cb_row_activated(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data);
enum {
STATUSICON_COLUMN,
STATUS_COLUMN,
N_COLUMN
};
static void cb_destroy_win(GtkWidget *widget, gpointer data)
{ destroy_status_dialog((struct status_dialog *)data); }
static void cb_row_activated(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data)
{ cb_apply_button(widget, data); }
static void cb_apply_button(GtkWidget *widget, gpointer data)
{
GtkTreeModel *model;
GtkTreeIter iter;
GtkTreeSelection *sel;
struct status_dialog *s_diag = (struct status_dialog *)data;
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(s_diag->list_view));
if(gtk_tree_selection_get_selected(sel, &model, &iter)) {
PurpleStatusType *type;
gchar *name;
gtk_tree_model_get(model, &iter, STATUS_COLUMN, &name, -1);
type = g_hash_table_lookup(s_diag->global_status, name);
if(type) { /* status type found */
- destroy_status_dialog(s_diag); /* destroy dialog fist */
+ destroy_status_dialog(s_diag); /* destroy dialog first */
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
PurpleStatusPrimitive prim = purple_status_type_get_primitive(type);
PurpleSavedStatus *status = purple_savedstatus_get_current();
purple_savedstatus_set_type(status, prim);
purple_savedstatus_set_message(status, pm);
purple_savedstatus_activate(status);
purple_debug_info(NAME, "status changed to \"%s\" by user\n",
purple_status_type_get_name(type));
} else
purple_debug_info(NAME, "selected status \"%s\" doesn't exists\n", name);
g_free(name);
} else
purple_debug_info(NAME, "no row selected\n");
}
static void cb_close_button(GtkWidget *widget, gpointer data)
{ destroy_status_dialog((struct status_dialog *)data); }
static void cb_refresh_button(GtkWidget *widget, gpointer data)
{
struct status_dialog *s_diag = (struct status_dialog *)data;
gtk_list_store_clear(s_diag->list_store);
init_status_dialog(s_diag);
}
struct status_dialog * create_status_dialog()
{
struct status_dialog *s_diag = g_malloc(sizeof(struct status_dialog));
memset(s_diag, 0, sizeof(struct status_dialog));
/* widgets that can be modifier along dialog lifetime */
s_diag->window = pidgin_create_dialog(_("Status selection"),
PIDGIN_HIG_BORDER,
"status-select",
TRUE);
s_diag->list_store = gtk_list_store_new(N_COLUMN,
GDK_TYPE_PIXBUF, /* STATUSICON */
G_TYPE_STRING /* STATUS */ );
s_diag->list_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
s_diag->list_store));
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(s_diag), s_diag->window);
/* widgets that are not modified */
GtkWidget *vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(
s_diag->window),
FALSE,
PIDGIN_HIG_BORDER);
GtkWidget *hbox = pidgin_dialog_get_action_area(GTK_DIALOG(s_diag->window));
GtkWidget *refresh_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
GtkWidget *apply_button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
/* create view and model */
GtkTreeViewColumn *p_col = gtk_tree_view_column_new();
GtkCellRenderer *p_renderer;
gtk_tree_view_column_set_title(p_col, _("Status"));
gtk_tree_view_append_column(GTK_TREE_VIEW(s_diag->list_view), p_col);
p_renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, FALSE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"pixbuf", STATUSICON_COLUMN);
p_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, TRUE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"text", STATUS_COLUMN);
/* pack widgets */
gtk_box_pack_start(GTK_BOX(hbox), refresh_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), apply_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), s_diag->list_view, TRUE, TRUE, 0);
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ s_diag->window, "destroy", cb_destroy_win },
{ s_diag->list_view, "row-activated", PBAR_GTK_CALLBACK(cb_row_activated) },
{ refresh_button, "clicked", cb_refresh_button },
{ apply_button, "clicked", cb_apply_button },
{ close_button, "clicked", cb_close_button },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(s_diag), g_signal_connections, s_diag);
/* show everything */
gtk_widget_show_all(s_diag->window);
gtk_window_present(GTK_WINDOW(s_diag->window));
return s_diag;
}
void destroy_status_dialog(struct status_dialog *s_diag)
{
gtk_destroy(PBAR_WIDGET(s_diag)); /* destroy widgets */
g_hash_table_destroy(s_diag->global_status); /* free global status */
g_free(s_diag); /* free dialog */
}
void init_status_dialog(struct status_dialog *s_diag)
{
GList *a = purple_accounts_get_all_active();
GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
if(!s_diag->global_status)
s_diag->global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
for(; a ; a = g_list_delete_link(a, a)) {
PurpleAccount *acct = (PurpleAccount *)a->data;
GList *types = purple_account_get_status_types(acct);
for(; types ; types = types->next) {
GtkTreeIter iter;
GdkPixbuf *icon;
PurpleStatusType *type = (PurpleStatusType *)types->data;
PurpleStatusPrimitive prim;
const gchar *stock, *status_name;
if(!purple_status_type_is_user_settable(type) ||
purple_status_type_is_independent(type))
continue;
prim = purple_status_type_get_primitive(type);
stock = pidgin_stock_id_from_status_primitive(prim);
if(g_hash_table_lookup(global_status, stock))
continue;
else
g_hash_table_insert(global_status, (gpointer)stock,
GINT_TO_POINTER(TRUE));
status_name = purple_status_type_get_name(type);
icon = gtk_widget_render_icon(s_diag->window, stock,
GTK_ICON_SIZE_MENU, NULL);
g_hash_table_insert(s_diag->global_status, (gpointer)status_name, type);
gtk_list_store_append(s_diag->list_store, &iter);
gtk_list_store_set(s_diag->list_store, &iter,
STATUSICON_COLUMN, icon,
STATUS_COLUMN, status_name,
-1);
}
}
g_hash_table_destroy(global_status);
}
|
gawen947/pidgin-pbar
|
57d5b3620ecf7ba17f95c4902abbc627f08a8fdd
|
Remove a warning
|
diff --git a/gtk.h b/gtk.h
index e262ea3..db8c406 100644
--- a/gtk.h
+++ b/gtk.h
@@ -1,51 +1,52 @@
/* File: gtk.h
- Time-stamp: <2011-02-07 18:33:20 gawen>
+ Time-stamp: <2011-02-10 16:52:27 gawen>
Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _GTK_H_
#define _GTK_H_
#include "common.h"
+#define PBAR_GTK_CALLBACK(func) ((void (*)(GtkWidget *, gpointer))func)
#define PBAR_WIDGET(widget) ((struct pbar_widget *)widget)
#define BEGIN_PBAR_WIDGET GList *gtk_hnd; \
GList *gtk_inst; \
GList *main_widgets
struct pbar_gtk_signal {
GtkWidget *widget;
const gchar *signal;
void (*callback)(GtkWidget *, gpointer);
};
struct pbar_widget {
BEGIN_PBAR_WIDGET; /* signals handlers and instance for disconnection */
};
#if !GTK_CHECK_VERSION(2,18,0)
gboolean gtk_widget_get_visible(GtkWidget *widget);
void gtk_widget_set_visible(GtkWidget *widget, gboolean visible);
void gtk_widget_set_can_focus(GtkWidget *widget, gboolean can_focus);
#endif /* GTK < 2.18 */
void gtk_destroy(struct pbar_widget *w);
void gtk_add_main_widget(struct pbar_widget *w, GtkWidget *widget);
void gtk_connect_signals(struct pbar_widget *w,
const struct pbar_gtk_signal *sig_list,
gpointer data);
#endif /* _GTK_H_ */
diff --git a/status_dialog.c b/status_dialog.c
index 6f9d747..ba52b86 100644
--- a/status_dialog.c
+++ b/status_dialog.c
@@ -1,217 +1,218 @@
/* File: status_dialog.c
- Time-stamp: <2011-02-10 16:46:34 gawen>
+ Time-stamp: <2011-02-10 16:52:56 gawen>
Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "gtk.h"
#include "preferences.h"
#include "status_dialog.h"
static void cb_destroy_win(GtkWidget *widget, gpointer data);
static void cb_close_button(GtkWidget *widget, gpointer data);
static void cb_apply_button(GtkWidget *widget, gpointer date);
static void cb_refresh_button(GtkWidget *widget, gpointer data);
static void cb_row_activated(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data);
enum {
STATUSICON_COLUMN,
STATUS_COLUMN,
N_COLUMN
};
static void cb_destroy_win(GtkWidget *widget, gpointer data)
{ destroy_status_dialog((struct status_dialog *)data); }
static void cb_row_activated(GtkWidget *widget,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data)
{ cb_apply_button(widget, data); }
static void cb_apply_button(GtkWidget *widget, gpointer data)
{
GtkTreeModel *model;
GtkTreeIter iter;
GtkTreeSelection *sel;
struct status_dialog *s_diag = (struct status_dialog *)data;
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(s_diag->list_view));
if(gtk_tree_selection_get_selected(sel, &model, &iter)) {
PurpleStatusType *type;
gchar *name;
gtk_tree_model_get(model, &iter, STATUS_COLUMN, &name, -1);
type = g_hash_table_lookup(s_diag->global_status, name);
if(type) { /* status type found */
+ destroy_status_dialog(s_diag); /* destroy dialog fist */
+
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
PurpleStatusPrimitive prim = purple_status_type_get_primitive(type);
PurpleSavedStatus *status = purple_savedstatus_get_current();
purple_savedstatus_set_type(status, prim);
purple_savedstatus_set_message(status, pm);
purple_savedstatus_activate(status);
purple_debug_info(NAME, "status changed to \"%s\" by user\n",
purple_status_type_get_name(type));
- destroy_status_dialog(s_diag); /* destroy dialog */
} else
purple_debug_info(NAME, "selected status \"%s\" doesn't exists\n", name);
g_free(name);
} else
purple_debug_info(NAME, "no row selected\n");
}
static void cb_close_button(GtkWidget *widget, gpointer data)
{ destroy_status_dialog((struct status_dialog *)data); }
static void cb_refresh_button(GtkWidget *widget, gpointer data)
{
struct status_dialog *s_diag = (struct status_dialog *)data;
gtk_list_store_clear(s_diag->list_store);
init_status_dialog(s_diag);
}
struct status_dialog * create_status_dialog()
{
struct status_dialog *s_diag = g_malloc(sizeof(struct status_dialog));
memset(s_diag, 0, sizeof(struct status_dialog));
/* widgets that can be modifier along dialog lifetime */
s_diag->window = pidgin_create_dialog(_("Status selection"),
PIDGIN_HIG_BORDER,
"status-select",
TRUE);
s_diag->list_store = gtk_list_store_new(N_COLUMN,
GDK_TYPE_PIXBUF, /* STATUSICON */
G_TYPE_STRING /* STATUS */ );
s_diag->list_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
s_diag->list_store));
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(s_diag), s_diag->window);
/* widgets that are not modified */
GtkWidget *vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(
s_diag->window),
FALSE,
PIDGIN_HIG_BORDER);
GtkWidget *hbox = pidgin_dialog_get_action_area(GTK_DIALOG(s_diag->window));
GtkWidget *refresh_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
GtkWidget *apply_button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
/* create view and model */
GtkTreeViewColumn *p_col = gtk_tree_view_column_new();
GtkCellRenderer *p_renderer;
gtk_tree_view_column_set_title(p_col, _("Status"));
gtk_tree_view_append_column(GTK_TREE_VIEW(s_diag->list_view), p_col);
p_renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, FALSE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"pixbuf", STATUSICON_COLUMN);
p_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, TRUE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"text", STATUS_COLUMN);
/* pack widgets */
gtk_box_pack_start(GTK_BOX(hbox), refresh_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), apply_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), s_diag->list_view, TRUE, TRUE, 0);
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ s_diag->window, "destroy", cb_destroy_win },
- { s_diag->list_view, "row-activated", cb_row_activated },
+ { s_diag->list_view, "row-activated", PBAR_GTK_CALLBACK(cb_row_activated) },
{ refresh_button, "clicked", cb_refresh_button },
{ apply_button, "clicked", cb_apply_button },
{ close_button, "clicked", cb_close_button },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(s_diag), g_signal_connections, s_diag);
/* show everything */
gtk_widget_show_all(s_diag->window);
gtk_window_present(GTK_WINDOW(s_diag->window));
return s_diag;
}
void destroy_status_dialog(struct status_dialog *s_diag)
{
gtk_destroy(PBAR_WIDGET(s_diag)); /* destroy widgets */
g_hash_table_destroy(s_diag->global_status); /* free global status */
g_free(s_diag); /* free dialog */
}
void init_status_dialog(struct status_dialog *s_diag)
{
GList *a = purple_accounts_get_all_active();
GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
if(!s_diag->global_status)
s_diag->global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
for(; a ; a = g_list_delete_link(a, a)) {
PurpleAccount *acct = (PurpleAccount *)a->data;
GList *types = purple_account_get_status_types(acct);
for(; types ; types = types->next) {
GtkTreeIter iter;
GdkPixbuf *icon;
PurpleStatusType *type = (PurpleStatusType *)types->data;
PurpleStatusPrimitive prim;
const gchar *stock, *status_name;
if(!purple_status_type_is_user_settable(type) ||
purple_status_type_is_independent(type))
continue;
prim = purple_status_type_get_primitive(type);
stock = pidgin_stock_id_from_status_primitive(prim);
if(g_hash_table_lookup(global_status, stock))
continue;
else
g_hash_table_insert(global_status, (gpointer)stock,
GINT_TO_POINTER(TRUE));
status_name = purple_status_type_get_name(type);
icon = gtk_widget_render_icon(s_diag->window, stock,
GTK_ICON_SIZE_MENU, NULL);
g_hash_table_insert(s_diag->global_status, (gpointer)status_name, type);
gtk_list_store_append(s_diag->list_store, &iter);
gtk_list_store_set(s_diag->list_store, &iter,
STATUSICON_COLUMN, icon,
STATUS_COLUMN, status_name,
-1);
}
}
g_hash_table_destroy(global_status);
}
|
gawen947/pidgin-pbar
|
33e7516d8513b8d8e711db174e49b9e0d3bd2b91
|
Change status on row-activated in status dialog
|
diff --git a/status_dialog.c b/status_dialog.c
index 55d323f..6f9d747 100644
--- a/status_dialog.c
+++ b/status_dialog.c
@@ -1,203 +1,217 @@
/* File: status_dialog.c
- Time-stamp: <2011-02-10 16:02:23 gawen>
+ Time-stamp: <2011-02-10 16:46:34 gawen>
Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "gtk.h"
#include "preferences.h"
#include "status_dialog.h"
static void cb_destroy_win(GtkWidget *widget, gpointer data);
static void cb_close_button(GtkWidget *widget, gpointer data);
static void cb_apply_button(GtkWidget *widget, gpointer date);
static void cb_refresh_button(GtkWidget *widget, gpointer data);
+static void cb_row_activated(GtkWidget *widget,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ gpointer data);
enum {
STATUSICON_COLUMN,
STATUS_COLUMN,
N_COLUMN
};
static void cb_destroy_win(GtkWidget *widget, gpointer data)
{ destroy_status_dialog((struct status_dialog *)data); }
+static void cb_row_activated(GtkWidget *widget,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ gpointer data)
+{ cb_apply_button(widget, data); }
+
static void cb_apply_button(GtkWidget *widget, gpointer data)
{
- GtkTreeSelection *sel;
GtkTreeModel *model;
GtkTreeIter iter;
+ GtkTreeSelection *sel;
struct status_dialog *s_diag = (struct status_dialog *)data;
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(s_diag->list_view));
if(gtk_tree_selection_get_selected(sel, &model, &iter)) {
PurpleStatusType *type;
gchar *name;
+
gtk_tree_model_get(model, &iter, STATUS_COLUMN, &name, -1);
type = g_hash_table_lookup(s_diag->global_status, name);
- if(type) {
+
+ if(type) { /* status type found */
const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
PurpleStatusPrimitive prim = purple_status_type_get_primitive(type);
PurpleSavedStatus *status = purple_savedstatus_get_current();
purple_savedstatus_set_type(status, prim);
purple_savedstatus_set_message(status, pm);
purple_savedstatus_activate(status);
purple_debug_info(NAME, "status changed to \"%s\" by user\n",
purple_status_type_get_name(type));
+ destroy_status_dialog(s_diag); /* destroy dialog */
} else
purple_debug_info(NAME, "selected status \"%s\" doesn't exists\n", name);
g_free(name);
} else
purple_debug_info(NAME, "no row selected\n");
}
static void cb_close_button(GtkWidget *widget, gpointer data)
{ destroy_status_dialog((struct status_dialog *)data); }
static void cb_refresh_button(GtkWidget *widget, gpointer data)
{
struct status_dialog *s_diag = (struct status_dialog *)data;
gtk_list_store_clear(s_diag->list_store);
init_status_dialog(s_diag);
}
struct status_dialog * create_status_dialog()
{
struct status_dialog *s_diag = g_malloc(sizeof(struct status_dialog));
memset(s_diag, 0, sizeof(struct status_dialog));
/* widgets that can be modifier along dialog lifetime */
s_diag->window = pidgin_create_dialog(_("Status selection"),
PIDGIN_HIG_BORDER,
"status-select",
TRUE);
s_diag->list_store = gtk_list_store_new(N_COLUMN,
GDK_TYPE_PIXBUF, /* STATUSICON */
G_TYPE_STRING /* STATUS */ );
s_diag->list_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
s_diag->list_store));
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(s_diag), s_diag->window);
/* widgets that are not modified */
GtkWidget *vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(
s_diag->window),
FALSE,
PIDGIN_HIG_BORDER);
GtkWidget *hbox = pidgin_dialog_get_action_area(GTK_DIALOG(s_diag->window));
GtkWidget *refresh_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
GtkWidget *apply_button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
/* create view and model */
GtkTreeViewColumn *p_col = gtk_tree_view_column_new();
GtkCellRenderer *p_renderer;
gtk_tree_view_column_set_title(p_col, _("Status"));
gtk_tree_view_append_column(GTK_TREE_VIEW(s_diag->list_view), p_col);
p_renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, FALSE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"pixbuf", STATUSICON_COLUMN);
p_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, TRUE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"text", STATUS_COLUMN);
/* pack widgets */
gtk_box_pack_start(GTK_BOX(hbox), refresh_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), apply_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), s_diag->list_view, TRUE, TRUE, 0);
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ s_diag->window, "destroy", cb_destroy_win },
+ { s_diag->list_view, "row-activated", cb_row_activated },
{ refresh_button, "clicked", cb_refresh_button },
{ apply_button, "clicked", cb_apply_button },
{ close_button, "clicked", cb_close_button },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(s_diag), g_signal_connections, s_diag);
/* show everything */
gtk_widget_show_all(s_diag->window);
gtk_window_present(GTK_WINDOW(s_diag->window));
return s_diag;
}
void destroy_status_dialog(struct status_dialog *s_diag)
{
gtk_destroy(PBAR_WIDGET(s_diag)); /* destroy widgets */
g_hash_table_destroy(s_diag->global_status); /* free global status */
g_free(s_diag); /* free dialog */
}
void init_status_dialog(struct status_dialog *s_diag)
{
GList *a = purple_accounts_get_all_active();
GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
if(!s_diag->global_status)
s_diag->global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
for(; a ; a = g_list_delete_link(a, a)) {
PurpleAccount *acct = (PurpleAccount *)a->data;
GList *types = purple_account_get_status_types(acct);
for(; types ; types = types->next) {
GtkTreeIter iter;
GdkPixbuf *icon;
PurpleStatusType *type = (PurpleStatusType *)types->data;
PurpleStatusPrimitive prim;
const gchar *stock, *status_name;
if(!purple_status_type_is_user_settable(type) ||
purple_status_type_is_independent(type))
continue;
prim = purple_status_type_get_primitive(type);
stock = pidgin_stock_id_from_status_primitive(prim);
if(g_hash_table_lookup(global_status, stock))
continue;
else
g_hash_table_insert(global_status, (gpointer)stock,
GINT_TO_POINTER(TRUE));
status_name = purple_status_type_get_name(type);
icon = gtk_widget_render_icon(s_diag->window, stock,
GTK_ICON_SIZE_MENU, NULL);
g_hash_table_insert(s_diag->global_status, (gpointer)status_name, type);
gtk_list_store_append(s_diag->list_store, &iter);
gtk_list_store_set(s_diag->list_store, &iter,
STATUSICON_COLUMN, icon,
STATUS_COLUMN, status_name,
-1);
}
}
g_hash_table_destroy(global_status);
}
|
gawen947/pidgin-pbar
|
ddb2bf4ac6fc55bf1d6e3b5885ad66be55273adc
|
Save global status
|
diff --git a/status_dialog.c b/status_dialog.c
index eb3f687..a1dd9ff 100644
--- a/status_dialog.c
+++ b/status_dialog.c
@@ -1,163 +1,165 @@
/* File: status_dialog.c
- Time-stamp: <2011-02-09 20:09:53 gawen>
+ Time-stamp: <2011-02-09 20:32:38 gawen>
Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common.h"
#include "gtk.h"
#include "status_dialog.h"
static void cb_destroy_win(GtkWidget *widget, gpointer data);
static void cb_close_button(GtkWidget *widget, gpointer data);
static void cb_apply_button(GtkWidget *widget, gpointer date);
static void cb_refresh_button(GtkWidget *widget, gpointer data);
enum {
STATUSICON_COLUMN,
STATUS_COLUMN,
N_COLUMN
};
static void cb_destroy_win(GtkWidget *widget, gpointer data)
{ destroy_status_dialog((struct status_dialog *)data); }
static void cb_apply_button(GtkWidget *widget, gpointer data)
{
}
static void cb_close_button(GtkWidget *widget, gpointer data)
{ destroy_status_dialog((struct status_dialog *)data); }
static void cb_refresh_button(GtkWidget *widget, gpointer data)
{
struct status_dialog *s_diag = (struct status_dialog *)data;
gtk_list_store_clear(s_diag->list_store);
init_status_dialog(s_diag);
}
struct status_dialog * create_status_dialog()
{
struct status_dialog *s_diag = g_malloc(sizeof(struct status_dialog));
memset(s_diag, 0, sizeof(struct status_dialog));
/* widgets that can be modifier along dialog lifetime */
s_diag->window = pidgin_create_dialog(_("Status selection"),
PIDGIN_HIG_BORDER,
"status-select",
TRUE);
s_diag->list_store = gtk_list_store_new(N_COLUMN,
GDK_TYPE_PIXBUF, /* STATUSICON */
G_TYPE_STRING /* STATUS */ );
/* add main widgets */
gtk_add_main_widget(PBAR_WIDGET(s_diag), s_diag->window);
/* widgets that are not modified */
GtkWidget *vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(s_diag->window),
FALSE,
PIDGIN_HIG_BORDER);
GtkWidget *hbox = pidgin_dialog_get_action_area(GTK_DIALOG(s_diag->window));
GtkWidget *view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(s_diag->list_store));
GtkWidget *refresh_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
GtkWidget *apply_button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
/* create view and model */
GtkTreeViewColumn *p_col = gtk_tree_view_column_new();
GtkCellRenderer *p_renderer;
gtk_tree_view_column_set_title(p_col, _("Status"));
gtk_tree_view_append_column(GTK_TREE_VIEW(view), p_col);
p_renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, FALSE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"pixbuf", STATUSICON_COLUMN);
p_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(p_col, p_renderer, TRUE);
gtk_tree_view_column_add_attribute(p_col, p_renderer,
"text", STATUS_COLUMN);
/* pack widgets */
gtk_box_pack_start(GTK_BOX(hbox), refresh_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), apply_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), view, TRUE, TRUE, 0);
/* gtk signals and callback */
const struct pbar_gtk_signal g_signal_connections[] = {
{ s_diag->window, "destroy", cb_destroy_win },
{ refresh_button, "clicked", cb_refresh_button },
{ close_button, "clicked", cb_close_button },
{ NULL, NULL, NULL }
};
/* connect signals and save handlers and instance when needed
to disconnect those signals when the widget is destroyed */
gtk_connect_signals(PBAR_WIDGET(s_diag), g_signal_connections, s_diag);
/* show everything */
gtk_widget_show_all(s_diag->window);
gtk_window_present(GTK_WINDOW(s_diag->window));
return s_diag;
}
void destroy_status_dialog(struct status_dialog *s_diag)
{
- gtk_destroy(PBAR_WIDGET(s_diag)); /* destroy widgets */
- g_free(s_diag); /* free dialog */
+ gtk_destroy(PBAR_WIDGET(s_diag)); /* destroy widgets */
+ g_hash_table_destroy(s_diag->global_status); /* free global status */
+ g_free(s_diag); /* free dialog */
}
void init_status_dialog(struct status_dialog *s_diag)
{
GList *a = purple_accounts_get_all_active();
- GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
- NULL, NULL);
+ if(!s_diag->global_status)
+ s_diag->global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
+ NULL, NULL);
for(; a ; a = g_list_delete_link(a, a)) {
PurpleAccount *acct = (PurpleAccount *)a->data;
GList *types = purple_account_get_status_types(acct);
for(; types ; types = types->next) {
GtkTreeIter iter;
GdkPixbuf *icon;
PurpleStatusType *type = (PurpleStatusType *)types->data;
PurpleStatusPrimitive prim;
const gchar *stock, *status_name;
if(!purple_status_type_is_user_settable(type) ||
purple_status_type_is_independent(type))
continue;
prim = purple_status_type_get_primitive(type);
stock = pidgin_stock_id_from_status_primitive(prim);
if(g_hash_table_lookup(global_status, stock))
continue;
else
g_hash_table_insert(global_status, (gpointer)stock,
GINT_TO_POINTER(TRUE));
status_name = purple_status_type_get_name(type);
icon = gtk_widget_render_icon(s_diag->window, stock,
GTK_ICON_SIZE_MENU, NULL);
gtk_list_store_append(s_diag->list_store, &iter);
gtk_list_store_set(s_diag->list_store, &iter,
STATUSICON_COLUMN, icon,
STATUS_COLUMN, status_name,
-1);
}
}
}
diff --git a/status_dialog.h b/status_dialog.h
index d04537f..7e532ac 100644
--- a/status_dialog.h
+++ b/status_dialog.h
@@ -1,38 +1,41 @@
/* File: status_dialog.h
- Time-stamp: <2011-02-09 20:05:59 gawen>
+ Time-stamp: <2011-02-09 20:32:23 gawen>
Copyright (C) 2011 David Hauweele <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _STATUS_DIALOG_H_
#define _STATUS_DIALOG_H_
#include "common.h"
#include "gtk.h"
struct status_dialog {
BEGIN_PBAR_WIDGET;
/* window and list storage */
GtkWidget *window;
GtkListStore *list_store;
+
+ /* global status for selection */
+ GHashTable *global_status;
};
struct status_dialog * create_status_dialog();
void destroy_status_dialog(struct status_dialog *s_diag);
void init_status_dialog(struct status_dialog *s_diag);
#endif /* _STATUS_DIALOG_H_ */
|
gawen947/pidgin-pbar
|
3c39e8c4257d4f27d9c06525d130402e02a06422
|
Add status selection dialog
|
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..94a9ed0
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..d3c03dd
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,2 @@
+* Wed Jan 5 2010 David Hauweele <[email protected]>
+ - Release 0.1
diff --git a/POTFILES.in b/POTFILES.in
new file mode 100644
index 0000000..ea4f862
--- /dev/null
+++ b/POTFILES.in
@@ -0,0 +1,21 @@
+pbar.c
+pbar.h
+protocol_features.c
+protocol_features.h
+acct_features.c
+acct_features.h
+preferences.c
+preferences.h
+actions.c
+actions.h
+widget.c
+widget.h
+widget_gtk.c
+widget_gtk.h
+widget_prpl.c
+widget_prpl.h
+purple.c
+purple.h
+gtk.c
+gtk.h
+common.h
diff --git a/README b/README
new file mode 100644
index 0000000..71cec2a
--- /dev/null
+++ b/README
@@ -0,0 +1,32 @@
+Pidgin PBar
+===========
+This Pidgin plugin adds a toolbar to the buddy list to quickly update nickname,
+personal message, icon, status and mood. It also allows updating the current
+song and other parameters which are updated globally on all accounts that
+support them.
+
+INSTALLATION
+============
+You will need a C compiler like gcc, make and the following depencies :
+
+ - pidgin-dev
+ - gtk2-dev
+ - pkg-config
+
+On Debian use the following command as root to install the required packages :
+
+ # aptitude install pidgin-dev libgtk2.0-dev pkg-config make gcc libc6-dev
+
+Then enter the following command :
+
+ $ make
+ $ sudo make install
+
+This will install the plugin and locales.
+The following flags are also available to enable/disable somes features :
+
+ - DISABLE_NLS (enabled by default)
+ - DISABLE_DEBUG (enabled by default)
+
+Please take advice that BSD make probably won't work, you need to use gmake
+instead.
diff --git a/acct_features.c b/acct_features.c
new file mode 100644
index 0000000..32822cf
--- /dev/null
+++ b/acct_features.c
@@ -0,0 +1,271 @@
+/* File: acct_features.c
+ Time-stamp: <2011-02-09 18:15:19 gawen>
+
+ Copyright (C) 2011 David Hauweele <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "common.h"
+
+#include "pbar.h"
+#include "purple.h"
+#include "gtk.h"
+#include "acct_features.h"
+
+static void cb_destroy_win(GtkWidget *widget, gpointer data);
+static void cb_close_button(GtkWidget *widget, gpointer data);
+static void cb_refresh_button(GtkWidget *widget, gpointer data);
+
+enum {
+ ACCTICON_COLUMN,
+ ACCT_COLUMN,
+ NICKNAME_COLUMN,
+ PM_COLUMN,
+ ICON_COLUMN,
+ MOOD_COLUMN,
+ MOODMSG_COLUMN,
+ TUNE_COLUMN,
+ GAME_COLUMN,
+ APP_COLUMN,
+ N_COLUMN
+};
+
+static void cb_destroy_win(GtkWidget *widget, gpointer data)
+{ destroy_acct_features_dialog((struct acct_features_dialog *)data); }
+
+static void cb_close_button(GtkWidget *widget, gpointer data)
+{ destroy_acct_features_dialog((struct acct_features_dialog *)data); }
+
+static void cb_refresh_button(GtkWidget *widget, gpointer data)
+{
+ struct acct_features_dialog *f_diag = (struct acct_features_dialog *)data;
+ gtk_list_store_clear(f_diag->list_store);
+ init_acct_features_dialog(f_diag);
+}
+
+struct acct_features_dialog * create_acct_features_dialog()
+{
+ struct acct_features_dialog *f_diag = g_malloc(sizeof(struct acct_features_dialog));
+ memset(f_diag, 0, sizeof(struct acct_features_dialog));
+
+ /* widgets that can possibly be modified along dialog lifetime */
+ f_diag->window = pidgin_create_dialog(_("Account features"),
+ PIDGIN_HIG_BORDER,
+ "acct-features",
+ TRUE);
+ f_diag->list_store = gtk_list_store_new(N_COLUMN,
+ GDK_TYPE_PIXBUF, /* ACCTICON */
+ G_TYPE_STRING, /* ACCT */
+ GDK_TYPE_PIXBUF, /* NICKNAME */
+ GDK_TYPE_PIXBUF, /* PM */
+ GDK_TYPE_PIXBUF, /* ICON */
+ GDK_TYPE_PIXBUF, /* MOOD */
+ GDK_TYPE_PIXBUF, /* MOODMSG */
+ GDK_TYPE_PIXBUF, /* TUNE */
+ GDK_TYPE_PIXBUF, /* GAME */
+ GDK_TYPE_PIXBUF /* APP */ );
+
+ /* add main widgets */
+ gtk_add_main_widget(PBAR_WIDGET(f_diag), f_diag->window);
+
+ /* widgets that are not modified */
+ GtkWidget *vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(f_diag->window),
+ FALSE,
+ PIDGIN_HIG_BORDER);
+ GtkWidget *hbox = pidgin_dialog_get_action_area(GTK_DIALOG(f_diag->window));
+ GtkWidget *view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(f_diag->list_store));
+ GtkWidget *refresh_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
+ GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
+
+ /* create view and model */
+ GtkTreeViewColumn *p_col = gtk_tree_view_column_new();
+ GtkCellRenderer *p_renderer;
+ gtk_tree_view_column_set_title(p_col, _("Account"));
+ gtk_tree_view_append_column(GTK_TREE_VIEW(view), p_col);
+ p_renderer = gtk_cell_renderer_pixbuf_new();
+ gtk_tree_view_column_pack_start(p_col, p_renderer, FALSE);
+ gtk_tree_view_column_add_attribute(p_col, p_renderer,
+ "pixbuf", ACCTICON_COLUMN);
+ p_renderer = gtk_cell_renderer_text_new();
+ gtk_tree_view_column_pack_start(p_col, p_renderer, TRUE);
+ gtk_tree_view_column_add_attribute(p_col, p_renderer,
+ "text", ACCT_COLUMN);
+ const struct g_column {
+ const gchar *title; /* column title */
+ const gchar *attr_type; /* column type attribute */
+ GtkCellRenderer *(*gtk_cell_renderer_new)(); /* gtk cell renderer creation */
+ guint position; /* column position */
+ } columns[] = {
+ { N_("Nickname"), "pixbuf", gtk_cell_renderer_pixbuf_new, NICKNAME_COLUMN },
+ { N_("Status message"), "pixbuf", gtk_cell_renderer_pixbuf_new, PM_COLUMN },
+ { N_("Buddy icon"), "pixbuf", gtk_cell_renderer_pixbuf_new, ICON_COLUMN },
+ { N_("Mood"), "pixbuf", gtk_cell_renderer_pixbuf_new, MOOD_COLUMN },
+ { N_("Mood message"), "pixbuf", gtk_cell_renderer_pixbuf_new, MOODMSG_COLUMN },
+ { N_("Tune"), "pixbuf", gtk_cell_renderer_pixbuf_new, TUNE_COLUMN },
+ { N_("Game"), "pixbuf", gtk_cell_renderer_pixbuf_new, GAME_COLUMN },
+ { N_("App."), "pixbuf", gtk_cell_renderer_pixbuf_new, APP_COLUMN },
+ { NULL, NULL, NULL, 0 }
+ }; const struct g_column *col = columns;
+
+ /* create columns */
+ for(; col->title ; col++) {
+ GtkCellRenderer *renderer = col->gtk_cell_renderer_new();
+ GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes(_(col->title),
+ renderer,
+ col->attr_type,
+ col->position,
+ NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
+ }
+
+ /* pack widgets */
+ gtk_box_pack_start(GTK_BOX(hbox), refresh_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), view, TRUE, TRUE, 0);
+
+ /* gtk signals and callback */
+ const struct pbar_gtk_signal g_signal_connections[] = {
+ { f_diag->window, "destroy", cb_destroy_win },
+ { refresh_button, "clicked", cb_refresh_button },
+ { close_button, "clicked", cb_close_button },
+ { NULL, NULL, NULL }
+ };
+
+ /* connect signals and save handlers and instance when needed
+ to disconnect those signals when the widget is destroyed */
+ gtk_connect_signals(PBAR_WIDGET(f_diag), g_signal_connections, f_diag);
+
+ /* show everything */
+ gtk_widget_show_all(f_diag->window);
+ gtk_window_present(GTK_WINDOW(f_diag->window));
+
+ return f_diag;
+}
+
+void destroy_acct_features_dialog(struct acct_features_dialog *f_diag)
+{
+ gtk_destroy(PBAR_WIDGET(f_diag)); /* destroy widgets */
+ g_free(f_diag); /* free dialog */
+}
+
+void init_acct_features_dialog(struct acct_features_dialog *f_diag)
+{
+ GList *a = purple_accounts_get_all_active();
+ /* TODO: should be freed ? */
+ GdkPixbuf *yes = gtk_widget_render_icon(f_diag->window, GTK_STOCK_YES,
+ GTK_ICON_SIZE_MENU, NULL);
+ GdkPixbuf *no = gtk_widget_render_icon(f_diag->window, GTK_STOCK_NO,
+ GTK_ICON_SIZE_MENU, NULL);
+
+ /* last line summarize all available features */
+ GtkTreeIter e_iter;
+ GdkPixbuf *e_icon = gtk_widget_render_icon(f_diag->window,
+ PIDGIN_STOCK_INFO,
+ GTK_ICON_SIZE_MENU,
+ NULL);
+ GdkPixbuf *e_pm = no;
+ GdkPixbuf *e_buddyicon = no;
+ GdkPixbuf *e_nickname = no;
+ GdkPixbuf *e_mood = no;
+ GdkPixbuf *e_moodmsg = no;
+ GdkPixbuf *e_game = no;
+ GdkPixbuf *e_app = no;
+ GdkPixbuf *e_tune = no;
+
+ for(; a ; a = a->next) {
+ PurpleAccount *acct = (PurpleAccount *)a->data;
+ PurplePlugin *plugin = purple_find_prpl(acct->protocol_id);
+ PurplePluginProtocolInfo *protocol = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
+
+ GtkTreeIter iter;
+ gchar *username = g_strdup_printf("%s (%s)",
+ purple_account_get_username(acct),
+ purple_account_get_protocol_name(acct));
+ GdkPixbuf *a_icon = pidgin_create_prpl_icon(acct, PIDGIN_PRPL_ICON_MEDIUM);
+ GHashTable *attrs = get_account_attrs(acct);
+
+ GdkPixbuf *nickname, *mood, *moodmsg, *game, *app, *tune, *pm, *buddyicon;
+
+ if(g_hash_table_lookup(attrs, "mood"))
+ e_mood = mood = yes;
+ else
+ mood = no;
+ if(g_hash_table_lookup(attrs, "moodtext"))
+ e_moodmsg = moodmsg = yes;
+ else
+ moodmsg = no;
+ if(g_hash_table_lookup(attrs, "game"))
+ e_game = game = yes;
+ else
+ game = no;
+ if(g_hash_table_lookup(attrs, "office"))
+ e_app = app = yes;
+ else
+ app = no;
+ if((g_hash_table_lookup(attrs, "tune_title") &&
+ g_hash_table_lookup(attrs, "tune_artist") &&
+ g_hash_table_lookup(attrs, "tune_album")))
+ e_tune = tune = yes;
+ else
+ tune = no;
+ g_hash_table_destroy(attrs);
+
+ if(protocol->set_status)
+ e_pm = pm = yes;
+ else
+ pm = no;
+ if(protocol->set_buddy_icon)
+ e_buddyicon = buddyicon = yes;
+ else
+ buddyicon = no;
+ /* exception for XMPP
+ nickname supported
+ manually
+ FIXME: however some XMPP account don't support nickname extension */
+ if(!strcmp(acct->protocol_id, "prpl-jabber") || protocol->set_public_alias)
+ e_nickname = nickname = yes;
+ else
+ nickname = no;
+
+ gtk_list_store_append(f_diag->list_store, &iter);
+ gtk_list_store_set(f_diag->list_store, &iter,
+ ACCT_COLUMN, username,
+ ACCTICON_COLUMN, a_icon,
+ NICKNAME_COLUMN, nickname,
+ PM_COLUMN, pm,
+ ICON_COLUMN, buddyicon,
+ MOOD_COLUMN, mood,
+ MOODMSG_COLUMN, moodmsg,
+ TUNE_COLUMN, tune,
+ GAME_COLUMN, game,
+ APP_COLUMN, app,
+ -1);
+ g_free(username);
+ }
+
+ /* last line summarize all available features */
+ gtk_list_store_append(f_diag->list_store, &e_iter);
+ gtk_list_store_set(f_diag->list_store, &e_iter,
+ ACCT_COLUMN, "Available features",
+ ACCTICON_COLUMN, e_icon,
+ NICKNAME_COLUMN, e_nickname,
+ PM_COLUMN, e_pm,
+ ICON_COLUMN, e_buddyicon,
+ MOOD_COLUMN, e_mood,
+ MOODMSG_COLUMN, e_moodmsg,
+ TUNE_COLUMN, e_tune,
+ GAME_COLUMN, e_game,
+ APP_COLUMN, e_app,
+ -1);
+}
diff --git a/acct_features.h b/acct_features.h
new file mode 100644
index 0000000..8ececc2
--- /dev/null
+++ b/acct_features.h
@@ -0,0 +1,38 @@
+/* File: acct_features.h
+ Time-stamp: <2011-02-07 17:31:32 gawen>
+
+ Copyright (C) 2011 David Hauweele <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _ACCT_FEATURES_H_
+#define _ACCT_FEATURES_H_
+
+#include "common.h"
+
+#include "gtk.h"
+
+struct acct_features_dialog {
+ BEGIN_PBAR_WIDGET;
+
+ /* window and list storage */
+ GtkWidget *window;
+ GtkListStore *list_store;
+};
+
+struct acct_features_dialog * create_acct_features_dialog();
+void destroy_acct_features_dialog(struct acct_features_dialog *f_diag);
+void init_acct_features_dialog(struct acct_features_dialog *f_diag);
+
+#endif /* _ACCT_FEATURES_H_ */
diff --git a/actions.c b/actions.c
new file mode 100644
index 0000000..19cd229
--- /dev/null
+++ b/actions.c
@@ -0,0 +1,101 @@
+/* File: actions.c
+ Time-stamp: <2011-02-09 20:11:28 gawen>
+
+ Copyright (C) 2011 David Hauweele <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "common.h"
+
+#include "pbar.h"
+#include "widget.h"
+#include "purple.h"
+#include "protocol_features.h"
+#include "acct_features.h"
+#include "status_dialog.h"
+
+static void cb_icon_choose(const gchar *path, gpointer data)
+{
+ g_return_if_fail(path);
+
+ purple_prefs_set_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon", path);
+}
+
+static void protocol_features(PurplePluginAction *act)
+{
+ struct protocol_features_dialog *f_diag = create_protocol_features_dialog();
+ init_protocol_features_dialog(f_diag);
+}
+
+static void acct_features(PurplePluginAction *act)
+{
+ struct acct_features_dialog *f_diag = create_acct_features_dialog();
+ init_acct_features_dialog(f_diag);
+}
+
+static void change_nickname(PurplePluginAction *act)
+{ create_name_dialog(); }
+
+static void change_pm(PurplePluginAction *act)
+{ create_pm_dialog(); }
+
+static void change_status(PurplePluginAction *act)
+{
+ struct status_dialog *s_diag = create_status_dialog();
+ init_status_dialog(s_diag);
+}
+
+static void change_mood(PurplePluginAction *act)
+{
+}
+
+static void change_icon(PurplePluginAction *act)
+{
+ g_return_if_fail(bar->installed);
+
+ PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
+ GtkWidget *chooser = pidgin_buddy_icon_chooser_new(GTK_WINDOW
+ (gtk_widget_get_toplevel
+ (GTK_WIDGET(blist))),
+ cb_icon_choose,
+ NULL);
+ gtk_widget_show(chooser);
+}
+
+GList * create_actions(PurplePlugin *plugin, gpointer ctx)
+{
+ GList *l = NULL;
+
+ const struct action {
+ const gchar *title;
+ void (*action)(PurplePluginAction *);
+ } actions[] = {
+ { N_("Change nickname"), change_nickname },
+ { N_("Change personal message"), change_pm },
+ { N_("Change status"), change_status },
+ { N_("Change mood"), change_mood },
+ { N_("Change icon"), change_icon },
+ { N_("Protocol features"), protocol_features },
+ { N_("Account features"), acct_features },
+ { NULL, NULL }
+ }; const struct action *acts = actions;
+
+ for(; acts->title ; acts++) {
+ PurplePluginAction *act = purple_plugin_action_new(_(acts->title),
+ acts->action);
+ l = g_list_append(l, act);
+ }
+
+ return l;
+}
diff --git a/actions.h b/actions.h
new file mode 100644
index 0000000..7ca5220
--- /dev/null
+++ b/actions.h
@@ -0,0 +1,26 @@
+/* File: actions.h
+ Time-stamp: <2011-02-04 03:33:28 gawen>
+
+ Copyright (C) 2011 David Hauweele <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _ACTIONS_H_
+#define _ACTIONS_H_
+
+#include "common.h"
+
+GList * create_actions(PurplePlugin *plugin, gpointer ctx);
+
+#endif /* _ACTIONS_H_ */
diff --git a/commands.mk b/commands.mk
new file mode 100644
index 0000000..c8c22ff
--- /dev/null
+++ b/commands.mk
@@ -0,0 +1,11 @@
+# defaults commands
+CC=gcc
+RM=rm -f
+INSTALL=install
+INSTALL_PROGRAM=install -s -m 555
+INSTALL_DATA=$(INSTALL) -m 444
+INSTALL_SCRIPT=$(INSTALL_PROGRAM)
+XGETTEXT=xgettext
+MSGFMT=msgfmt
+MKDIR=mkdir
+CP=cp
\ No newline at end of file
diff --git a/common.h b/common.h
new file mode 100644
index 0000000..c139551
--- /dev/null
+++ b/common.h
@@ -0,0 +1,52 @@
+/* File: common.h
+ Time-stamp: <2010-10-05 01:14:39 gawen>
+
+ Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2008,2009 Craig Harding <[email protected]>
+ Wolter Hellmund <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _COMMON_H_
+#define _COMMON_H_
+
+/* define for NLS */
+#define GETTEXT_PACKAGE "pidgin-pbar"
+
+/* common include for pidgin and gtk */
+
+#include <string.h>
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
+
+#include "pidginstock.h"
+#include "plugin.h"
+#include "signals.h"
+#include "gtkblist.h"
+#include "gtkstatusbox.h"
+#include "gtkprefs.h"
+#include "prpl.h"
+#include "request.h"
+#include "debug.h"
+#include "gtkutils.h"
+#include "buddyicon.h"
+#include "version.h"
+#include "gtkplugin.h"
+
+#ifdef _WIN32
+# include "win32dep.h"
+#endif /* _WIN32 */
+
+#endif /* _COMMON_H_ */
diff --git a/de.po b/de.po
new file mode 100644
index 0000000..16bb1b7
--- /dev/null
+++ b/de.po
@@ -0,0 +1,190 @@
+# Pidgin PBar German translation
+# Copyright (C) 2010, Marleen Bekaert <[email protected]>
+# This file is distributed under the same license as the Pidgin PBar package.
+# Marleen Bekaert <[email protected]>, 2010
+#
+
+msgid ""
+msgstr ""
+"Project-Id-Version: nl\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2011-01-04 20:23+0100\n"
+"PO-Revision-Date: 2011-01-04 23:19+0100\n"
+"Last-Translator: Marleen Bekaert <[email protected]>\n"
+"Language-Team: German <[email protected]>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. name
+#. internal name
+#: pbar.h:36
+msgid "PBar"
+msgstr "PBar"
+
+#: pbar.h:48
+msgid "A toolbar to update some account settings globally."
+msgstr "Eine Symbolleiste um manche Account Einstellungen vollständig zu aktualisieren."
+
+#: pbar.h:50
+msgid "Adds a toolbar to the buddy list to quickly update nickname, personal message, icon, status and mood. It also allows updating of the current song and other parameters which are updated globally on all accounts that support them."
+msgstr "Fügt eine Symbolleiste zu der Buddy-liste um schnell den Spitzname, den Persönlichen Bericht, die Ikone, den Status und die Laune schnell zu ändern. Erlaubt auch um das aktuelle Lied und anderen parameter die global aktualisiert werden auf alle Account die es ertragen ."
+
+#: preferences.c:50
+msgid "Left"
+msgstr "Linke"
+
+#: preferences.c:51
+msgid "Center"
+msgstr "Mitte"
+
+#: preferences.c:52
+msgid "Right"
+msgstr "Rechte"
+
+#: preferences.c:58
+msgid "Top"
+msgstr "Oben"
+
+#: preferences.c:59
+msgid "Bottom"
+msgstr "Unter"
+
+#: preferences.c:130
+msgid "_Nickname markup"
+msgstr "_Spitzname Tag"
+
+#: preferences.c:131
+msgid "Nickname markup _hovered"
+msgstr "_Ãbergezwegd Spitzname Tag"
+
+#: preferences.c:132
+msgid "Personal _message markup"
+msgstr "Persönliche _Nachricht Tag"
+
+#: preferences.c:133
+msgid "Personal message markup _hovered"
+msgstr "_Ãbergezwegd persönliche Nachricht Tag"
+
+#: preferences.c:144
+msgid "Align _nickname"
+msgstr "Spitzname_ausrichten"
+
+#: preferences.c:145
+msgid "Align personal _message"
+msgstr "_Persönliche Nachricht ausrichten"
+
+#: preferences.c:146
+msgid "Widget _position in the buddy list"
+msgstr "Widget _Lage in den buddy-Liste"
+
+#: preferences.c:152
+msgid "Hide _statusbox"
+msgstr "_Statusbox verbergen"
+
+#: preferences.c:153
+msgid "_Ignore status changes"
+msgstr "_Ignoriert Status anderungen"
+
+#: preferences.c:154
+msgid "Use a frame for _entry"
+msgstr "Nutz ein ein Rahmen für Textinput"
+
+#: preferences.c:155
+msgid "_Swap left and right click"
+msgstr "_Dreht linke und rechte klik um"
+
+#: preferences.c:156
+msgid "Use a _compact bar"
+msgstr "Benutz ein kompakt Balken"
+
+#: preferences.c:157
+msgid "_Reset status messages"
+msgstr "_Rûcksetz Status Berichten"
+
+#. preferences
+#. preference root
+#. empty messages to display at first installation
+#: preferences.h:33
+msgid "<Enter nickname here>"
+msgstr "<hier Spitzname einführen>"
+
+#: preferences.h:34
+msgid "<Enter personal message here>"
+msgstr "<Hier persönlich nachricht einführen>"
+
+#: widget_gtk.c:94
+msgid "Change nickname"
+msgstr "ändernt Spitzname"
+
+#: widget_gtk.c:95
+msgid "Enter your nickname here..."
+msgstr "Hier Spitzname einführen..."
+
+#: widget_gtk.c:96
+msgid "This will change your nickname for every account which supports it."
+msgstr "ändernt ihr Spitzname für jeder Account die es ertragen ."
+
+#: widget_gtk.c:102 widget_gtk.c:246
+msgid "OK"
+msgstr "OK"
+
+#: widget_gtk.c:104 widget_gtk.c:248
+msgid "Cancel"
+msgstr "Annulieren"
+
+#: widget_gtk.c:197
+msgid "_Mood message"
+msgstr "_Laune Nachricht"
+
+#: widget_gtk.c:198
+msgid "Current song"
+msgstr "Aktuel lied"
+
+#: widget_gtk.c:199
+msgid "Song _title"
+msgstr "lied _Titel"
+
+#: widget_gtk.c:200
+msgid "Song _artist"
+msgstr "Lied _Künstler"
+
+#: widget_gtk.c:201
+msgid "Song al_bum"
+msgstr "Lied Al_bum"
+
+#: widget_gtk.c:202
+msgid "MSN pecan extra attributes"
+msgstr "MSN pecan extra Parameter"
+
+#: widget_gtk.c:203
+msgid "_Game name"
+msgstr "_Spiel Name"
+
+#: widget_gtk.c:204
+msgid "_Office app name"
+msgstr "_Office app Name"
+
+#: widget_gtk.c:210
+msgid "Status and mood message"
+msgstr "Status und Laune Nachricht"
+
+#: widget_gtk.c:214
+msgid "_Personal message"
+msgstr "_Persönliche Nachricht"
+
+#: widget_gtk.c:240
+msgid "Change status messages"
+msgstr "ändernt Status Nachricht"
+
+#: widget_gtk.c:241
+msgid "Enter status message..."
+msgstr "führt Status Nachricht ein..."
+
+#: widget_gtk.c:242
+msgid "This will change some status messages for every account which supports it, please be advised that some are inconsistent between each other."
+msgstr "ändernt einige Status Nachrichten für jeder Account die es ertragt, Bitte beachten Sie dass einige inkonsistent sind untereinander."
+
+#: widget_gtk.c:361
+msgid "None"
+msgstr "Nichts"
diff --git a/fr.po b/fr.po
new file mode 100644
index 0000000..993c6dd
--- /dev/null
+++ b/fr.po
@@ -0,0 +1,189 @@
+# Pidgin PBar French translation.
+# Copyright (C) 2010, David Hauweele <[email protected]>
+# This file is distributed under the same license as the Pidgin PBar package.
+# David Hauweele <[email protected]>, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: fr\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-10-13 20:18+0200\n"
+"PO-Revision-Date: 2010-11-17 14:20+0100\n"
+"Last-Translator: David Hauweele <[email protected]>\n"
+"Language-Team: French <[email protected]>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. name
+#. internal name
+#: pbar.h:36
+msgid "PBar"
+msgstr "PBar"
+
+#: pbar.h:48
+msgid "A toolbar to update some account settings globally."
+msgstr "Une barre d'outils pour mettre à jour certains paramètres de manière globale."
+
+#: pbar.h:50
+msgid "Adds a toolbar to the buddy list to quickly update nickname, personal message, icon, status and mood. It also allows updating of the current song and other parameters which are updated globally on all accounts that support them."
+msgstr "Ajoute une barre d'outils à la liste de contacts pour rapidement mettre à jour le pseudonyme, le message personnel, l'icône, le status et l'humeur. Il permet également de mettre à jour le morceau actuel et d'autres paramètres qui sont mis à jours de manière globale sur tous les comptes qui les supportent."
+
+#: preferences.c:50
+msgid "Left"
+msgstr "Gauche"
+
+#: preferences.c:51
+msgid "Center"
+msgstr "Centre"
+
+#: preferences.c:52
+msgid "Right"
+msgstr "Droite"
+
+#: preferences.c:58
+msgid "Top"
+msgstr "Haut"
+
+#: preferences.c:59
+msgid "Bottom"
+msgstr "Bas"
+
+#: preferences.c:130
+msgid "_Nickname markup"
+msgstr "Balise du _pseudonyme"
+
+#: preferences.c:131
+msgid "Nickname markup _hovered"
+msgstr "Balise du pseudonyme _survolé"
+
+#: preferences.c:132
+msgid "Personal _message markup"
+msgstr "Balise du _message personnel"
+
+#: preferences.c:133
+msgid "Personal message markup _hovered"
+msgstr "Balise du message personnel _survolé"
+
+#: preferences.c:144
+msgid "Align _nickname"
+msgstr "Aligner le _pseudonyme"
+
+#: preferences.c:145
+msgid "Align personal _message"
+msgstr "Aligner le _message personnel"
+
+#: preferences.c:146
+msgid "Widget _position in the buddy list"
+msgstr "_Position de la barre dans la liste de contacts"
+
+#: preferences.c:152
+msgid "Hide _statusbox"
+msgstr "Cacher le sélecteur d'é_tats"
+
+#: preferences.c:153
+msgid "_Ignore status changes"
+msgstr "_Ignorer les changements d'états"
+
+#: preferences.c:154
+msgid "Use a frame for _entry"
+msgstr "Utiliser un _cadre"
+
+#: preferences.c:155
+msgid "_Swap left and right click"
+msgstr "_Inverser le clique gauche et droit"
+
+#: preferences.c:156
+msgid "Use a _compact bar"
+msgstr "Utiliser une barre _compacte"
+
+#: preferences.c:157
+msgid "_Reset status messages"
+msgstr "Réinitialiser les messages d'état"
+
+#. preferences
+#. preference root
+#. empty messages to display at first installation
+#: preferences.h:33
+msgid "<Enter nickname here>"
+msgstr "<Entrez votre pseudonyme ici>"
+
+#: preferences.h:34
+msgid "<Enter personal message here>"
+msgstr "<Entrez votre message personnel ici>"
+
+#: widget_gtk.c:94
+msgid "Change nickname"
+msgstr "Changer le pseudonyme"
+
+#: widget_gtk.c:95
+msgid "Enter your nickname here..."
+msgstr "Entrez votre pseudonyme ici..."
+
+#: widget_gtk.c:96
+msgid "This will change your nickname for every account which supports it."
+msgstr "Cela va changer votre pseudonyme pour tous les comptes qui le supportent."
+
+#: widget_gtk.c:102 widget_gtk.c:246
+msgid "OK"
+msgstr "OK"
+
+#: widget_gtk.c:104 widget_gtk.c:248
+msgid "Cancel"
+msgstr "_Annuler"
+
+#: widget_gtk.c:197
+msgid "_Mood message"
+msgstr "Message pour l'_humeur"
+
+#: widget_gtk.c:198
+msgid "Current song"
+msgstr "Morceau actuel"
+
+#: widget_gtk.c:199
+msgid "Song _title"
+msgstr "_Titre"
+
+#: widget_gtk.c:200
+msgid "Song _artist"
+msgstr "_Artiste"
+
+#: widget_gtk.c:201
+msgid "Song al_bum"
+msgstr "_Album"
+
+#: widget_gtk.c:202
+msgid "MSN pecan extra attributes"
+msgstr "Options supplémentaires pour MSN pecan"
+
+#: widget_gtk.c:203
+msgid "_Game name"
+msgstr "_Jeu actuel"
+
+#: widget_gtk.c:204
+msgid "_Office app name"
+msgstr "_Application"
+
+#: widget_gtk.c:210
+msgid "Status and mood message"
+msgstr "Message d'états et d'humeur"
+
+#: widget_gtk.c:214
+msgid "_Personal message"
+msgstr "Message _personnel"
+
+#: widget_gtk.c:240
+msgid "Change status messages"
+msgstr "Changer le message d'état"
+
+#: widget_gtk.c:241
+msgid "Enter status message..."
+msgstr "Entrez votre message d'état..."
+
+#: widget_gtk.c:242
+msgid "This will change some status messages for every account which supports it, please be advised that some are inconsistent between each other."
+msgstr "Cela va changer certains messages d'états pour tous les comptes qui le supportent, notez toutefois que certains sont incompatibles entre eux."
+
+#: widget_gtk.c:361
+msgid "None"
+msgstr "Aucun"
diff --git a/gtk.c b/gtk.c
new file mode 100644
index 0000000..f921d41
--- /dev/null
+++ b/gtk.c
@@ -0,0 +1,86 @@
+/* File: gtk.c
+ Time-stamp: <2011-02-07 18:49:30 gawen>
+
+ Copyright (C) 2011 David Hauweele <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "common.h"
+
+#include "gtk.h"
+
+#if !GTK_CHECK_VERSION(2,18,0)
+gboolean gtk_widget_get_visible(GtkWidget *widget)
+{
+ return GTK_WIDGET_FLAGS(widget) & GTK_VISIBLE;
+}
+
+void gtk_widget_set_visible(GtkWidget *widget, gboolean visible)
+{
+ if(visible)
+ gtk_widget_show(widget);
+ else
+ gtk_widget_hide(widget);
+}
+
+void gtk_widget_set_can_focus(GtkWidget *widget, gboolean can_focus)
+{
+ if(can_focus)
+ GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_FOCUS);
+ else
+ GTK_WIDGET_UNSET_FLAGS(widget, GTK_CAN_FOCUS);
+}
+#endif /* GTK < 2.18 */
+
+void gtk_connect_signals(struct pbar_widget *w,
+ const struct pbar_gtk_signal *sig_list,
+ gpointer data)
+{
+ const struct pbar_gtk_signal *s = sig_list;
+ for(; s->signal ; s++) {
+ gulong handler_id = g_signal_connect(G_OBJECT(s->widget),
+ s->signal,
+ G_CALLBACK(s->callback),
+ data);
+ w->gtk_hnd = g_list_append(w->gtk_hnd, GINT_TO_POINTER(handler_id));
+ w->gtk_inst = g_list_append(w->gtk_inst, s->widget);
+ }
+}
+
+void gtk_destroy(struct pbar_widget *w)
+{
+ GList *l, *i, *j;
+
+ /* disconnect gtk signals */
+ for(i = w->gtk_hnd, j = w->gtk_inst ; i && j ;
+ i = i->next, j = j->next)
+ g_signal_handler_disconnect(j->data, GPOINTER_TO_INT(i->data));
+ g_list_free(w->gtk_hnd);
+ g_list_free(w->gtk_inst);
+
+ /* destroy widgets */
+ for(j = w->main_widgets ; j ; j = j->next) {
+ GtkWidget *main_widget = (GtkWidget *)j->data;
+
+ l = gtk_container_get_children(GTK_CONTAINER(main_widget));
+ for(i = l ; i ; i = i->next) {
+ gtk_widget_destroy(i->data);
+ i->data = NULL;
+ }
+ gtk_widget_destroy(main_widget);
+ }
+}
+
+void gtk_add_main_widget(struct pbar_widget *w, GtkWidget *widget)
+{ w->main_widgets = g_list_append(w->main_widgets, widget); }
diff --git a/gtk.h b/gtk.h
new file mode 100644
index 0000000..e262ea3
--- /dev/null
+++ b/gtk.h
@@ -0,0 +1,51 @@
+/* File: gtk.h
+ Time-stamp: <2011-02-07 18:33:20 gawen>
+
+ Copyright (C) 2011 David Hauweele <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _GTK_H_
+#define _GTK_H_
+
+#include "common.h"
+
+#define PBAR_WIDGET(widget) ((struct pbar_widget *)widget)
+#define BEGIN_PBAR_WIDGET GList *gtk_hnd; \
+ GList *gtk_inst; \
+ GList *main_widgets
+
+struct pbar_gtk_signal {
+ GtkWidget *widget;
+ const gchar *signal;
+ void (*callback)(GtkWidget *, gpointer);
+};
+
+struct pbar_widget {
+ BEGIN_PBAR_WIDGET; /* signals handlers and instance for disconnection */
+};
+
+#if !GTK_CHECK_VERSION(2,18,0)
+gboolean gtk_widget_get_visible(GtkWidget *widget);
+void gtk_widget_set_visible(GtkWidget *widget, gboolean visible);
+void gtk_widget_set_can_focus(GtkWidget *widget, gboolean can_focus);
+#endif /* GTK < 2.18 */
+
+void gtk_destroy(struct pbar_widget *w);
+void gtk_add_main_widget(struct pbar_widget *w, GtkWidget *widget);
+void gtk_connect_signals(struct pbar_widget *w,
+ const struct pbar_gtk_signal *sig_list,
+ gpointer data);
+
+#endif /* _GTK_H_ */
diff --git a/hash.sh b/hash.sh
new file mode 100755
index 0000000..8baa549
--- /dev/null
+++ b/hash.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+# script to determine git hash of current source tree
+# try to use whatever git tells us if there is a .git folder
+if [ -d .git -a -r .git ]
+then
+ hash=$(git log 2>/dev/null | head -n1 2>/dev/null | sed "s/.* //" 2>/dev/null)
+fi
+
+if [ x"$hash" != x ]
+then
+ echo $hash
+else
+ echo "UNKNOWN"
+fi
+exit 0
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..dab7be3
--- /dev/null
+++ b/makefile
@@ -0,0 +1,81 @@
+include commands.mk
+
+OPTS := -O2
+CFLAGS := -std=c99 $(OPTS) $(shell pkg-config --cflags pidgin purple gtk+-2.0 gobject-2.0) -fPIC -Wall
+LDFLAGS := $(shell pkg-config --libs pidgin purple gtk+-2.0 gobject-2.0)
+
+SRC = $(wildcard *.c)
+OBJ = $(foreach obj, $(SRC:.c=.o), $(notdir $(obj)))
+DEP = $(SRC:.c=.d)
+POFILES = $(wildcard *.po)
+CATALOGS = $(foreach cat, $(POFILES:.po=.mo), $(notdir $(cat)))
+
+PREFIX ?= /usr/local
+LOCALEDIR ?= $(PREFIX)/share/locale
+PLUGINDIR ?= $(shell pkg-config --variable=plugindir pidgin)
+DATADIR ?= $(shell pkg-config --variable=datadir pidgin)
+
+
+ifndef DISABLE_DEBUG
+CFLAGS += -ggdb
+endif
+
+commit = $(shell ./hash.sh)
+ifneq ($(commit), UNKNOWN)
+CFLAGS += -DCOMMIT="\"$(commit)\""
+endif
+
+ifndef DISABLE_NLS
+CFLAGS += -DENABLE_NLS=1 -DLOCALEDIR="\"$(LOCALEDIR)\""
+locales := locales
+install-locales := install-locales
+uninstall-locales := uninstall-locales
+endif
+
+CFLAGS += -DDATADIR="\"$(DATADIR)\""
+
+.PHONY: all clean
+
+all: pbar.so $(locales)
+
+pbar.so: $(OBJ)
+ $(CC) -shared -o $@ $^ $(LDFLAGS)
+
+%.o: %.c
+ $(CC) -Wp,-MMD,$*.d -c $(CFLAGS) -o $@ $<
+
+clean:
+ $(RM) $(DEP)
+ $(RM) $(OBJ)
+ $(RM) $(CATALOGS)
+ $(RM) messages.pot
+ $(RM) pbar.so
+
+install: $(install-locales)
+ $(MKDIR) -p $(DESTDIR)$(PLUGINDIR)
+ $(INSTALL_PROGRAM) pbar.so $(DESTDIR)$(PLUGINDIR)
+
+uninstall: $(uninstall-locales)
+ $(RM) $(PLUGINDIR)/pbar.so
+
+locales: $(CATALOGS)
+
+CAT_INST_PATH = $(foreach lang, $(POFILES:.po=), $(DESTDIR)$(LOCALEDIR)/$(lang)/LC_MESSAGES/pidgin-pbar.mo)
+
+install-locales: $(CAT_INST_PATH)
+
+$(DESTDIR)$(LOCALEDIR)/%/LC_MESSAGES/pidgin-pbar.mo: %.mo
+ $(MKDIR) -p $(DESTDIR)$(LOCALEDIR)/$(basename $<)/LC_MESSAGES
+ $(INSTALL_DATA) $< $@
+
+uninstall-locales:
+ $(RM) $(CAT_INST_PATH)
+
+%.mo: %.po
+ $(MSGFMT) -c -o $@ $<
+
+messages.pot: POTFILES.in
+ $(XGETTEXT) --no-wrap -m -c --files-from $< --keyword --keyword=_ --keyword=N_ -o $@
+
+-include $(DEP)
+
diff --git a/nl.po b/nl.po
new file mode 100644
index 0000000..4d7dba8
--- /dev/null
+++ b/nl.po
@@ -0,0 +1,190 @@
+# Pidgin PBar Dutch translation
+# Copyright (C) 2010, Marleen Bekaert <[email protected]>
+# This file is distributed under the same license as the Pidgin PBar package.
+# Marleen Bekaert <[email protected]>, 2010
+#
+
+msgid ""
+msgstr ""
+"Project-Id-Version: nl\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-12-19 19:13+0100\n"
+"PO-Revision-Date: 2010-12-19 19:20+0100\n"
+"Last-Translator: Marleen Bekaert <[email protected]>\n"
+"Language-Team: Dutch <[email protected]>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. name
+#. internal name
+#: pbar.h:36
+msgid "PBar"
+msgstr "PBar"
+
+#: pbar.h:48
+msgid "A toolbar to update some account settings globally."
+msgstr "Een werkbalk om sommige account instellingen globaal te actualiseren."
+
+#: pbar.h:50
+msgid "Adds a toolbar to the buddy list to quickly update nickname, personal message, icon, status and mood. It also allows updating of the current song and other parameters which are updated globally on all accounts that support them."
+msgstr "Voegt een werkbalk aan de contact list om vlug bijnaam, persoonlijk bericht, icoon, status en humeur te actualiseren. Het laat ook toe om het huidig lied en andere parameters die globaal actualiseerd zijn op alle accounts die het verdragen."
+
+#: preferences.c:50
+msgid "Left"
+msgstr "Links"
+
+#: preferences.c:51
+msgid "Center"
+msgstr "Midden"
+
+#: preferences.c:52
+msgid "Right"
+msgstr "Rechts"
+
+#: preferences.c:58
+msgid "Top"
+msgstr "Boven"
+
+#: preferences.c:59
+msgid "Bottom"
+msgstr "Beneden"
+
+#: preferences.c:130
+msgid "_Nickname markup"
+msgstr "_Bijnaam baken"
+
+#: preferences.c:131
+msgid "Nickname markup _hovered"
+msgstr "Bijnaam baken _overgezweefd"
+
+#: preferences.c:132
+msgid "Personal _message markup"
+msgstr "Persoonlijk _bericht baken"
+
+#: preferences.c:133
+msgid "Personal message markup _hovered"
+msgstr "Persoonlijk bericht baken _overgezweefd"
+
+#: preferences.c:144
+msgid "Align _nickname"
+msgstr "Richten _bijnaam"
+
+#: preferences.c:145
+msgid "Align personal _message"
+msgstr "Richten persoonlijk _bericht"
+
+#: preferences.c:146
+msgid "Widget _position in the buddy list"
+msgstr "Werkbalk _positie in contactlijst"
+
+#: preferences.c:152
+msgid "Hide _statusbox"
+msgstr "Verberg _statusbox"
+
+#: preferences.c:153
+msgid "_Ignore status changes"
+msgstr "_Negeren van status negeren"
+
+#: preferences.c:154
+msgid "Use a frame for _entry"
+msgstr "Gebruik een kader voor _textinvoer"
+
+#: preferences.c:155
+msgid "_Swap left and right click"
+msgstr "_Keer linkse and rechtse klik om"
+
+#: preferences.c:156
+msgid "Use a _compact bar"
+msgstr "gebruikt een _compacte balk"
+
+#: preferences.c:157
+msgid "_Reset status messages"
+msgstr "_Opmaak status berichten"
+
+#. preferences
+#. preference root
+#. empty messages to display at first installation
+#: preferences.h:33
+msgid "<Enter nickname here>"
+msgstr "<Hier bijnaam invoeren>"
+
+#: preferences.h:34
+msgid "<Enter personal message here>"
+msgstr "<Hier persoonlijk bericht iuvoeren>"
+
+#: widget_gtk.c:94
+msgid "Change nickname"
+msgstr "Veranderd bijnaam"
+
+#: widget_gtk.c:95
+msgid "Enter your nickname here..."
+msgstr "Hier U bijnaam invoeren..."
+
+#: widget_gtk.c:96
+msgid "This will change your nickname for every account which supports it."
+msgstr "Dat zal U bijnaam veranderen vor iedere account die het verdraagt."
+
+#: widget_gtk.c:102 widget_gtk.c:246
+msgid "OK"
+msgstr "OK"
+
+#: widget_gtk.c:104 widget_gtk.c:248
+msgid "Cancel"
+msgstr "Annuleren"
+
+#: widget_gtk.c:197
+msgid "_Mood message"
+msgstr "_Humeur bericht"
+
+#: widget_gtk.c:198
+msgid "Current song"
+msgstr "Huidig lied"
+
+#: widget_gtk.c:199
+msgid "Song _title"
+msgstr "Lied _tijtel"
+
+#: widget_gtk.c:200
+msgid "Song _artist"
+msgstr "Lied _artiest"
+
+#: widget_gtk.c:201
+msgid "Song al_bum"
+msgstr "Lied al_bum"
+
+#: widget_gtk.c:202
+msgid "MSN pecan extra attributes"
+msgstr "MSN pecan extra parameters"
+
+#: widget_gtk.c:203
+msgid "_Game name"
+msgstr "_Spelnaam"
+
+#: widget_gtk.c:204
+msgid "_Office app name"
+msgstr "_Office app naam"
+
+#: widget_gtk.c:210
+msgid "Status and mood message"
+msgstr "Status en humeur bericht"
+
+#: widget_gtk.c:214
+msgid "_Personal message"
+msgstr "_Persoonlijk bericht"
+
+#: widget_gtk.c:240
+msgid "Change status messages"
+msgstr "Veranderd status berichten"
+
+#: widget_gtk.c:241
+msgid "Enter status message..."
+msgstr "Voert Status berichten in..."
+
+#: widget_gtk.c:242
+msgid "This will change some status messages for every account which supports it, please be advised that some are inconsistent between each other."
+msgstr"Dat zal sommige status berichten voor iedere account die het verdraagt veranderen, Gelieve nota te nemen dat sommige inconsequent zijn onder elkaar."
+
+#: widget_gtk.c:361
+msgid "None"
+msgstr "Niets"
diff --git a/pbar.c b/pbar.c
new file mode 100644
index 0000000..cbd31c4
--- /dev/null
+++ b/pbar.c
@@ -0,0 +1,134 @@
+/* File: pbar.c
+ Time-stamp: <2011-01-31 19:06:59 gawen>
+
+ Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2008,2009 Craig Harding <[email protected]>
+ Wolter Hellmund <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#define PURPLE_PLUGINS
+
+#include "common.h"
+
+#include "pbar.h"
+#include "actions.h"
+#include "preferences.h"
+#include "widget.h"
+#include "purple.h"
+
+static gboolean plugin_load(PurplePlugin *plugin);
+static gboolean plugin_unload(PurplePlugin *plugin);
+
+static PidginPluginUiInfo ui_info = { get_config_frame };
+
+static PurplePluginInfo info = {
+ PURPLE_PLUGIN_MAGIC,
+ PURPLE_MAJOR_VERSION,
+ PURPLE_MINOR_VERSION,
+ PURPLE_PLUGIN_STANDARD,
+ PIDGIN_PLUGIN_TYPE,
+ 0,
+ NULL,
+ PURPLE_PRIORITY_DEFAULT,
+ PLUGIN_ID,
+ NULL, /* defined later for NLS */
+ PLUGIN_VERSION,
+ NULL, /* defined later for NLS */
+ NULL, /* defined later for NLS */
+ PLUGIN_AUTHOR,
+ PLUGIN_WEBSITE,
+ plugin_load,
+ plugin_unload,
+ NULL,
+ &ui_info,
+ NULL,
+ NULL,
+ create_actions,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+PurplePlugin *thisplugin;
+
+/* we need this callback to catch
+ blist construction and install
+ widget when we may do so */
+static void cb_blist_created(GtkWidget *widget, gpointer data)
+{
+ /* create widget and
+ load preferences */
+ create_widget();
+ init_widget();
+}
+
+static gboolean plugin_load(PurplePlugin *plugin)
+{
+ /* connect construction signal only when needed
+ as when installing the plugin after launching
+ pidgin there is no need to wait for blist
+ creation */
+ if(is_gtk_blist_created()) {
+ /* create widget and
+ load preferences */
+ create_widget();
+ init_widget();
+ }
+ else
+ /* connect construction signal */
+ purple_signal_connect(pidgin_blist_get_handle(),
+ "gtkblist-created",
+ plugin,
+ PURPLE_CALLBACK(cb_blist_created),
+ NULL);
+
+ purple_debug_info(NAME,"plugin initialized...\n");
+
+ return TRUE;
+}
+
+static gboolean plugin_unload(PurplePlugin *plugin)
+{
+ /* destroy widget and free memory */
+ destroy_widget();
+
+ /* restore statusbox */
+ set_statusbox_visible(TRUE);
+
+ purple_debug_info(NAME,"plugin destroyed...\n");
+
+ return TRUE;
+}
+
+static void init_plugin(PurplePlugin *plugin)
+{
+ thisplugin = plugin;
+
+#ifdef ENABLE_NLS
+ bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+#endif /* ENABLE_NLS */
+
+ /* translate name, summary and description */
+ info.name = _(PLUGIN_NAME);
+ info.summary = _(PLUGIN_SUMMARY);
+ info.description = _(PLUGIN_DESCRIPTION);
+
+ /* load or create preferences */
+ init_prefs();
+}
+
+PURPLE_INIT_PLUGIN(pbar, init_plugin, info)
diff --git a/pbar.h b/pbar.h
new file mode 100644
index 0000000..c9fc95c
--- /dev/null
+++ b/pbar.h
@@ -0,0 +1,61 @@
+/* File: pbar.h
+ Time-stamp: <2010-11-15 23:55:36 gawen>
+
+ Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2008,2009 Craig Harding <[email protected]>
+ Wolter Hellmund <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _PBAR_H_
+#define _PBAR_H_
+
+#include "common.h"
+
+#ifndef G_GNUC_NULL_TERMINATED
+# if __GNUC__ >= 4
+# define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
+# else
+# define G_GNUC_NULL_TERMINATED
+# endif /* __GNUC__ >= 4 */
+#endif /* G_GNUC_NULL_TERMINATED */
+
+/* name */
+#define NAME "pbar" /* internal name */
+#define DISP_NAME N_("PBar") /* displayed name */
+#define VERSION "0.2-git" /* current version */
+
+/* plugin information */
+#define PLUGIN_ID "gtk-" NAME /* gtk plugin id */
+#define PLUGIN_NAME DISP_NAME
+#ifndef COMMIT
+# define PLUGIN_VERSION VERSION
+#else
+# define PLUGIN_VERSION VERSION " (commit:" COMMIT ")" /* add git commit
+ when available */
+#endif
+#define PLUGIN_SUMMARY N_("A toolbar to update some account settings " \
+ "globally.")
+#define PLUGIN_DESCRIPTION N_("Adds a toolbar to the buddy list to quickly " \
+ "update nickname, personal message, icon, " \
+ "status and mood. It also allows updating of " \
+ "the current song and other parameters which " \
+ "are updated globally on all accounts that " \
+ "support them.")
+#define PLUGIN_AUTHOR "David Hauweele <[email protected]>"
+#define PLUGIN_WEBSITE "http://www.atlantysse.prout.be/~gawen/pidgin-pbar.html"
+
+extern PurplePlugin *thisplugin;
+
+#endif /* _PBAR_H_ */
diff --git a/preferences.c b/preferences.c
new file mode 100644
index 0000000..0756b9c
--- /dev/null
+++ b/preferences.c
@@ -0,0 +1,376 @@
+/* File: prefs.c
+ Time-stamp: <2010-11-15 23:14:54 gawen>
+
+ Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2008,2009 Craig Harding <[email protected]>
+ Wolter Hellmund <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "common.h"
+
+#include "preferences.h"
+#include "widget.h"
+
+/* callback for preferences setting which set preferences and
+ update interface when needed */
+static void cb_nickname_markup(GtkWidget *widget, gpointer data);
+static void cb_nickname_markup_hover(GtkWidget *widget, gpointer data);
+static void cb_personal_message_markup(GtkWidget *widget, gpointer data);
+static void cb_personal_message_markup_hover(GtkWidget *widget, gpointer data);
+static void cb_hide_statusbox(GtkWidget *widget, gpointer data);
+static void cb_override_status(GtkWidget *widget, gpointer data);
+static void cb_nickname_justify(GtkWidget *widget, gpointer data);
+static void cb_personal_message_justify(GtkWidget *widget, gpointer data);
+static void cb_compact(GtkWidget *widget, gpointer data);
+static void cb_frame_entry(GtkWidget *widget, gpointer data);
+static void cb_swap_click(GtkWidget *widget, gpointer data);
+static void cb_reset_attrs(GtkWidget *widget, gpointer data);
+static void cb_widget_position(GtkWidget *widget, gpointer data);
+
+/* the following structures are defined here as global
+ since they are needed in combobox callback */
+
+/* alias we will use for combobox */
+static const struct i_alias {
+ const char *alias;
+ int value;
+} alias_justify[] = {
+ { N_("Left"), JUSTIFY_LEFT },
+ { N_("Center"), JUSTIFY_CENTER },
+ { N_("Right"), JUSTIFY_RIGHT },
+ { NULL, 0 }
+};
+
+/* widget position in the buddy list */
+static const struct i_alias alias_position[] = {
+ { N_("Top"), POSITION_TOP },
+ { N_("Bottom"), POSITION_BOTTOM },
+ { NULL, 0 }
+};
+
+/* init preferences and set default values */
+void init_prefs()
+{
+ /* string preferences and default value */
+ const struct prefs_string {
+ const char *name;
+ const char *value;
+ } prefs_add_string[] = {
+ { PREF "/personal-message-markup-hover", "<span color=\"DarkOliveGreen4\"><small><i>%p</i></small></span>" },
+ { PREF "/personal-message-markup", "<small>%p</small>" },
+ { PREF "/nickname-markup-hover", "<span color=\"DarkOliveGreen4\"><b>%n</b></span>" },
+ { PREF "/nickname-markup", "<b>%n</b>" },
+ { PREF "/personal-message", EMPTY_PM },
+ { PREF "/tune-title", "" },
+ { PREF "/tune-artist", "" },
+ { PREF "/tune-album", "" },
+ { PREF "/game-message", "" },
+ { PREF "/office-message", "" },
+ { PREF "/nickname", EMPTY_NAME },
+ { PREF "/mood-message", "" },
+ { PREF "/mood", "" },
+ { NULL, NULL }
+ }; const struct prefs_string *s = prefs_add_string;
+
+ /* boolean preferences and default value */
+ const struct prefs_bool {
+ const char *name;
+ gboolean value;
+ } prefs_add_bool[] = {
+ { PREF "/hide-statusbox", TRUE },
+ { PREF "/override-status", FALSE },
+ { PREF "/frame-entry", TRUE },
+ { PREF "/swap-click", FALSE },
+ { PREF "/reset-attrs", FALSE },
+ { PREF "/compact", FALSE },
+ { NULL, FALSE }
+ }; const struct prefs_bool *b = prefs_add_bool;
+
+ /* integer preferences and default value */
+ const struct prefs_int {
+ const char *name;
+ int value;
+ } prefs_add_int[] = {
+ { PREF "/nickname-justify", JUSTIFY_LEFT },
+ { PREF "/personal-message-justify", JUSTIFY_LEFT },
+ { PREF "/widget-position", POSITION_TOP },
+ { NULL, 0 }
+ }; const struct prefs_int *i = prefs_add_int;
+
+ /* add preferences */
+ purple_prefs_add_none(PREF);
+ for(; s->name ; s++)
+ purple_prefs_add_string(s->name, s->value);
+ for(; b->name ; b++)
+ purple_prefs_add_bool(b->name, b->value);
+ for(; i->name ; i++)
+ purple_prefs_add_int(i->name, i->value);
+}
+
+GtkWidget * get_config_frame(PurplePlugin *plugin)
+{
+ /* entry widgets label, associated preference and callback */
+ const struct widget {
+ const char *name;
+ const char *prefs;
+ void (*callback)(GtkWidget *, gpointer);
+ } entry[] = {
+ { N_("_Nickname markup"), PREF "/nickname-markup", cb_nickname_markup },
+ { N_("Nickname markup _hovered"), PREF "/nickname-markup-hover", cb_nickname_markup_hover },
+ { N_("Personal _message markup"), PREF "/personal-message-markup", cb_personal_message_markup },
+ { N_("Personal message markup _hovered"), PREF "/personal-message-markup-hover", cb_personal_message_markup_hover },
+ { NULL, NULL, NULL }
+ }; const struct widget *e = entry;
+
+ /* combobox widgets label, associated preference, alias and callback */
+ const struct i_widget {
+ const char *name;
+ const char *prefs;
+ const struct i_alias *alias;
+ void (*callback)(GtkWidget *, gpointer);
+ } combobox[] = {
+ { N_("Align _nickname"), PREF "/nickname-justify", alias_justify, cb_nickname_justify },
+ { N_("Align personal _message"), PREF "/personal-message-justify", alias_justify, cb_personal_message_justify },
+ { N_("Widget _position in the buddy list"), PREF "/widget-position", alias_position, cb_widget_position },
+ { NULL, NULL, NULL, NULL }
+ }; const struct i_widget *cbx = combobox;
+
+ /* check button widgets label, associated preference and callback */
+ const struct widget check_button[] = {
+ { N_("Hide _statusbox"), PREF "/hide-statusbox", cb_hide_statusbox },
+ { N_("_Ignore status changes"), PREF "/override-status", cb_override_status },
+ { N_("Use a frame for _entry"), PREF "/frame-entry", cb_frame_entry },
+ { N_("_Swap left and right click"), PREF "/swap-click", cb_swap_click },
+ { N_("Use a _compact bar"), PREF "/compact", cb_compact },
+ { N_("_Reset status messages"), PREF "/reset-attrs", cb_reset_attrs },
+ { NULL, NULL, NULL }
+ }; const struct widget *cb = check_button;
+
+ /* create table */
+ GtkWidget *table = gtk_table_new(((sizeof(entry) - 2) +
+ sizeof(check_button) / 2 - 1) /
+ sizeof(struct widget),
+ 2, FALSE);
+
+ /* load table and connect signals */
+ int x = 0, y = 0;
+ for(; e->name ; e++, y++) {
+ /* entry widgets */
+ GtkWidget *widget_label = gtk_label_new_with_mnemonic(_(e->name));
+ GtkWidget *widget_entry = gtk_entry_new();
+ const gchar *prefs_value = purple_prefs_get_string(e->prefs);
+
+ gtk_label_set_mnemonic_widget(GTK_LABEL(widget_label), widget_entry);
+ gtk_entry_set_text(GTK_ENTRY(widget_entry), prefs_value);
+ gtk_misc_set_alignment(GTK_MISC(widget_label), 0., .5);
+ gtk_table_attach(GTK_TABLE(table), widget_label, 0, 1, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
+ gtk_table_attach(GTK_TABLE(table), widget_entry, 1, 2, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
+ g_signal_connect(G_OBJECT(widget_entry), "activate", G_CALLBACK(e->callback),NULL);
+ g_signal_connect(G_OBJECT(widget_entry), "focus-out-event", G_CALLBACK(e->callback),NULL);
+ }
+ for(; cbx->name ; cbx++, y++) {
+ /* combobox widgets */
+ const struct i_alias *j;
+ GtkWidget *widget_label = gtk_label_new_with_mnemonic(_(cbx->name));
+ GtkWidget *widget_combo = gtk_combo_box_new_text();
+ int prefs_value = purple_prefs_get_int(cbx->prefs);
+ int i;
+
+ gtk_label_set_mnemonic_widget(GTK_LABEL(widget_label), widget_combo);
+ gtk_misc_set_alignment(GTK_MISC(widget_label), 0., .5);
+ gtk_table_attach(GTK_TABLE(table), widget_label, 0, 1, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
+ gtk_table_attach(GTK_TABLE(table), widget_combo, 1, 2, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
+ for(i = 0, j = cbx->alias ; j->alias ; j++, i++) {
+ gtk_combo_box_append_text(GTK_COMBO_BOX(widget_combo), _(j->alias));
+ if(j->value == prefs_value)
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget_combo), i);
+ }
+ g_signal_connect(G_OBJECT(widget_combo), "changed", G_CALLBACK(cbx->callback), (gpointer)cbx->alias);
+ }
+ for(; cb->name ; cb++, x = (x + 1) % 2) {
+ /* check button widgets */
+ GtkWidget *widget_cb = gtk_check_button_new_with_mnemonic(_(cb->name));
+ gboolean prefs_value = purple_prefs_get_bool(cb->prefs);
+
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget_cb), prefs_value);
+ gtk_table_attach(GTK_TABLE(table), widget_cb, x, x+1, y, y+1, GTK_FILL, GTK_FILL, 5, 5);
+ g_signal_connect(G_OBJECT(widget_cb), "toggled", G_CALLBACK(cb->callback),NULL);
+ if(x % 2)
+ y++;
+ }
+
+ return table; /* pidgin destroy this when closed */
+}
+
+static void cb_nickname_markup(GtkWidget *widget, gpointer data)
+{
+ const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget));
+ purple_prefs_set_string(PREF "/nickname-markup", value);
+
+ if(!get_widget_name_hover_state()) {
+ const gchar *name = purple_prefs_get_string(PREF "/nickname");
+ set_widget_name(value, name);
+ }
+
+ purple_debug_info(NAME, "nickname markup changed\n");
+}
+
+static void cb_nickname_markup_hover(GtkWidget *widget, gpointer data)
+{
+ const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget));
+ purple_prefs_set_string(PREF "/nickname-markup-hover", value);
+
+ if(get_widget_name_hover_state()) {
+ const gchar *name = purple_prefs_get_string(PREF "/nickname");
+ set_widget_name(value, name);
+ }
+
+ purple_debug_info(NAME, "nickname markup hover changed\n");
+}
+
+static void cb_personal_message_markup(GtkWidget *widget, gpointer data)
+{
+ const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget));
+ purple_prefs_set_string(PREF "/personal-message-markup", value);
+
+ if(!get_widget_pm_hover_state()) {
+ const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
+ set_widget_pm(value, pm);
+ }
+
+ purple_debug_info(NAME, "personal message markup hover changed\n");
+}
+
+static void cb_personal_message_markup_hover(GtkWidget *widget, gpointer data)
+{
+ const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget));
+ purple_prefs_set_string(PREF "/personal-message-markup-hover", value);
+
+ if(get_widget_pm_hover_state()) {
+ const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
+ set_widget_pm(value, pm);
+ }
+
+ purple_debug_info(NAME, "personal message markup hover changed\n");
+}
+
+static void cb_hide_statusbox(GtkWidget *widget, gpointer data)
+{
+ gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+ purple_prefs_set_bool(PREF "/hide-statusbox", state);
+ set_statusbox_visible(!state);
+
+ purple_debug_info(NAME, "status box state changed\n");
+}
+
+static void cb_override_status(GtkWidget *widget, gpointer data)
+{
+ gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+ purple_prefs_set_bool(PREF "/override-status", state);
+
+ purple_debug_info(NAME, "override status state changed\n");
+}
+
+static void cb_nickname_justify(GtkWidget *widget, gpointer data)
+{
+ const gchar *value = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget));
+ const struct i_alias *j;
+
+ for(j = (struct i_alias *)data ; j->alias ; j++) {
+ if(!strcmp(value, _(j->alias))) {
+ purple_prefs_set_int(PREF "/nickname-justify", j->value);
+ set_widget_name_justify(j->value);
+ break;
+ }
+ }
+
+ purple_debug_info(NAME, "nickname justification changed\n");
+}
+
+static void cb_personal_message_justify(GtkWidget *widget, gpointer data)
+{
+ const gchar *value = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget));
+ const struct i_alias *j;
+
+ for(j = (struct i_alias *)data ; j->alias ; j++) {
+ if(!strcmp(value, _(j->alias))) {
+ purple_prefs_set_int(PREF "/personal-message-justify", j->value);
+ set_widget_pm_justify(j->value);
+ break;
+ }
+ }
+
+ purple_debug_info(NAME, "personal message justification changed\n");
+}
+
+static void cb_compact(GtkWidget *widget, gpointer data)
+{
+ gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+
+ purple_prefs_set_bool(PREF "/compact", state);
+ /* recreate bar since we need to repack everything */
+ destroy_widget();
+ create_widget();
+ init_widget();
+
+ purple_debug_info(NAME, "compact state changed\n");
+}
+
+static void cb_frame_entry(GtkWidget *widget, gpointer data)
+{
+ gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+
+ purple_prefs_set_bool(PREF "/frame-entry", state);
+ set_widget_entry_frame(state);
+
+ purple_debug_info(NAME, "frame entry state changed\n");
+}
+
+static void cb_swap_click(GtkWidget *widget, gpointer data)
+{
+ gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+ purple_prefs_set_bool(PREF "/swap-click", state);
+
+ purple_debug_info(NAME, "swap click state changed\n");
+}
+
+static void cb_reset_attrs(GtkWidget *widget, gpointer data)
+{
+ gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+
+ purple_prefs_set_bool(PREF "/reset-attrs", state);
+ set_widget_entry_frame(state);
+
+ purple_debug_info(NAME, "reset attributes state changed\n");
+}
+
+static void cb_widget_position(GtkWidget *widget, gpointer data)
+{
+ const gchar *value = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget));
+ const struct i_alias *j;
+
+ for(j = (struct i_alias *)data ; j->alias ; j++) {
+ if(!strcmp(value, _(j->alias))) {
+ purple_prefs_set_int(PREF "/widget-position", j->value);
+ /* recreate bar since we need to repack everything */
+ destroy_widget();
+ create_widget();
+ init_widget();
+ break;
+ }
+ }
+
+ purple_debug_info(NAME, "personal message justification changed\n");
+}
diff --git a/preferences.h b/preferences.h
new file mode 100644
index 0000000..56fe732
--- /dev/null
+++ b/preferences.h
@@ -0,0 +1,43 @@
+/* File: prefs.h
+ Time-stamp: <2010-11-14 01:30:53 gawen>
+
+ Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2008,2009 Craig Harding <[email protected]>
+ Wolter Hellmund <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _PREFERENCES_H_
+#define _PREFERENCES_H_
+
+#include "common.h"
+
+#include "pbar.h"
+#include "widget.h"
+
+/* preferences */
+#define PREF "/plugins/gtk/" NAME /* preference root */
+
+/* empty messages to display at first installation */
+#define EMPTY_NAME N_("<Enter nickname here>")
+#define EMPTY_PM N_("<Enter personal message here>")
+
+/* justification and alignment */
+enum { JUSTIFY_LEFT, JUSTIFY_CENTER, JUSTIFY_RIGHT };
+enum { POSITION_TOP, POSITION_BOTTOM };
+
+void init_prefs();
+GtkWidget * get_config_frame(PurplePlugin *plugin);
+
+#endif /* _PREFERENCES_H_ */
diff --git a/protocol_features.c b/protocol_features.c
new file mode 100644
index 0000000..c45d406
--- /dev/null
+++ b/protocol_features.c
@@ -0,0 +1,214 @@
+/* File: protocol_features.c
+ Time-stamp: <2011-02-07 19:05:53 gawen>
+
+ Copyright (C) 2011 David Hauweele <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "common.h"
+
+#include "pbar.h"
+#include "purple.h"
+#include "gtk.h"
+#include "protocol_features.h"
+
+static void cb_destroy_win(GtkWidget *widget, gpointer data);
+static void cb_close_button(GtkWidget *widget, gpointer data);
+static void cb_refresh_button(GtkWidget *widget, gpointer data);
+
+enum {
+ PROTOCOLICON_COLUMN,
+ PROTOCOL_COLUMN,
+ NICKNAME_COLUMN,
+ PM_COLUMN,
+ ICON_COLUMN,
+ MOOD_COLUMN,
+ MOODMSG_COLUMN,
+ TUNE_COLUMN,
+ GAME_COLUMN,
+ APP_COLUMN,
+ N_COLUMN
+};
+
+static void cb_destroy_win(GtkWidget *widget, gpointer data)
+{ destroy_protocol_features_dialog((struct protocol_features_dialog *)data); }
+
+static void cb_close_button(GtkWidget *widget, gpointer data)
+{ destroy_protocol_features_dialog((struct protocol_features_dialog *)data); }
+
+static void cb_refresh_button(GtkWidget *widget, gpointer data)
+{
+ struct protocol_features_dialog *f_diag = (struct protocol_features_dialog *)data;
+ gtk_list_store_clear(f_diag->list_store);
+ init_protocol_features_dialog(f_diag);
+}
+
+struct protocol_features_dialog * create_protocol_features_dialog()
+{
+ struct protocol_features_dialog *f_diag = g_malloc(sizeof(struct protocol_features_dialog));
+ memset(f_diag, 0, sizeof(struct protocol_features_dialog));
+
+ /* widgets that can possibly be modified along dialog lifetime */
+ f_diag->window = pidgin_create_dialog(_("Protocol features"),
+ PIDGIN_HIG_BORDER,
+ "protocol-features",
+ TRUE);
+ f_diag->list_store = gtk_list_store_new(N_COLUMN,
+ GDK_TYPE_PIXBUF, /* PROTOCOLICON */
+ G_TYPE_STRING, /* PROTOCOL */
+ GDK_TYPE_PIXBUF, /* NICKNAME */
+ GDK_TYPE_PIXBUF, /* PM */
+ GDK_TYPE_PIXBUF, /* ICON */
+ GDK_TYPE_PIXBUF, /* MOOD */
+ GDK_TYPE_PIXBUF, /* MOODMSG */
+ GDK_TYPE_PIXBUF, /* TUNE */
+ GDK_TYPE_PIXBUF, /* GAME */
+ GDK_TYPE_PIXBUF /* APP */ );
+
+ /* add main widgets */
+ gtk_add_main_widget(PBAR_WIDGET(f_diag), f_diag->window);
+
+ /* widgets that are not modified */
+ GtkWidget *vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(f_diag->window),
+ FALSE,
+ PIDGIN_HIG_BORDER);
+ GtkWidget *hbox = pidgin_dialog_get_action_area(GTK_DIALOG(f_diag->window));
+ GtkWidget *view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(f_diag->list_store));
+ GtkWidget *refresh_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
+ GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
+
+ /* create view and model */
+ GtkTreeViewColumn *p_col = gtk_tree_view_column_new();
+ GtkCellRenderer *p_renderer;
+ gtk_tree_view_column_set_title(p_col, _("Protocol"));
+ gtk_tree_view_append_column(GTK_TREE_VIEW(view), p_col);
+ p_renderer = gtk_cell_renderer_pixbuf_new();
+ gtk_tree_view_column_pack_start(p_col, p_renderer, FALSE);
+ gtk_tree_view_column_add_attribute(p_col, p_renderer,
+ "pixbuf", PROTOCOLICON_COLUMN);
+ p_renderer = gtk_cell_renderer_text_new();
+ gtk_tree_view_column_pack_start(p_col, p_renderer, TRUE);
+ gtk_tree_view_column_add_attribute(p_col, p_renderer,
+ "text", PROTOCOL_COLUMN);
+ const struct g_column {
+ const gchar *title; /* column title */
+ const gchar *attr_type; /* column type attribute */
+ GtkCellRenderer *(*gtk_cell_renderer_new)(); /* gtk cell renderer creation */
+ guint position; /* column position */
+ } columns[] = {
+ { N_("Nickname"), "pixbuf", gtk_cell_renderer_pixbuf_new, NICKNAME_COLUMN },
+ { N_("Status message"), "pixbuf", gtk_cell_renderer_pixbuf_new, PM_COLUMN },
+ { N_("Buddy icon"), "pixbuf", gtk_cell_renderer_pixbuf_new, ICON_COLUMN },
+ { N_("Mood"), "pixbuf", gtk_cell_renderer_pixbuf_new, MOOD_COLUMN },
+ { N_("Mood message"), "pixbuf", gtk_cell_renderer_pixbuf_new, MOODMSG_COLUMN },
+ { N_("Tune"), "pixbuf", gtk_cell_renderer_pixbuf_new, TUNE_COLUMN },
+ { N_("Game"), "pixbuf", gtk_cell_renderer_pixbuf_new, GAME_COLUMN },
+ { N_("App."), "pixbuf", gtk_cell_renderer_pixbuf_new, APP_COLUMN },
+ { NULL, NULL, NULL, 0 }
+ }; const struct g_column *col = columns;
+
+ /* create columns */
+ for(; col->title ; col++) {
+ GtkCellRenderer *renderer = col->gtk_cell_renderer_new();
+ GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes(_(col->title),
+ renderer,
+ col->attr_type,
+ col->position,
+ NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
+ }
+
+ /* pack widgets */
+ gtk_box_pack_start(GTK_BOX(hbox), refresh_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), view, TRUE, TRUE, 0);
+
+ /* gtk signals and callback */
+ const struct pbar_gtk_signal g_signal_connections[] = {
+ { f_diag->window, "destroy", cb_destroy_win },
+ { refresh_button, "clicked", cb_refresh_button },
+ { close_button, "clicked", cb_close_button },
+ { NULL, NULL, NULL }
+ };
+
+ /* connect signals and save handlers and instance when needed
+ to disconnect those signals when the widget is destroyed */
+ gtk_connect_signals(PBAR_WIDGET(f_diag), g_signal_connections, f_diag);
+
+ /* show everything */
+ gtk_widget_show_all(f_diag->window);
+ gtk_window_present(GTK_WINDOW(f_diag->window));
+
+ return f_diag;
+}
+
+void destroy_protocol_features_dialog(struct protocol_features_dialog *f_diag)
+{
+ gtk_destroy(PBAR_WIDGET(f_diag)); /* destroy widgets */
+ g_free(f_diag); /* free dialog */
+}
+
+void init_protocol_features_dialog(struct protocol_features_dialog *f_diag)
+{
+ GList *p = purple_plugins_get_protocols();
+ /* TODO: should be freed ? */
+ GdkPixbuf *yes = gtk_widget_render_icon(f_diag->window, GTK_STOCK_YES,
+ GTK_ICON_SIZE_MENU, NULL);
+ GdkPixbuf *no = gtk_widget_render_icon(f_diag->window, GTK_STOCK_NO,
+ GTK_ICON_SIZE_MENU, NULL);
+
+ for(; p ; p = p->next) {
+ PurplePlugin *plugin = p->data;
+ PurplePluginInfo *info = plugin->info;
+ PurplePluginProtocolInfo *protocol = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
+
+ if(info && info->name) {
+ GtkTreeIter iter;
+ GdkPixbuf *p_icon = create_prpl_icon_from_info(protocol,
+ PIDGIN_PRPL_ICON_MEDIUM);
+ GHashTable *attrs = get_protocol_attrs(protocol);
+ GdkPixbuf *nickname;
+ GdkPixbuf *mood = g_hash_table_lookup(attrs, "mood") ? yes : no;
+ GdkPixbuf *moodmsg = g_hash_table_lookup(attrs, "moodtext") ? yes : no;
+ GdkPixbuf *game = g_hash_table_lookup(attrs, "game") ? yes : no;
+ GdkPixbuf *app = g_hash_table_lookup(attrs, "office") ? yes : no;
+ GdkPixbuf *tune = (g_hash_table_lookup(attrs, "tune_title") &&
+ g_hash_table_lookup(attrs, "tune_artist") &&
+ g_hash_table_lookup(attrs, "tune_album")) ? yes : no;
+ g_hash_table_destroy(attrs);
+
+ /* exception for XMPP
+ nickname supported
+ manually */
+ if(!strcmp(info->name, "XMPP"))
+ nickname = yes;
+ else
+ nickname = protocol->set_public_alias ? yes : no;
+
+ gtk_list_store_append(f_diag->list_store, &iter);
+ gtk_list_store_set(f_diag->list_store, &iter,
+ PROTOCOL_COLUMN, info->name,
+ PROTOCOLICON_COLUMN, p_icon,
+ NICKNAME_COLUMN, nickname,
+ PM_COLUMN, protocol->set_status ? yes : no,
+ ICON_COLUMN, protocol->set_buddy_icon ? yes : no,
+ MOOD_COLUMN, mood,
+ MOODMSG_COLUMN, moodmsg,
+ TUNE_COLUMN, tune,
+ GAME_COLUMN, game,
+ APP_COLUMN, app,
+ -1);
+ }
+ }
+}
diff --git a/protocol_features.h b/protocol_features.h
new file mode 100644
index 0000000..b42f7f8
--- /dev/null
+++ b/protocol_features.h
@@ -0,0 +1,38 @@
+/* File: protocol_features.h
+ Time-stamp: <2011-02-07 17:31:27 gawen>
+
+ Copyright (C) 2011 David Hauweele <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _PROTOCOL_FEATURES_H_
+#define _PROTOCOL_FEATURES_H_
+
+#include "common.h"
+
+#include "gtk.h"
+
+struct protocol_features_dialog {
+ BEGIN_PBAR_WIDGET;
+
+ /* window and list storage */
+ GtkWidget *window;
+ GtkListStore *list_store;
+};
+
+struct protocol_features_dialog * create_protocol_features_dialog();
+void destroy_protocol_features_dialog(struct protocol_features_dialog *f_diag);
+void init_protocol_features_dialog(struct protocol_features_dialog *f_diag);
+
+#endif /* _PROTOCOL_FEATURES_H_ */
diff --git a/purple.c b/purple.c
new file mode 100644
index 0000000..bf47ca8
--- /dev/null
+++ b/purple.c
@@ -0,0 +1,386 @@
+/* File: purple.c
+ Time-stamp: <2011-02-07 20:11:54 gawen>
+
+ Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2008,2009 Craig Harding <[email protected]>
+ Wolter Hellmund <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* this file contains common functions for libpurple and pidgin */
+
+#include "common.h"
+
+#include "pbar.h"
+#include "gtk.h"
+#include "purple.h"
+
+/* callbacks */
+static void cb_global_moods_for_each(gpointer key, gpointer value,
+ gpointer user_data);
+static void cb_set_alias_failure(PurpleAccount *account, const char *error);
+static void cb_dummy();
+
+/* check if default gtk blist is created */
+gboolean is_gtk_blist_created()
+{
+ const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
+
+ if(!blist ||
+ !blist->vbox ||
+ !gtk_widget_get_visible(blist->vbox))
+ return FALSE;
+ return TRUE;
+}
+
+/* get buddy icon from statusbox widget */
+GdkPixbuf * get_buddy_icon()
+{
+ const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
+ const PidginStatusBox *statusbox = PIDGIN_STATUS_BOX(blist->statusbox);
+
+ return statusbox->buddy_icon;
+}
+
+/* get buddy icon hovered from statusbox widget */
+GdkPixbuf * get_buddy_icon_hover()
+{
+ const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
+ const PidginStatusBox *statusbox = PIDGIN_STATUS_BOX(blist->statusbox);
+
+ return statusbox->buddy_icon_hover;
+}
+
+/* create purple protocol icon from protocol info */
+GdkPixbuf * create_prpl_icon_from_info(PurplePluginProtocolInfo *prpl_info,
+ PidginPrplIconSize size)
+{
+ const char *protoname = NULL;
+ char *tmp;
+ char *filename = NULL;
+ GdkPixbuf *pixbuf;
+
+ if (prpl_info->list_icon == NULL)
+ return NULL;
+
+ protoname = prpl_info->list_icon(NULL, NULL);
+ if (protoname == NULL)
+ return NULL;
+
+ /*
+ * Status icons will be themeable too, and then it will look up
+ * protoname from the theme
+ */
+ tmp = g_strconcat(protoname, ".png", NULL);
+
+ filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols",
+ size == PIDGIN_PRPL_ICON_SMALL ? "16" :
+ size == PIDGIN_PRPL_ICON_MEDIUM ? "22" : "48",
+ tmp, NULL);
+ g_free(tmp);
+
+ pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
+ g_free(filename);
+
+ return pixbuf;
+}
+
+/* get current status stock id */
+const gchar * get_status_stock_id()
+{
+ const PurpleSavedStatus *status = purple_savedstatus_get_current();
+ PurpleStatusPrimitive prim = purple_savedstatus_get_type(status);
+
+ return pidgin_stock_id_from_status_primitive(prim);
+}
+
+/* get mood icon path */
+gchar * get_mood_icon_path(const gchar *mood)
+{
+ gchar *path;
+
+ if(!mood || !strcmp(mood, ""))
+ path = g_build_filename(DATADIR, "pixmaps", "pidgin",
+ "toolbar", "16", "emote-select.png", NULL);
+ else if(!strcmp(mood, "busy"))
+ path = g_build_filename(DATADIR, "pixmaps", "pidgin",
+ "status", "16", "busy.png", NULL);
+ else if(!strcmp(mood, "hiptop"))
+ path = g_build_filename(DATADIR, "pixmaps", "pidgin",
+ "emblems", "16", "hiptop.png", NULL);
+ else {
+ gchar *filename = g_strdup_printf("%s.png", mood);
+ path = g_build_filename(DATADIR, "pixmaps", "pidgin",
+ "emotes", "small", filename, NULL);
+ g_free(filename);
+ }
+
+ return path;
+}
+
+/* get available attributes for a protocol
+ returned hashtable should be freed manually */
+GHashTable * get_protocol_attrs(PurplePluginProtocolInfo *protocol)
+{
+ if(!protocol->status_types)
+ return NULL;
+
+ GHashTable *attrs = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
+ GList *l = protocol->status_types(NULL);
+ for(; l ; l = l->next) {
+ PurpleStatusType *type = (PurpleStatusType *)l->data;
+ GList *k = purple_status_type_get_attrs(type);
+ for(; k ; k = k->next) {
+ struct _PurpleStatusAttr {
+ char *id;
+ char *name;
+ PurpleValue *value_type;
+ };
+ struct _PurpleStatusAttr *attr = (struct _PurpleStatusAttr *)k->data;
+ if(g_hash_table_lookup(attrs, attr->id))
+ continue;
+ else
+ g_hash_table_insert(attrs, (gpointer)attr->id,
+ GINT_TO_POINTER(TRUE));
+ }
+ }
+
+ return attrs;
+}
+
+/* get available attributes for an account
+ returned hashtable should be freed manally */
+/* TODO: review this, now it does the same as get_protocol_attrs... */
+GHashTable * get_account_attrs(PurpleAccount *account)
+{
+ GHashTable *attrs = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
+ GList *l = purple_account_get_status_types(account);
+ for(; l ; l = l->next) {
+ PurpleStatusType *type = (PurpleStatusType *)l->data;
+ GList *k = purple_status_type_get_attrs(type);
+ for(; k ; k = k->next) {
+ struct _PurpleStatusAttr {
+ char *id;
+ char *name;
+ PurpleValue *value_type;
+ };
+ struct _PurpleStatusAttr *attr = (struct _PurpleStatusAttr *)k->data;
+ if(g_hash_table_lookup(attrs, attr->id))
+ continue;
+ else
+ g_hash_table_insert(attrs, (gpointer)attr->id,
+ GINT_TO_POINTER(TRUE));
+ }
+ }
+
+ return attrs;
+}
+
+
+/* get global moods */
+PurpleMood * get_global_moods()
+{
+ GHashTable *global_moods = g_hash_table_new_full(g_str_hash, g_str_equal,
+ NULL, NULL);
+ GHashTable *mood_counts = g_hash_table_new_full(g_str_hash, g_str_equal,
+ NULL, NULL);
+
+ GList *accounts = purple_accounts_get_all_active();
+ PurpleMood *result = NULL;
+ GList *out_moods = NULL;
+ int i = 0;
+ int num_accounts = 0;
+
+ for(; accounts ; accounts = g_list_delete_link(accounts, accounts)) {
+ PurpleAccount *account = (PurpleAccount *)accounts->data;
+
+ if(purple_account_is_connected(account)) {
+ PurpleConnection *gc = purple_account_get_connection(account);
+
+ if(gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS) {
+ PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
+ PurpleMood *mood = NULL;
+
+ for(mood = prpl_info->get_moods(account) ;
+ mood->mood ; mood++) {
+ int mood_count = GPOINTER_TO_INT(g_hash_table_lookup(mood_counts,
+ mood->mood));
+
+ if(!g_hash_table_lookup(global_moods, mood->mood))
+ g_hash_table_insert(global_moods, (gpointer)mood->mood, mood);
+ g_hash_table_insert(mood_counts, (gpointer)mood->mood,
+ GINT_TO_POINTER(mood_count + 1));
+ }
+
+ num_accounts++;
+ }
+ }
+ }
+
+ g_hash_table_foreach(global_moods, cb_global_moods_for_each, &out_moods);
+ result = g_new0(PurpleMood, g_hash_table_size(global_moods) + 1);
+
+ while(out_moods) {
+ PurpleMood *mood = (PurpleMood *)out_moods->data;
+ int in_num_accounts = GPOINTER_TO_INT(g_hash_table_lookup(mood_counts,
+ mood->mood));
+
+ if(in_num_accounts == num_accounts) {
+ /* mood is present in all accounts supporting moods */
+ result[i].mood = mood->mood;
+ result[i].description = mood->description;
+ i++;
+ }
+ out_moods = g_list_delete_link(out_moods, out_moods);
+ }
+
+ g_hash_table_destroy(global_moods);
+ g_hash_table_destroy(mood_counts);
+
+ return result;
+}
+
+/* set status to the specified mood */
+void set_status_with_mood(PurpleAccount *account, const gchar *mood)
+{
+ purple_account_set_status(account, "mood", TRUE, PURPLE_MOOD_NAME, mood,
+ NULL);
+}
+
+/* set exclusive status for all account */
+void set_status_all(const gchar *status_id, GList *attrs)
+{
+ GList *accts = purple_accounts_get_all_active();
+
+ /* empty list means we have nothing to do */
+ if(!attrs)
+ return;
+
+ for(; accts ; accts = g_list_delete_link(accts, accts)) {
+ PurpleAccount *account = accts->data;
+
+ if(!purple_account_is_connected(account))
+ continue;
+ purple_account_set_status_list(account, status_id, TRUE, attrs);
+ }
+}
+
+/* set display name for account */
+void set_display_name(PurpleAccount *account, const gchar *name)
+{
+ const gchar *id = purple_account_get_protocol_id(account);
+
+ /* exception for set_public_alias */
+ if(!strcmp(id, "prpl-jabber")) {
+ PurpleConnection *gc = account->gc;
+ gchar *iq_id = g_strdup_printf("purple%x", g_random_int());
+ xmlnode *iq, *pubsub, *publish, *nicknode;
+
+ gc = account->gc;
+ iq_id = g_strdup_printf("purple%x", g_random_int());
+ iq = xmlnode_new("iq");
+ xmlnode_set_attrib(iq, "type", "set");
+ xmlnode_set_attrib(iq, "id", iq_id);
+
+ pubsub = xmlnode_new("pubsub");
+ xmlnode_set_attrib(pubsub, "xmlns", "http://jabber.org/protocol/pubsub");
+ publish = xmlnode_new("publish");
+ xmlnode_set_attrib(publish,"node","http://jabber.org/protocol/nick");
+ nicknode = xmlnode_new_child(xmlnode_new_child(publish, "item"), "nick");
+ xmlnode_set_namespace(nicknode, "http://jabber.org/protocol/nick");
+ xmlnode_insert_data(nicknode, name, -1);
+ xmlnode_insert_child(pubsub, publish);
+ xmlnode_insert_child(iq, pubsub);
+
+ purple_signal_emit(purple_connection_get_prpl(gc),
+ "jabber-sending-xmlnode", gc, &iq);
+ g_free(iq_id);
+ }
+ else
+ /* provide dummy callback since some
+ protocols don't check before calling */
+ purple_account_set_public_alias(account, name, cb_dummy,
+ cb_set_alias_failure);
+}
+
+/* set display name for all connected accounts */
+void set_display_name_all(const char *name)
+{
+ GList *accts = purple_accounts_get_all_active();
+
+ for(; accts ; accts = g_list_delete_link(accts, accts)) {
+ PurpleAccount *account = accts->data;
+
+ if(!purple_account_is_connected(account))
+ continue;
+ set_display_name(account, name);
+ }
+}
+
+/* set status message (personal message) */
+void set_status_message(const gchar *pm)
+{
+ PurpleSavedStatus *status = purple_savedstatus_get_current();
+
+ purple_savedstatus_set_message(status, pm);
+ purple_savedstatus_activate(status);
+}
+
+void prpl_connect_signals(struct pbar_widget *w,
+ const struct pbar_prpl_signal *sig_list,
+ gpointer data)
+{
+ const struct pbar_prpl_signal *s = sig_list;
+ for(; s->signal ; s++)
+ purple_signal_connect(s->instance,
+ s->signal,
+ w,
+ PURPLE_CALLBACK(s->callback),
+ data);
+}
+
+void prpl_prefs_connect_signals(struct pbar_widget *w,
+ const struct pbar_prpl_signal *sig_list,
+ gpointer data)
+{
+ const struct pbar_prpl_signal *s = sig_list;
+ for(; s->signal ; s++)
+ purple_prefs_connect_callback(s->instance,
+ s->signal,
+ PURPLE_PREFS_CALLBACK(s->callback),
+ data);
+}
+
+void prpl_disconnect_signals(struct pbar_widget *w)
+{ purple_signals_disconnect_by_handle(w); }
+
+void prpl_prefs_disconnect_signals(struct pbar_widget *w)
+{ purple_prefs_disconnect_by_handle(w); }
+
+static void cb_global_moods_for_each(gpointer key, gpointer value,
+ gpointer user_data)
+{
+ GList **out_moods = (GList **)user_data;
+ PurpleMood *mood = (PurpleMood *)value;
+
+ *out_moods = g_list_append(*out_moods, mood);
+}
+
+static void cb_set_alias_failure(PurpleAccount *account, const char *error)
+{
+ const gchar *id = purple_account_get_protocol_id(account);
+
+ purple_debug_info(NAME, "aliases not supported by \"%s\"\n", id);
+}
+
+static void cb_dummy() {}
diff --git a/purple.h b/purple.h
new file mode 100644
index 0000000..646e60d
--- /dev/null
+++ b/purple.h
@@ -0,0 +1,64 @@
+/* File: purple.h
+ Time-stamp: <2011-02-07 20:12:06 gawen>
+
+ Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2008,2009 Craig Harding <[email protected]>
+ Wolter Hellmund <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _PURPLE_H_
+#define _PURPLE_H_
+
+#include "common.h"
+
+#include "gtk.h"
+
+struct pbar_prpl_signal {
+ void *instance;
+ const char *signal;
+ void *callback;
+};
+
+/* not sure purple define that */
+#ifndef PURPLE_PREFS_CALLBACK
+# define PURPLE_PREFS_CALLBACK(func) ((PurplePrefCallback)func)
+#endif
+
+gboolean is_gtk_blist_created();
+GdkPixbuf * create_prpl_icon_from_info(PurplePluginProtocolInfo *prpl_info,
+ PidginPrplIconSize size);
+GdkPixbuf * get_buddy_icon();
+GdkPixbuf * get_buddy_icon_hover();
+GHashTable * get_protocol_attrs(PurplePluginProtocolInfo *protocol);
+GHashTable * get_account_attrs(PurpleAccount *account);
+const gchar * get_status_stock_id();
+gchar * get_mood_icon_path();
+PurpleMood * get_global_moods();
+
+void set_status_message(const gchar *pm);
+void set_status_all(const gchar *status_id, GList *attrs);
+void set_status_with_mood(PurpleAccount *account, const gchar *mood);
+void set_display_name(PurpleAccount *account, const gchar *name);
+void set_display_name_all(const gchar *name);
+void prpl_disconnect_signals(struct pbar_widget *w);
+void prpl_prefs_disconnect_signals(struct pbar_widget *w);
+void prpl_connect_signals(struct pbar_widget *w,
+ const struct pbar_prpl_signal *sig_list,
+ gpointer data);
+void prpl_prefs_connect_signals(struct pbar_widget *w,
+ const struct pbar_prpl_signal *sig_list,
+ gpointer data);
+
+#endif /* _PURPLE_H_ */
diff --git a/status_dialog.c b/status_dialog.c
new file mode 100644
index 0000000..eb3f687
--- /dev/null
+++ b/status_dialog.c
@@ -0,0 +1,163 @@
+/* File: status_dialog.c
+ Time-stamp: <2011-02-09 20:09:53 gawen>
+
+ Copyright (C) 2011 David Hauweele <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "common.h"
+
+#include "gtk.h"
+#include "status_dialog.h"
+
+static void cb_destroy_win(GtkWidget *widget, gpointer data);
+static void cb_close_button(GtkWidget *widget, gpointer data);
+static void cb_apply_button(GtkWidget *widget, gpointer date);
+static void cb_refresh_button(GtkWidget *widget, gpointer data);
+
+enum {
+ STATUSICON_COLUMN,
+ STATUS_COLUMN,
+ N_COLUMN
+};
+
+static void cb_destroy_win(GtkWidget *widget, gpointer data)
+{ destroy_status_dialog((struct status_dialog *)data); }
+
+static void cb_apply_button(GtkWidget *widget, gpointer data)
+{
+}
+
+static void cb_close_button(GtkWidget *widget, gpointer data)
+{ destroy_status_dialog((struct status_dialog *)data); }
+
+static void cb_refresh_button(GtkWidget *widget, gpointer data)
+{
+ struct status_dialog *s_diag = (struct status_dialog *)data;
+ gtk_list_store_clear(s_diag->list_store);
+ init_status_dialog(s_diag);
+}
+
+struct status_dialog * create_status_dialog()
+{
+ struct status_dialog *s_diag = g_malloc(sizeof(struct status_dialog));
+ memset(s_diag, 0, sizeof(struct status_dialog));
+
+ /* widgets that can be modifier along dialog lifetime */
+ s_diag->window = pidgin_create_dialog(_("Status selection"),
+ PIDGIN_HIG_BORDER,
+ "status-select",
+ TRUE);
+ s_diag->list_store = gtk_list_store_new(N_COLUMN,
+ GDK_TYPE_PIXBUF, /* STATUSICON */
+ G_TYPE_STRING /* STATUS */ );
+
+ /* add main widgets */
+ gtk_add_main_widget(PBAR_WIDGET(s_diag), s_diag->window);
+
+ /* widgets that are not modified */
+ GtkWidget *vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(s_diag->window),
+ FALSE,
+ PIDGIN_HIG_BORDER);
+ GtkWidget *hbox = pidgin_dialog_get_action_area(GTK_DIALOG(s_diag->window));
+ GtkWidget *view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(s_diag->list_store));
+ GtkWidget *refresh_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
+ GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
+ GtkWidget *apply_button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
+
+ /* create view and model */
+ GtkTreeViewColumn *p_col = gtk_tree_view_column_new();
+ GtkCellRenderer *p_renderer;
+ gtk_tree_view_column_set_title(p_col, _("Status"));
+ gtk_tree_view_append_column(GTK_TREE_VIEW(view), p_col);
+ p_renderer = gtk_cell_renderer_pixbuf_new();
+ gtk_tree_view_column_pack_start(p_col, p_renderer, FALSE);
+ gtk_tree_view_column_add_attribute(p_col, p_renderer,
+ "pixbuf", STATUSICON_COLUMN);
+ p_renderer = gtk_cell_renderer_text_new();
+ gtk_tree_view_column_pack_start(p_col, p_renderer, TRUE);
+ gtk_tree_view_column_add_attribute(p_col, p_renderer,
+ "text", STATUS_COLUMN);
+
+ /* pack widgets */
+ gtk_box_pack_start(GTK_BOX(hbox), refresh_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), apply_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), view, TRUE, TRUE, 0);
+
+ /* gtk signals and callback */
+ const struct pbar_gtk_signal g_signal_connections[] = {
+ { s_diag->window, "destroy", cb_destroy_win },
+ { refresh_button, "clicked", cb_refresh_button },
+ { close_button, "clicked", cb_close_button },
+ { NULL, NULL, NULL }
+ };
+
+ /* connect signals and save handlers and instance when needed
+ to disconnect those signals when the widget is destroyed */
+ gtk_connect_signals(PBAR_WIDGET(s_diag), g_signal_connections, s_diag);
+
+ /* show everything */
+ gtk_widget_show_all(s_diag->window);
+ gtk_window_present(GTK_WINDOW(s_diag->window));
+
+ return s_diag;
+}
+
+void destroy_status_dialog(struct status_dialog *s_diag)
+{
+ gtk_destroy(PBAR_WIDGET(s_diag)); /* destroy widgets */
+ g_free(s_diag); /* free dialog */
+}
+
+void init_status_dialog(struct status_dialog *s_diag)
+{
+ GList *a = purple_accounts_get_all_active();
+ GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
+ NULL, NULL);
+
+ for(; a ; a = g_list_delete_link(a, a)) {
+ PurpleAccount *acct = (PurpleAccount *)a->data;
+ GList *types = purple_account_get_status_types(acct);
+
+ for(; types ; types = types->next) {
+ GtkTreeIter iter;
+ GdkPixbuf *icon;
+ PurpleStatusType *type = (PurpleStatusType *)types->data;
+ PurpleStatusPrimitive prim;
+ const gchar *stock, *status_name;
+
+ if(!purple_status_type_is_user_settable(type) ||
+ purple_status_type_is_independent(type))
+ continue;
+
+ prim = purple_status_type_get_primitive(type);
+ stock = pidgin_stock_id_from_status_primitive(prim);
+
+ if(g_hash_table_lookup(global_status, stock))
+ continue;
+ else
+ g_hash_table_insert(global_status, (gpointer)stock,
+ GINT_TO_POINTER(TRUE));
+ status_name = purple_status_type_get_name(type);
+ icon = gtk_widget_render_icon(s_diag->window, stock,
+ GTK_ICON_SIZE_MENU, NULL);
+ gtk_list_store_append(s_diag->list_store, &iter);
+ gtk_list_store_set(s_diag->list_store, &iter,
+ STATUSICON_COLUMN, icon,
+ STATUS_COLUMN, status_name,
+ -1);
+ }
+ }
+}
diff --git a/status_dialog.h b/status_dialog.h
new file mode 100644
index 0000000..d04537f
--- /dev/null
+++ b/status_dialog.h
@@ -0,0 +1,38 @@
+/* File: status_dialog.h
+ Time-stamp: <2011-02-09 20:05:59 gawen>
+
+ Copyright (C) 2011 David Hauweele <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _STATUS_DIALOG_H_
+#define _STATUS_DIALOG_H_
+
+#include "common.h"
+
+#include "gtk.h"
+
+struct status_dialog {
+ BEGIN_PBAR_WIDGET;
+
+ /* window and list storage */
+ GtkWidget *window;
+ GtkListStore *list_store;
+};
+
+struct status_dialog * create_status_dialog();
+void destroy_status_dialog(struct status_dialog *s_diag);
+void init_status_dialog(struct status_dialog *s_diag);
+
+#endif /* _STATUS_DIALOG_H_ */
diff --git a/widget.c b/widget.c
new file mode 100644
index 0000000..4371207
--- /dev/null
+++ b/widget.c
@@ -0,0 +1,534 @@
+/* File: widget.c
+ Time-stamp: <2011-02-08 19:42:07 gawen>
+
+ Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2008,2009 Craig Harding <[email protected]>
+ Wolter Hellmund <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "common.h"
+
+#include "pbar.h"
+#include "widget.h"
+#include "widget_gtk.h"
+#include "widget_prpl.h"
+#include "preferences.h"
+#include "purple.h"
+#include "gtk.h"
+
+/* we only have one widget per plugin
+ but this might change in the future */
+struct widget *bar;
+
+void create_widget()
+{
+ /* this should occurs only once but
+ this way way we avoid memory leaks */
+ if(!bar)
+ bar = g_malloc(sizeof(struct widget));
+ memset(bar, 0, sizeof(struct widget));
+
+ /* widgets that can possibly be modified along plugin's execution */
+ bar->icon = gtk_image_new();
+ bar->status = gtk_button_new_from_stock(NULL);
+ bar->mood = gtk_button_new_from_stock(NULL);
+ bar->name_label = gtk_label_new(NULL);
+ bar->name_eventbox = gtk_event_box_new();
+ bar->name_entry = gtk_entry_new();
+ bar->pm_label = gtk_label_new(NULL);
+ bar->pm_eventbox = gtk_event_box_new();
+ bar->pm_entry = gtk_entry_new();
+ bar->hbox = gtk_hbox_new(FALSE, 2);
+ bar->icon_eventbox = gtk_event_box_new();
+ bar->status_menu = gtk_menu_new();
+ bar->mood_menu = gtk_menu_new();
+
+ /* add main widgets */
+ gtk_add_main_widget(PBAR_WIDGET(bar), bar->hbox);
+ gtk_add_main_widget(PBAR_WIDGET(bar), bar->status_menu);
+ gtk_add_main_widget(PBAR_WIDGET(bar), bar->mood_menu);
+
+ /* widgets that are not modified */
+ GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
+ GtkWidget *hbox1 = gtk_hbox_new(FALSE, 2);
+ GtkWidget *hbox2 = gtk_hbox_new(FALSE, 2);
+
+ /* setup widgets */
+ gtk_label_set_ellipsize(GTK_LABEL(bar->name_label), PANGO_ELLIPSIZE_END);
+ gtk_label_set_ellipsize(GTK_LABEL(bar->pm_label), PANGO_ELLIPSIZE_END);
+ gtk_label_set_max_width_chars(GTK_LABEL(bar->name_label), 50);
+ gtk_button_set_relief(GTK_BUTTON(bar->status), GTK_RELIEF_NONE);
+ gtk_button_set_relief(GTK_BUTTON(bar->mood), GTK_RELIEF_NONE);
+ gtk_widget_set_can_focus(bar->name_eventbox, FALSE);
+ gtk_widget_set_can_focus(bar->pm_eventbox, FALSE);
+ gtk_widget_set_can_focus(bar->status, FALSE);
+ gtk_widget_set_can_focus(bar->mood, FALSE);
+ gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->icon_eventbox), FALSE);
+ gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->name_eventbox), FALSE);
+ gtk_event_box_set_visible_window(GTK_EVENT_BOX(bar->pm_eventbox), FALSE);
+
+ /* pack widgets */
+ gtk_container_add(GTK_CONTAINER(bar->name_eventbox), bar->name_label);
+ gtk_container_add(GTK_CONTAINER(bar->pm_eventbox), bar->pm_label);
+ gtk_container_add(GTK_CONTAINER(bar->icon_eventbox), bar->icon);
+ if(purple_prefs_get_bool(PREF "/compact")) {
+ gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_eventbox, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox1), bar->pm_entry, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox1), bar->mood, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
+ }
+ else {
+ gtk_box_pack_start(GTK_BOX(hbox1), bar->name_eventbox, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox1), bar->name_entry, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox1), bar->status, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_eventbox, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox2), bar->pm_entry, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox2), bar->mood, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0);
+ }
+ gtk_box_pack_start(GTK_BOX(bar->hbox), bar->icon_eventbox, FALSE, FALSE, 5);
+ gtk_box_pack_start(GTK_BOX(bar->hbox), vbox, TRUE, TRUE, 0);
+
+ /* pack at top of the buddy list and fallback to top
+ if the position option is unknown */
+ void (*gtk_box_pack)(GtkBox *, GtkWidget *, gboolean, gboolean, guint) = gtk_box_pack_start;
+ const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
+ switch(purple_prefs_get_int(PREF "/widget-position")) {
+ case(POSITION_TOP):
+ gtk_box_pack = gtk_box_pack_start;
+ break;
+ case(POSITION_BOTTOM):
+ gtk_box_pack = gtk_box_pack_end;
+ break;
+ };
+ gtk_box_pack(GTK_BOX(blist->vbox), bar->hbox, FALSE, TRUE, 2);
+ gtk_box_reorder_child(GTK_BOX(blist->vbox), bar->hbox, 0);
+
+ /* setup initial states */
+ bar->gtk_hnd = NULL;
+ bar->gtk_inst = NULL;
+ bar->hover_name = FALSE;
+ bar->hover_pm = FALSE;
+ bar->name_entry_activated = FALSE;
+ bar->pm_entry_activated = FALSE;
+ bar->name_dialog = FALSE;
+ bar->pm_dialog = FALSE;
+
+ /* gtk signals and callback */
+ const struct pbar_gtk_signal g_signal_connections[] = {
+ { bar->icon_eventbox, "button-press-event", cb_buddy_icon },
+ { bar->icon_eventbox, "enter-notify-event", cb_buddy_icon_enter },
+ { bar->icon_eventbox, "leave-notify-event", cb_buddy_icon_leave },
+ { bar->name_eventbox, "button-press-event", cb_name },
+ { bar->name_eventbox, "enter-notify-event", cb_name_enter },
+ { bar->name_eventbox, "leave-notify-event", cb_name_leave },
+ { bar->name_entry, "activate", cb_name_entry },
+ { bar->name_entry, "focus-out-event", cb_name_entry_focus_out },
+ { bar->pm_eventbox, "button-press-event", cb_pm },
+ { bar->pm_eventbox, "enter-notify-event", cb_pm_enter },
+ { bar->pm_eventbox, "leave-notify-event", cb_pm_leave },
+ { bar->pm_entry, "activate", cb_pm_entry },
+ { bar->pm_entry, "focus-out-event", cb_pm_entry_focus_out },
+ { bar->status, "clicked", cb_status_button },
+ { bar->mood, "clicked", cb_mood_button },
+ { NULL, NULL, NULL }
+ };
+
+ /* purple signals and callback */
+ const struct pbar_prpl_signal p_signal_connections[] = {
+ { purple_accounts_get_handle(), "account-status-changed", cb_status },
+ { purple_connections_get_handle(), "signed-on", cb_signed_on },
+ { NULL, NULL, NULL }
+ };
+
+ /* purple preferences signals and callback */
+ const struct pbar_prpl_signal pp_signal_connections[] = {
+ { bar, PIDGIN_PREFS_ROOT "/accounts/buddyicon", cb_buddy_icon_update },
+ { NULL, NULL, NULL }
+ };
+
+ /* connect signals and save handlers and instance when needed
+ to disconnect those signals when the widget is destroyed */
+ gtk_connect_signals(PBAR_WIDGET(bar), g_signal_connections, NULL);
+ prpl_connect_signals(PBAR_WIDGET(bar), p_signal_connections, NULL);
+ prpl_prefs_connect_signals(PBAR_WIDGET(bar), pp_signal_connections, NULL);
+
+ /* show everything */
+ gtk_widget_show_all(bar->hbox);
+ gtk_widget_hide(bar->name_entry);
+ gtk_widget_hide(bar->pm_entry);
+
+ /* inform that the bar is installed */
+ bar->installed = TRUE;
+}
+
+void destroy_widget()
+{
+ g_return_if_fail(bar->installed);
+
+ bar->installed = FALSE;
+
+ /* disconnect purple and prefs signals */
+ prpl_disconnect_signals(PBAR_WIDGET(bar));
+ prpl_prefs_disconnect_signals(PBAR_WIDGET(bar));
+
+ gtk_destroy(PBAR_WIDGET(bar)); /* destroy widgets */
+ g_free(bar); /* free widget */
+ bar = NULL;
+}
+
+/* load preferences into our widget */
+void init_widget()
+{
+ g_return_if_fail(bar->installed);
+
+ /* entry frame */
+ gboolean state = purple_prefs_get_bool(PREF "/frame-entry");
+ set_widget_entry_frame(state);
+
+ /* nickname */
+ const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup");
+ const gchar *value = purple_prefs_get_string(PREF "/nickname");
+ int jtype = purple_prefs_get_int(PREF "/nickname-justify");
+ set_widget_name(markup, value);
+ set_widget_name_justify(jtype);
+
+ /* personal message */
+ markup = purple_prefs_get_string(PREF "/personal-message-markup");
+ value = purple_prefs_get_string(PREF "/personal-message");
+ jtype = purple_prefs_get_int(PREF "/personal-message-justify");
+ set_widget_pm(markup, value);
+ set_widget_pm_justify(jtype);
+
+ /* buddy icon */
+ GdkPixbuf *icon = get_buddy_icon();
+ set_widget_icon(icon);
+
+ /* mood image */
+ const gchar *current_mood = purple_prefs_get_string(PREF "/mood");
+ gchar *path = get_mood_icon_path(current_mood);
+ set_widget_mood(path);
+ g_free(path);
+
+ /* status image */
+ const gchar *stock = get_status_stock_id();
+ set_widget_status(stock);
+
+ /* fill status menu */
+ GList *accts = purple_accounts_get_all_active();
+ GHashTable *global_status = g_hash_table_new_full(g_str_hash, g_str_equal,
+ NULL, NULL);
+ for(; accts ; accts = g_list_delete_link(accts, accts)) {
+ PurpleAccount *account = (PurpleAccount *)accts->data;
+ GList *types = purple_account_get_status_types(account);
+
+ for(; types ; types = types->next) {
+ PurpleStatusType *type = (PurpleStatusType *)types->data;
+ PurpleStatusPrimitive prim;
+ const gchar *stock, *status_name;
+ GtkWidget *menu_item, *icon;
+
+ if(!purple_status_type_is_user_settable(type) ||
+ purple_status_type_is_independent(type))
+ continue;
+
+ prim = purple_status_type_get_primitive(type);
+ stock = pidgin_stock_id_from_status_primitive(prim);
+
+ if(g_hash_table_lookup(global_status, stock))
+ continue;
+ else
+ g_hash_table_insert(global_status, (gpointer)stock,
+ GINT_TO_POINTER(TRUE));
+
+ status_name = purple_status_type_get_name(type);
+ menu_item = gtk_image_menu_item_new_with_label(status_name);
+ icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
+
+ gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), icon);
+ gtk_menu_shell_append(GTK_MENU_SHELL(bar->status_menu), menu_item);
+
+ g_signal_connect_swapped(menu_item, "activate",
+ G_CALLBACK(cb_status_menu),
+ (gpointer)type);
+
+ gtk_widget_show(menu_item);
+ }
+ }
+ g_hash_table_destroy(global_status);
+
+ /* statusbox hiding */
+ state = purple_prefs_get_bool(PREF "/hide-statusbox");
+ set_statusbox_visible(!state);
+}
+
+/* create a change name dialog */
+void create_name_dialog()
+{
+ const gchar *name = purple_prefs_get_string(PREF "/nickname");
+ if(!name || !strcmp(name, EMPTY_NAME))
+ name = "";
+
+ purple_request_input(thisplugin,
+ _("Change nickname"),
+ _("Enter your nickname here..."),
+ _("This will change your nickname "
+ "for every account which supports it."),
+ name,
+ FALSE,
+ FALSE,
+ NULL,
+ _("OK"),
+ G_CALLBACK(cb_name_apply),
+ _("Cancel"),
+ G_CALLBACK(cb_name_cancel),
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ bar->name_dialog = TRUE;
+}
+
+/* create a personal message dialog */
+void create_pm_dialog()
+{
+ PurpleRequestFields *fields;
+ PurpleRequestFieldGroup *group;
+ PurpleRequestField *field;
+ const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
+ if(!pm || !strcmp(pm, EMPTY_PM))
+ pm = "";
+
+ const struct s_field {
+ const gchar *text;
+ const gchar *pref;
+ } groups[] = {
+ { N_("_Mood message"), PREF "/mood-message" },
+ { N_("Current song"), NULL },
+ { N_("Song _title"), PREF "/tune-title" },
+ { N_("Song _artist"), PREF "/tune-artist" },
+ { N_("Song al_bum"), PREF "/tune-album" },
+ { N_("MSN pecan extra attributes"), NULL },
+ { N_("_Game name"), PREF "/game-message" },
+ { N_("_Office app name"), PREF "/office-message" },
+ { NULL, NULL },
+ { NULL, NULL }
+ }; const struct s_field *g = groups;
+
+ fields = purple_request_fields_new();
+ group = purple_request_field_group_new(_("Status and mood message"));
+ purple_request_fields_add_group(fields, group);
+
+ field = purple_request_field_string_new(PREF "/personal-message",
+ _("_Personal message"),
+ pm,
+ FALSE);
+ purple_request_field_set_required(field, FALSE);
+ purple_request_field_group_add_field(group, field);
+
+ for(; g->pref ; g++) {
+ for(; g->pref ; g++) {
+ const gchar *message;
+
+ if(purple_prefs_get_bool(PREF "/reset-attrs"))
+ message = "";
+ else
+ message = purple_prefs_get_string(g->pref);
+ field = purple_request_field_string_new(g->pref,
+ _(g->text),
+ message,
+ FALSE);
+ purple_request_field_set_required(field, FALSE);
+ purple_request_field_group_add_field(group, field);
+ }
+ group = purple_request_field_group_new(_(g->text));
+ purple_request_fields_add_group(fields, group);
+ }
+
+ purple_request_fields(thisplugin,
+ _("Change status messages"),
+ _("Enter status message..."),
+ _("This will change some status messages for every "
+ "account which supports it, please be advised "
+ "that some are inconsistent between each other."),
+ fields,
+ _("OK"),
+ G_CALLBACK(cb_pm_apply),
+ _("Cancel"),
+ G_CALLBACK(cb_pm_cancel),
+ NULL, NULL, NULL, NULL);
+ bar->pm_dialog = TRUE;
+}
+
+
+/* replace format character <c><r> with <n> string and escape with <c><c> */
+static gchar * g_strreplacefmt(const gchar *s, gchar c, gchar r, const gchar *n)
+{
+ int sn = strlen(n);
+ int sr = strlen(s);
+ int index = 0;
+ gchar *ret = g_malloc(sr);
+
+ for(; *s != '\0' ; s++) {
+ if(*s == c) {
+ s++;
+ if(*s == r) {
+ const gchar *i = n;
+
+ sr += sn;
+ ret = g_realloc(ret, sr);
+ for(; *i != '\0' ; i++, index++)
+ ret[index] = *i;
+ continue;
+ }
+ else if(*s != c || *s == '\0')
+ s--;
+ }
+
+ ret[index] = *s;
+ index++;
+ }
+
+ ret[index] = '\0';
+
+ return ret;
+}
+
+
+void set_widget_name(const gchar *markup, const gchar *name)
+{
+ g_return_if_fail(markup && name && bar->installed);
+
+ gchar *escaped_name, *new;
+
+ /* translate name if needed */
+ if(!strcmp(name, EMPTY_NAME))
+ name = _(EMPTY_NAME);
+
+ escaped_name = g_markup_printf_escaped("%s", name);
+ new = g_strreplacefmt(markup, '%', 'n', escaped_name);
+ g_free(escaped_name);
+
+ gtk_label_set_markup(GTK_LABEL(bar->name_label), new);
+ g_free(new);
+}
+
+void set_widget_pm(const gchar *markup, const gchar *pm)
+{
+ g_return_if_fail(markup && pm && bar->installed);
+
+ gchar *escaped_pm, *new;
+
+ /* translate pm if needed */
+ if(!strcmp(pm, EMPTY_PM))
+ pm = _(EMPTY_PM);
+
+ escaped_pm = g_markup_printf_escaped("%s", pm);
+ new = g_strreplacefmt(markup, '%', 'p', escaped_pm);
+ g_free(escaped_pm);
+
+ gtk_label_set_markup(GTK_LABEL(bar->pm_label), new);
+ g_free(new);
+}
+
+void set_widget_status(const gchar *stock)
+{
+ g_return_if_fail(stock && bar->installed);
+
+ GtkWidget *icon = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU);
+ gtk_button_set_image(GTK_BUTTON(bar->status), icon);
+ gtk_button_set_label(GTK_BUTTON(bar->status), "");
+}
+
+void set_widget_mood(const gchar *path)
+{
+ g_return_if_fail(path && bar->installed);
+
+ GtkWidget *mood = gtk_image_new_from_file(path);
+ gtk_button_set_image(GTK_BUTTON(bar->mood), mood);
+ gtk_button_set_label(GTK_BUTTON(bar->mood), "");
+}
+
+void set_widget_icon(GdkPixbuf *icon)
+{
+ g_return_if_fail(bar->installed);
+
+ if(icon)
+ gtk_image_set_from_pixbuf(GTK_IMAGE(bar->icon), icon);
+ else
+ gtk_image_set_from_stock(GTK_IMAGE(bar->icon), GTK_STOCK_MISSING_IMAGE, 48);
+}
+
+/* convertion of int justification
+ to float justification for
+ gtk_misc_set_alignment */
+static float int_jtype_to_float_jtype(int justify)
+{
+ float ret = 0.; /* default to left */
+
+ switch(justify) {
+ case(JUSTIFY_LEFT):
+ ret = 0.;
+ break;
+ case(JUSTIFY_CENTER):
+ ret = .5;
+ break;
+ case(JUSTIFY_RIGHT):
+ ret = 1.;
+ break;
+ }
+
+ return ret;
+}
+
+void set_widget_name_justify(int justify)
+{
+ g_return_if_fail(bar->installed);
+
+ float jtype = int_jtype_to_float_jtype(justify);
+ gtk_misc_set_alignment(GTK_MISC(bar->name_label), jtype, .5);
+}
+
+void set_widget_pm_justify(int justify)
+{
+ g_return_if_fail(bar->installed);
+
+ float jtype = int_jtype_to_float_jtype(justify);
+ gtk_misc_set_alignment(GTK_MISC(bar->pm_label), jtype, .5);
+}
+
+void set_widget_entry_frame(gboolean use_frame)
+{
+ g_return_if_fail(bar->installed);
+
+ gtk_entry_set_has_frame(GTK_ENTRY(bar->name_entry), use_frame);
+ gtk_entry_set_has_frame(GTK_ENTRY(bar->pm_entry), use_frame);
+}
+
+void set_statusbox_visible(gboolean visible)
+{
+ const PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
+ GtkWidget *statusbox = blist->statusbox;
+
+ if(statusbox)
+ gtk_widget_set_visible(statusbox, visible);
+}
+
+gboolean get_widget_name_hover_state() { return bar->hover_name; }
+gboolean get_widget_pm_hover_state() { return bar->hover_pm; }
diff --git a/widget.h b/widget.h
new file mode 100644
index 0000000..c2f1f8e
--- /dev/null
+++ b/widget.h
@@ -0,0 +1,86 @@
+/* File: widget.h
+ Time-stamp: <2011-02-08 19:39:51 gawen>
+
+ Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2008,2009 Craig Harding <[email protected]>
+ Wolter Hellmund <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _WIDGET_H_
+#define _WIDGET_H_
+
+#include "common.h"
+
+#include "gtk.h"
+
+struct widget {
+ BEGIN_PBAR_WIDGET;
+
+ /* icon and status */
+ GtkWidget *icon;
+ GtkWidget *icon_eventbox;
+ GtkWidget *status;
+ GtkWidget *status_menu;
+
+ /* mood */
+ GtkWidget *mood;
+ GtkWidget *mood_menu;
+
+ /* nickname */
+ GtkWidget *name_label;
+ GtkWidget *name_eventbox;
+ GtkWidget *name_entry;
+
+ /* personal message */
+ GtkWidget *pm_label;
+ GtkWidget *pm_eventbox;
+ GtkWidget *pm_entry;
+
+ GtkWidget *hbox; /* contains the widget */
+
+ gboolean installed; /* widget installed or not */
+ gboolean hover_name; /* name hovered or not */
+ gboolean hover_pm; /* pm hovered or not */
+
+ /* avoid setting status and name twice
+ with focus-out-event */
+ gboolean name_entry_activated;
+ gboolean pm_entry_activated;
+
+ /* avoid activating entry with dialog */
+ gboolean name_dialog;
+ gboolean pm_dialog;
+};
+
+extern struct widget *bar;
+
+void create_widget();
+void destroy_widget();
+void init_widget();
+void create_name_dialog();
+void create_pm_dialog();
+void set_widget_name(const gchar *markup, const gchar *name);
+void set_widget_pm(const gchar *markup, const gchar *pm);
+void set_widget_status(const gchar *stock);
+void set_widget_mood(const gchar *path);
+void set_widget_icon(GdkPixbuf *icon);
+void set_widget_name_justify(int justify);
+void set_widget_pm_justify(int justify);
+void set_widget_entry_frame(gboolean use_frame);
+void set_statusbox_visible(gboolean visible);
+gboolean get_widget_name_hover_state();
+gboolean get_widget_pm_hover_state();
+
+#endif /* _WIDGET_H_ */
diff --git a/widget_gtk.c b/widget_gtk.c
new file mode 100644
index 0000000..43f6574
--- /dev/null
+++ b/widget_gtk.c
@@ -0,0 +1,333 @@
+/* File: widget_gtk.c
+ Time-stamp: <2011-02-08 19:38:55 gawen>
+
+ Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2008,2009 Craig Harding <[email protected]>
+ Wolter Hellmund <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "common.h"
+
+#include "preferences.h"
+#include "widget_prpl.h"
+#include "widget_gtk.h"
+#include "widget.h"
+#include "purple.h"
+
+static void cb_icon_choose(const gchar *path, gpointer data)
+{
+ g_return_if_fail(path);
+
+ purple_prefs_set_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon", path);
+}
+
+void cb_buddy_icon(GtkWidget *widget, gpointer data)
+{
+ g_return_if_fail(bar->installed);
+
+ PidginBuddyList *blist = pidgin_blist_get_default_gtk_blist();
+ GtkWidget *chooser = pidgin_buddy_icon_chooser_new(GTK_WINDOW
+ (gtk_widget_get_toplevel
+ (GTK_WIDGET(blist))),
+ cb_icon_choose,
+ NULL);
+ gtk_widget_show(chooser);
+}
+
+void cb_buddy_icon_enter(GtkWidget *widget, gpointer data)
+{
+ g_return_if_fail(bar->installed);
+
+ GdkPixbuf *icon = get_buddy_icon_hover();
+
+ set_widget_icon(icon);
+ pidgin_set_cursor(bar->icon_eventbox, GDK_HAND2);
+}
+
+void cb_buddy_icon_leave(GtkWidget *widget, gpointer data)
+{
+ g_return_if_fail(bar->installed);
+
+ GdkPixbuf *icon = get_buddy_icon();
+
+ set_widget_icon(icon);
+ pidgin_clear_cursor(bar->icon_eventbox);
+}
+
+void cb_name(GtkWidget *widget, gpointer data)
+{
+ g_return_if_fail(bar->installed);
+
+ const gchar *name = purple_prefs_get_string(PREF "/nickname");
+ GdkEventButton *event = (GdkEventButton *)gtk_get_current_event();
+ gboolean swap = (event->button == 1);
+
+ swap = purple_prefs_get_bool(PREF "/swap-click") ? !swap : swap;
+
+ if(!name || !strcmp(name, EMPTY_NAME))
+ name = "";
+
+ if(swap && !bar->name_dialog) {
+ gtk_entry_set_text(GTK_ENTRY(bar->name_entry), name);
+
+ if(purple_prefs_get_bool(PREF "/compact"))
+ gtk_widget_hide(bar->pm_eventbox);
+ gtk_widget_hide(bar->name_eventbox);
+ gtk_widget_show(bar->name_entry);
+
+ gtk_widget_grab_focus(bar->name_entry);
+ }
+ else if(!bar->name_dialog)
+ create_name_dialog();
+}
+
+void cb_name_enter(GtkWidget *widget, gpointer data)
+{
+ g_return_if_fail(bar->installed);
+
+ const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup-hover");
+ const gchar *name = purple_prefs_get_string(PREF "/nickname");
+
+ bar->hover_name = TRUE;
+ set_widget_name(markup, name);
+}
+
+void cb_name_leave(GtkWidget *widget, gpointer data)
+{
+ g_return_if_fail(bar->installed);
+
+ const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup");
+ const gchar *name = purple_prefs_get_string(PREF "/nickname");
+
+ bar->hover_name = FALSE;
+ set_widget_name(markup, name);
+}
+
+void cb_name_entry(GtkWidget *widget, gpointer data)
+{
+ g_return_if_fail(bar->installed);
+
+ const gchar *name = gtk_entry_get_text(GTK_ENTRY(widget));
+ const gchar *markup = purple_prefs_get_string(PREF "/nickname-markup");
+
+ set_widget_name(markup, name);
+
+ purple_prefs_set_string(PREF "/nickname", name);
+ set_display_name_all(name);
+
+ bar->name_entry_activated = TRUE;
+
+ if(purple_prefs_get_bool(PREF "/compact"))
+ gtk_widget_show(bar->pm_eventbox);
+ gtk_widget_hide(bar->name_entry);
+ gtk_widget_show(bar->name_eventbox);
+
+ purple_debug_info(NAME, "nickname changed to \"%s\" by user\n", name);
+}
+
+void cb_name_entry_focus_out(GtkWidget *widget, gpointer data)
+{
+ if(!bar->name_entry_activated)
+ cb_name_entry(widget, data);
+ bar->name_entry_activated = FALSE;
+}
+
+void cb_pm(GtkWidget *widget, gpointer data)
+{
+ g_return_if_fail(bar->installed);
+
+ const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
+ GdkEventButton *event = (GdkEventButton *)gtk_get_current_event();
+ gboolean swap = (event->button == 1);
+
+ swap = purple_prefs_get_bool(PREF "/swap-click") ? !swap : swap;
+
+ if(!pm || !strcmp(pm, EMPTY_PM))
+ pm = "";
+
+ if(swap && !bar->pm_dialog) {
+ gtk_entry_set_text(GTK_ENTRY(bar->pm_entry), pm);
+
+ if(purple_prefs_get_bool(PREF "/compact"))
+ gtk_widget_hide(bar->name_eventbox);
+ gtk_widget_hide(bar->pm_eventbox);
+ gtk_widget_show(bar->pm_entry);
+
+ gtk_widget_grab_focus(bar->pm_entry);
+ }
+ else if(!bar->pm_dialog)
+ create_pm_dialog();
+}
+
+void cb_pm_enter(GtkWidget *widget, gpointer data)
+{
+ g_return_if_fail(bar->installed);
+
+ const gchar *markup = purple_prefs_get_string(PREF "/personal-message-markup-hover");
+ const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
+
+ bar->hover_pm = TRUE;
+ set_widget_pm(markup, pm);
+}
+
+void cb_pm_leave(GtkWidget *widget, gpointer data)
+{
+ g_return_if_fail(bar->installed);
+
+ const gchar *markup = purple_prefs_get_string(PREF "/personal-message-markup");
+ const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
+
+ bar->hover_pm = FALSE;
+ set_widget_pm(markup, pm);
+}
+
+void cb_pm_entry(GtkWidget *widget, gpointer data)
+{
+ g_return_if_fail(bar->installed);
+
+ const gchar *markup = purple_prefs_get_string(PREF "/personal-message-markup");
+ const gchar *pm = gtk_entry_get_text(GTK_ENTRY(widget));
+
+ purple_prefs_set_string(PREF "/personal-message", pm);
+
+ /* set personal message for all protocols */
+ set_status_message(pm);
+
+ set_widget_pm(markup, pm);
+ bar->pm_entry_activated = TRUE;
+
+ if(purple_prefs_get_bool(PREF "/compact"))
+ gtk_widget_show(bar->name_eventbox);
+ gtk_widget_hide(bar->pm_entry);
+ gtk_widget_show(bar->pm_eventbox);
+
+ purple_debug_info(NAME, "personal message changed to \"%s\" by user\n", pm);
+}
+
+void cb_pm_entry_focus_out(GtkWidget *widget, gpointer data)
+{
+ if(!bar->pm_entry_activated)
+ cb_pm_entry(widget, data);
+ bar->pm_entry_activated = FALSE;
+}
+
+void cb_status_button(GtkWidget *widget, gpointer data)
+{
+ g_return_if_fail(bar->installed);
+
+ GdkEventButton *event = (GdkEventButton *)gtk_get_current_event();
+
+ gtk_menu_popup(GTK_MENU(bar->status_menu), NULL, NULL, NULL, NULL,
+ event->button, event->time);
+}
+
+void cb_status_menu(gpointer data)
+{
+ g_return_if_fail(bar->installed);
+
+ const gchar *pm = purple_prefs_get_string(PREF "/personal-message");
+ PurpleStatusType *status_type = (PurpleStatusType *)data;
+ PurpleStatusPrimitive type_prim = purple_status_type_get_primitive(status_type);
+ PurpleSavedStatus *status = purple_savedstatus_get_current();
+
+ status = purple_savedstatus_get_current();
+ purple_savedstatus_set_type(status, type_prim);
+ purple_savedstatus_set_message(status, pm);
+ purple_savedstatus_activate(status);
+
+ purple_debug_info(NAME, "status changed to \"%s\" by user\n",
+ purple_status_type_get_name(status_type));
+}
+
+void cb_mood_button(GtkWidget *widget, gpointer data)
+{
+ g_return_if_fail(bar->installed);
+ const gchar *empty_mood;
+ GtkWidget *menu_item, *icon;
+ PurpleMood *mood = get_global_moods();
+ GdkEventButton *event;
+ GList *l, *i;
+ gchar *path;
+
+ /* destroy dop down mood menu and create a new one */
+ l = gtk_container_get_children(GTK_CONTAINER(bar->mood_menu));
+ for(i = l ; i ; i = i->next) {
+ gtk_widget_destroy(l->data);
+ l->data = NULL;
+ }
+ gtk_widget_destroy(bar->mood_menu);
+ bar->mood_menu = gtk_menu_new();
+
+ /* add empty mood to mood menu */
+ empty_mood = "";
+ path = get_mood_icon_path(empty_mood);
+ icon = gtk_image_new_from_file(path);
+ menu_item = gtk_image_menu_item_new_with_label(_("None"));
+ g_free(path);
+ gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), icon);
+ gtk_menu_shell_append(GTK_MENU_SHELL(bar->mood_menu), menu_item);
+ g_signal_connect_swapped(menu_item, "activate",
+ G_CALLBACK(cb_mood_menu),
+ (gpointer)empty_mood);
+ gtk_widget_show(menu_item);
+
+ /* fill mood menu */
+ for( ; mood->mood ; mood++) {
+ if(!mood->mood || !mood->description)
+ continue;
+
+ path = get_mood_icon_path(mood->mood);
+ icon = gtk_image_new_from_file(path);
+ menu_item = gtk_image_menu_item_new_with_label(_(mood->description));
+ g_free(path);
+
+ gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), icon);
+ gtk_menu_shell_append(GTK_MENU_SHELL(bar->mood_menu), menu_item);
+
+ g_signal_connect_swapped(menu_item, "activate",
+ G_CALLBACK(cb_mood_menu),
+ (gpointer)mood->mood);
+
+ gtk_widget_show(menu_item);
+ }
+
+ event = (GdkEventButton *)gtk_get_current_event();
+ gtk_menu_popup(GTK_MENU(bar->mood_menu), NULL, NULL, NULL, NULL,
+ event->button, event->time);
+}
+
+void cb_mood_menu(gpointer data)
+{
+ g_return_if_fail(bar->installed);
+
+ const gchar *mood = (const gchar *)data;
+ GList *accts = purple_accounts_get_all_active();
+ gchar *path;
+
+ for(; accts ; accts = g_list_delete_link(accts, accts)) {
+ PurpleAccount *account = (PurpleAccount *)accts->data;
+ PurpleConnection *gc = purple_account_get_connection(account);
+
+ if(gc && gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS)
+ set_status_with_mood(account, mood);
+ }
+
+ purple_prefs_set_string(PREF "/mood", mood);
+ path = get_mood_icon_path(mood);
+ set_widget_mood(path);
+ g_free(path);
+
+ purple_debug_info(NAME, "mood changed to \"%s\" by user\n", mood);
+}
diff --git a/widget_gtk.h b/widget_gtk.h
new file mode 100644
index 0000000..b7d6fb2
--- /dev/null
+++ b/widget_gtk.h
@@ -0,0 +1,48 @@
+/* File: widget_gtk.h
+ Time-stamp: <2010-10-28 01:03:07 gawen>
+
+ Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2008,2009 Craig Harding <[email protected]>
+ Wolter Hellmund <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _WIDGET_GTK_H_
+#define _WIDGET_GTK_H_
+
+#include "common.h"
+
+void cb_buddy_icon(GtkWidget *widget, gpointer data);
+void cb_buddy_icon_enter(GtkWidget *widget, gpointer data);
+void cb_buddy_icon_leave(GtkWidget *widget, gpointer data);
+
+void cb_name(GtkWidget *widget, gpointer data);
+void cb_name_enter(GtkWidget *widget, gpointer data);
+void cb_name_leave(GtkWidget *widget, gpointer data);
+void cb_name_entry(GtkWidget *widget, gpointer data);
+void cb_name_entry_focus_out(GtkWidget *widget, gpointer data);
+
+void cb_pm(GtkWidget *widget, gpointer data);
+void cb_pm_enter(GtkWidget *widget, gpointer data);
+void cb_pm_leave(GtkWidget *widget, gpointer data);
+void cb_pm_entry(GtkWidget *widget, gpointer data);
+void cb_pm_entry_focus_out(GtkWidget *widget, gpointer data);
+
+void cb_status_button(GtkWidget *widget, gpointer data);
+void cb_status_menu(gpointer data);
+
+void cb_mood_button(GtkWidget *widget, gpointer data);
+void cb_mood_menu(gpointer data);
+
+#endif /* _WIDGET_GTK_H_ */
diff --git a/widget_prpl.c b/widget_prpl.c
new file mode 100644
index 0000000..0fcd0bf
--- /dev/null
+++ b/widget_prpl.c
@@ -0,0 +1,229 @@
+/* File: widget_prpl.c
+ Time-stamp: <2010-11-15 18:03:20 gawen>
+
+ Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2008,2009 Craig Harding <[email protected]>
+ Wolter Hellmund <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "common.h"
+
+#include "preferences.h"
+#include "widget.h"
+#include "widget_prpl.h"
+#include "purple.h"
+
+void cb_status(PurpleAccount *account, PurpleStatus *old, PurpleStatus *new)
+{
+ g_return_if_fail(bar->installed);
+
+ PurpleStatusPrimitive prim;
+ const gchar *stock, *pm;
+
+ PurpleSavedStatus *status = purple_savedstatus_get_current();
+ if(purple_prefs_get_bool(PREF "/override-status")) {
+ pm = purple_prefs_get_string(PREF "/personal-message");
+ purple_savedstatus_set_message(status,pm);
+ purple_savedstatus_activate(status);
+ }
+ else {
+ const gchar *markup;
+ markup = purple_prefs_get_string(PREF "/personal-message-markup");
+ pm = purple_savedstatus_get_message(status);
+ if(!pm)
+ pm = "";
+ set_widget_pm(markup, pm);
+ purple_prefs_set_string(PREF "/personal-message", pm);
+ }
+
+ prim = purple_savedstatus_get_type(status);
+ stock = pidgin_stock_id_from_status_primitive(prim);
+ set_widget_status(stock);
+}
+
+void cb_signed_on(PurpleConnection *gc)
+{
+ const gchar *name = purple_prefs_get_string(PREF "/nickname");
+ PurpleAccount *account = purple_connection_get_account(gc);
+ set_display_name(account, name);
+
+ purple_debug_info(NAME, "nickname changed to \"%s\" by signed-on account\n",
+ name);
+
+ if(gc && gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS) {
+ const gchar *mood = purple_prefs_get_string(PREF "/mood");
+ set_status_with_mood(account, mood);
+
+ purple_debug_info(NAME, "mood changed to \"%s\" by signed-on account\n",
+ mood);
+ }
+
+ /* load tune and stuff */
+ GList *a_tune = NULL;
+ GList *a_mood = NULL;
+
+ const struct attrs {
+ const gchar *pref;
+ const gchar *attr;
+ GList **list;
+ } attrs[] = {
+ { PREF "/mood-message", PURPLE_MOOD_COMMENT, &a_mood },
+ { PREF "/tune-title", PURPLE_TUNE_TITLE, &a_tune },
+ { PREF "/tune-artist", PURPLE_TUNE_ARTIST, &a_tune },
+ { PREF "/tune-album", PURPLE_TUNE_ALBUM, &a_tune },
+ { PREF "/game-message", "game", &a_tune },
+ { PREF "/office-message", "office", &a_tune },
+ { NULL, NULL, NULL }
+ }; const register struct attrs *a = attrs;
+
+ for(; a->pref ; a++) {
+ const gchar *value;
+
+ if(purple_prefs_get_bool(PREF "/reset-attrs"))
+ value = NULL;
+ else
+ value = purple_prefs_get_string(a->pref);
+
+ if(value && !strcmp(value, ""))
+ value = NULL;
+ else
+ purple_debug_info(NAME, "%s message changed to \"%s\" by signed-on account\n",
+ a->attr, value);
+
+ *(a->list) = g_list_append(*(a->list), (gpointer)a->attr);
+ *(a->list) = g_list_append(*(a->list), (gpointer)value);
+ }
+
+ const struct status_list {
+ const gchar *status_id;
+ GList *list;
+ gboolean cont;
+ } status[] = {
+ { "tune", a_tune, TRUE },
+ { "mood", a_mood, TRUE },
+ { NULL, NULL, FALSE}
+ }; register const struct status_list *s = status;
+
+ for(; s->cont ; s++) {
+ purple_account_set_status_list(account, s->status_id, TRUE, s->list);
+ g_list_free(s->list);
+ }
+}
+
+void cb_buddy_icon_update(const char *name, PurplePrefType type,
+ gconstpointer val, gpointer data)
+{
+ g_return_if_fail(bar->installed);
+
+ GdkPixbuf *icon;
+
+ icon = get_buddy_icon();
+ set_widget_icon(icon);
+}
+
+void cb_name_apply(PurpleAccount *account, const char *user_info)
+{
+ g_return_if_fail(bar->installed);
+
+ const gchar *markup, *name;
+
+ name = user_info;
+ markup = purple_prefs_get_string(PREF "/nickname-markup");
+ set_widget_name(markup, name);
+
+ purple_prefs_set_string(PREF "/nickname", name);
+ set_display_name_all(name);
+
+ bar->name_dialog = FALSE;
+
+ purple_debug_info(NAME, "nickname changed to \"%s\" by user\n", name);
+}
+
+void cb_name_cancel(PurpleAccount *account, const char *user_info)
+{
+ g_return_if_fail(bar->installed);
+
+ bar->name_dialog = FALSE;
+}
+
+void cb_pm_apply(gpointer data, PurpleRequestFields *fields)
+{
+ g_return_if_fail(bar->installed);
+
+ /* attrs */
+ GList *a_tune = NULL;
+ GList *a_mood = NULL;
+
+ /* just to update widget */
+ const gchar *pm = purple_request_fields_get_string(fields, PREF "/personal-message");
+ const gchar *markup = purple_prefs_get_string(PREF "/personal-message-markup");
+ set_status_message(pm);
+ set_widget_pm(markup, pm);
+ purple_debug_info(NAME, "personal message changed to \"%s\" by user\n", pm);
+
+ const struct r_field {
+ const gchar *id;
+ const gchar *attr;
+ GList **list;
+ } r_fields[] = {
+ { PREF "/mood-message", PURPLE_MOOD_COMMENT, &a_mood },
+ { PREF "/tune-title", PURPLE_TUNE_TITLE, &a_tune },
+ { PREF "/tune-artist", PURPLE_TUNE_ARTIST, &a_tune },
+ { PREF "/tune-album", PURPLE_TUNE_ALBUM, &a_tune },
+ { PREF "/game-message", "game", &a_tune },
+ { PREF "/office-message", "office", &a_tune },
+ { NULL, NULL, NULL }
+ }; const register struct r_field *rf = r_fields;
+
+ for(; rf->id ; rf++) {
+ const gchar *value = purple_request_fields_get_string(fields, rf->id);
+
+ if(!purple_prefs_get_bool(PREF "/reset-attrs"))
+ purple_prefs_set_string(rf->id, value);
+
+ if(value && !strcmp(value, ""))
+ value = NULL;
+ else
+ purple_debug_info(NAME, "%s message changed to \"%s\" by user\n",
+ rf->attr, value);
+
+ *(rf->list) = g_list_append(*(rf->list), (gpointer)rf->attr);
+ *(rf->list) = g_list_append(*(rf->list), (gpointer)value);
+ }
+
+ const struct status_list {
+ const gchar *status_id;
+ GList *list;
+ gboolean cont;
+ } status[] = {
+ { "tune", a_tune, TRUE },
+ { "mood", a_mood, TRUE },
+ { NULL, NULL, FALSE}
+ }; register const struct status_list *s = status;
+
+ for(; s->cont ; s++) {
+ set_status_all(s->status_id, s->list);
+ g_list_free(s->list);
+ }
+
+ bar->pm_dialog = FALSE;
+}
+
+void cb_pm_cancel(gpointer data, PurpleRequestFields *fields)
+{
+ g_return_if_fail(bar->installed);
+
+ bar->pm_dialog = FALSE;
+}
diff --git a/widget_prpl.h b/widget_prpl.h
new file mode 100644
index 0000000..332bb6e
--- /dev/null
+++ b/widget_prpl.h
@@ -0,0 +1,35 @@
+/* File: widget_prpl.h
+ Time-stamp: <2010-11-08 18:51:46 gawen>
+
+ Copyright (C) 2010 David Hauweele <[email protected]>
+ Copyright (C) 2008,2009 Craig Harding <[email protected]>
+ Wolter Hellmund <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _WIDGET_PRPL_H_
+#define _WIDGET_PRPL_H_
+
+#include "common.h"
+
+void cb_name_apply(PurpleAccount *account, const char *user_info);
+void cb_name_cancel(PurpleAccount *account, const char *user_info);
+void cb_pm_apply(gpointer data, PurpleRequestFields *fields);
+void cb_pm_cancel(gpointer data, PurpleRequestFields *fields);
+void cb_status(PurpleAccount *account, PurpleStatus *old, PurpleStatus *new);
+void cb_signed_on(PurpleConnection *gc);
+void cb_buddy_icon_update(const char *name, PurplePrefType type,
+ gconstpointer val, gpointer data);
+
+#endif /* _WIDGET_PRPL_H_ */
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.