Changeset 5978 for branches/newosd

Show
Ignore:
Timestamp:
01/02/08 11:25:29 (11 months ago)
Author:
eugene
Message:

Updated to the latest devel version of libaosd and cleaned a code a little bit.

Location:
branches/newosd/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/newosd/src/iface.cpp

    r5974 r5978  
    11#include "iface.h" 
    2  
    3 #include <string> 
    42 
    53#include <licq_icqd.h> 
     
    119  aosd_set_transparency(aosd, TRANSPARENCY_COMPOSITE); 
    1210  aosd_set_hide_upon_mouse_event(aosd, True); 
    13   aosd_set_renderer(aosd, 
    14       reinterpret_cast<AosdRenderer>(aosd_text_renderer), &trd); 
     11  aosd_set_renderer(aosd, aosd_text_renderer, &trd); 
    1512  aosd_set_names(aosd, "OSD Plugin", "Licq"); 
    1613 
     
    2724  trd.shadow.y_offset = 2; 
    2825  trd.shadow.color = "black"; 
    29   trd.shadow.opacity = 127; 
    30  
    31   trd.fore.color = "green"; 
     26  trd.shadow.opacity = 192; 
     27 
    3228  trd.fore.opacity = 255; 
    3329 
     
    5046void Iface::processSignal(CICQSignal* sig) 
    5147{ 
    52   clearLayout(); 
     48  string msg = ""; 
     49  bool message = false; 
    5350 
    5451  switch (sig->Signal()) 
     
    6461        break; 
    6562 
    66       string msg = ""; 
     63      msg = u->GetAlias(); 
    6764 
    6865      switch (sig->SubSignal()) 
    6966      { 
    7067        case USER_STATUS: 
    71           msg = u->GetAlias(); 
    7268          msg += " changed status to: "; 
    7369          msg += u->StatusStr(); 
     
    7874        case USER_EVENTS: 
    7975          if (sig->Argument() < 0) 
     76          { 
     77            msg.clear(); 
    8078            break; 
     79          } 
    8180 
    8281          if (sig->Argument() == 0) 
    8382          { 
    84             msg = u->GetAlias(); 
    8583            msg += " checked your auto-response"; 
    8684            break; 
     
    9189            if (ue == NULL) 
    9290              break; 
    93             msg = setLayoutTag(u); 
     91            if (u->Secure()) // TODO config check 
     92              msg += " (S)"; 
     93            msg += ": "; 
    9494            char* trans = gTranslator.ToUnicode(const_cast<char*>(ue->Text()), 
    9595                u->UserEncoding()); 
    9696            msg += trans; 
    9797            delete[] trans; 
     98            message = true; 
    9899          } 
    99100          break; 
    100101 
    101102        default: 
     103          msg.clear(); 
    102104          break; 
    103105      } 
    104106 
    105107      gUserManager.DropUser(u); 
    106       pango_layout_set_text_aosd(trd.lay, const_cast<char*>(msg.c_str())); 
    107       displayLayout(); 
    108108    } 
    109109      break; 
     
    118118      break; 
    119119  } 
    120 } 
    121  
    122 void Iface::clearLayout() 
    123 { 
    124   pango_layout_set_text(trd.lay, "", -1); 
    125   pango_layout_set_indent(trd.lay, 0); 
     120 
     121  if (!msg.empty()) 
     122    displayLayout(msg, message); 
    126123} 
    127124 
     
    180177} 
    181178 
    182 const char* Iface::setLayoutTag(ICQUser* u) 
    183 { 
    184   string str = u->GetAlias(); 
    185   str += (true && u->Secure()) ? " (S)" : ""; 
    186   str += ": "; 
    187  
    188   int tag_width = 0; 
    189  
    190   pango_layout_set_text(trd.lay, str.c_str(), -1); 
    191   pango_layout_get_size(trd.lay, &tag_width, NULL); 
    192   pango_layout_set_indent(trd.lay, -tag_width); 
    193  
    194   return str.c_str(); 
    195 } 
    196  
    197 void Iface::displayLayout() 
    198 { 
    199   if (strlen(pango_layout_get_text(trd.lay)) == 0) 
    200     return; 
     179void Iface::displayLayout(string& msg, bool message) 
     180{ 
     181/* 
     182  string nl = "‹"; // U+2028 
     183  string::size_type pos = 0; 
     184  while ((pos = msg.find('\n', pos)) != string::npos) 
     185    msg.replace(pos, nl.length(), nl); 
     186*/ 
     187  pango_layout_set_text(trd.lay, const_cast<char*>(msg.c_str()), -1); 
     188 
     189  trd.fore.color = const_cast<char*>(message ? "green" : "gray"); 
    201190 
    202191  unsigned width, height; 
     
    205194 
    206195  aosd_set_position_with_offset(aosd, 
    207       COORDINATE_MINIMUM, COORDINATE_MINIMUM, 
     196      COORDINATE_MINIMUM, COORDINATE_MAXIMUM, 
    208197      width + 2 * trd.geom.x_offset + trd.shadow.x_offset, 
    209198      height + 2 * trd.geom.y_offset + trd.shadow.y_offset, 
    210       80, 80); 
    211  
    212   aosd_flash(aosd, 0, 1000, 150); 
     199      80, -80); 
     200 
     201  aosd_flash(aosd, 0, 3000, 150); 
    213202} 
    214203 
  • branches/newosd/src/iface.h

    r5974 r5978  
    22#define IFACE_H 
    33 
    4 class CICQSignal; 
    5 class ICQUser; 
     4#include <string> 
    65 
    7 extern "C" 
    8 { 
    96#include <libaosd/aosd.h> 
    107#include <libaosd/aosd-text.h> 
    118#undef Status 
    12 } 
     9 
     10class CICQSignal; 
     11class ICQUser; 
    1312 
    1413class Iface 
     
    2928 
    3029  const char* setLayoutTag(ICQUser* u); 
    31   void clearLayout(); 
    32   void displayLayout(); 
     30  void displayLayout(std::string& msg, bool message); 
    3331}; 
    3432