Changeset 5965 for branches/newosd

Show
Ignore:
Timestamp:
12/21/07 00:22:39 (11 months ago)
Author:
eugene
Message:

Updated to the new libaosd API.

Location:
branches/newosd/src
Files:
2 modified

Legend:

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

    r5856 r5965  
    11#include "iface.h" 
     2 
     3#include <stdlib.h> 
     4#include <sys/wait.h> 
    25 
    36#include <licq_icqd.h> 
    47 
    5 extern "C" 
    6 { 
    7 #include <libaosd/aosd.h> 
    8 #include <libaosd/aosd-text.h> 
    9 } 
    10  
    118Iface::Iface() 
    129{ 
    13   aosd = aosd_new_text( 
    14       "<span font_desc='Times New Roman 20' color='red'>" 
    15       "Received a signal..." 
    16       "</span>", 
    17       80, 80); 
     10  aosd = aosd_new(); 
     11  aosd_set_transparency(aosd, TRANSPARENCY_COMPOSITE); 
     12  aosd_set_hide_upon_mouse_event(aosd, True); 
     13  aosd_set_renderer(aosd, 
     14      reinterpret_cast<AosdRenderer>(aosd_text_renderer), &trd); 
     15  aosd_set_names(aosd, "OSD Plugin", "Licq"); 
    1816 
    19   aosd_set_transparency(aosd, TRANSPARENCY_COMPOSITE); 
     17  memset(&trd, 0, sizeof(TextRenderData)); 
     18 
     19  g_type_init(); 
     20 
     21  trd.lay = pango_layout_new_aosd(); 
     22 
     23  trd.geom.x_offset = 10; 
     24  trd.geom.y_offset = 10; 
     25 
     26  trd.shadow.x_offset = 2; 
     27  trd.shadow.y_offset = 2; 
     28  trd.shadow.color = "black"; 
     29  trd.shadow.opacity = 127; 
     30 
     31  trd.fore.color = "green"; 
     32  trd.fore.opacity = 255; 
     33 
     34  pango_layout_set_font_aosd(trd.lay, "Times New Roman Bold 24"); 
     35 
     36  int max_width; 
     37  aosd_get_screen_size(aosd, &max_width, NULL); 
     38  max_width -= 2 * trd.geom.x_offset + trd.shadow.x_offset + 80; 
     39  if (max_width > 0) 
     40    pango_layout_set_width(trd.lay, max_width * PANGO_SCALE); 
    2041} 
    2142 
     
    2344{ 
    2445  aosd_destroy(aosd); 
     46  pango_layout_unref_aosd(trd.lay); 
    2547} 
    2648 
    2749void Iface::processSignal(CICQSignal* sig) 
    2850{ 
    29   aosd_flash(aosd, 0, 100); 
     51  if (setText(sig->Id(), sig->PPID())) 
     52    aosd_flash(aosd, 0, 1000, 150); 
     53} 
     54 
     55bool Iface::setText(char* id, unsigned long ppid) 
     56{ 
     57  int tag_width; 
     58  unsigned width, height; 
     59 
     60  if (id == NULL) 
     61    return false; 
     62 
     63  ICQUser* u = gUserManager.FetchUser(id, ppid, LOCK_R); 
     64  if (u == NULL) 
     65    return false; 
     66 
     67  char* alias = strdup(u->GetAlias()); 
     68  gUserManager.DropUser(u); 
     69  alias = static_cast<char*>(realloc(alias, strlen(alias) + 3)); 
     70  strcat(alias, ": "); 
     71 
     72  pango_layout_set_text(trd.lay, alias, -1); 
     73  pango_layout_get_size(trd.lay, &tag_width, NULL); 
     74  pango_layout_set_indent(trd.lay, -tag_width); 
     75 
     76  char* x = "received\nthe\nsignal"; 
     77  alias = static_cast<char*>(realloc(alias, strlen(alias) + strlen(x) + 1)); 
     78  strcat(alias, x); 
     79 
     80  pango_layout_set_text_aosd(trd.lay, alias); 
     81  free(alias); 
     82  pango_layout_get_size_aosd(trd.lay, &width, &height, &trd.lbearing); 
     83 
     84  aosd_set_position_with_offset(aosd, 
     85      COORDINATE_MINIMUM, COORDINATE_MINIMUM, 
     86      width + 2 * trd.geom.x_offset + trd.shadow.x_offset, 
     87      height + 2 * trd.geom.y_offset + trd.shadow.y_offset, 
     88      80, 80); 
     89 
     90  return true; 
    3091} 
    3192 
  • branches/newosd/src/iface.h

    r5856 r5965  
    44class CICQSignal; 
    55 
    6 typedef struct _Aosd Aosd; 
     6extern "C" 
     7{ 
     8#include <libaosd/aosd.h> 
     9#include <libaosd/aosd-text.h> 
     10#undef Status 
     11} 
    712 
    813class Iface 
     
    1621private: 
    1722  Aosd* aosd; 
     23  TextRenderData trd; 
     24 
     25  bool setText(char* id, unsigned long ppid); 
    1826}; 
    1927 
    2028#endif 
     29 
    2130/* vim: set ts=2 sw=2 et : */