A PHP Error was encountered

Severity: 8192

Message: Function create_function() is deprecated

Filename: geshi/geshi.php

Line Number: 4698

Backtrace:

File: /var/www/stikked/htdocs/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler

File: /var/www/stikked/htdocs/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string

File: /var/www/stikked/htdocs/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list

File: /var/www/stikked/htdocs/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group

File: /var/www/stikked/htdocs/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache

File: /var/www/stikked/htdocs/application/libraries/Process.php
Line: 45
Function: parse_code

File: /var/www/stikked/htdocs/application/models/Pastes.php
Line: 517
Function: syntax

File: /var/www/stikked/htdocs/application/controllers/Main.php
Line: 693
Function: getPaste

File: /var/www/stikked/htdocs/index.php
Line: 315
Function: require_once

Untitled - Gajim's Pastbin

Untitled

From lovetox, 4 Months ago, written in Python, viewed 71 times. This paste will expire in 1 Second.
URL https://paste.gajim.org/view/35375d47 Embed
Download Paste or View Raw
  1. # This file is part of Gajim.
  2. #
  3. # Gajim is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published
  5. # by the Free Software Foundation; version 3 only.
  6. #
  7. # Gajim is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License
  13. # along with Gajim. If not, see <http://www.gnu.org/licenses/>.
  14.  
  15. from math import pi
  16.  
  17. from gi.repository import Gdk
  18. from gi.repository import PangoCairo
  19. from gi.repository import Pango
  20.  
  21. import cairo
  22.  
  23. from gajim.common import app
  24.  
  25.  
  26. def get_account_badge(account, font_size, scale):
  27.     account_label = app.get_account_label(account)
  28.     account_color = app.config.get_per('accounts', account, 'account_color')
  29.     surface = _create_account_badge(account_label, account_color, font_size,
  30.                                     scale)
  31.     surface = _clip_badge(surface)
  32.     surface.set_device_scale(scale, scale)
  33.     return surface
  34.  
  35.  
  36. def _create_account_badge(account_label, account_color, font_size, scale):
  37.     rgba = Gdk.RGBA()
  38.     rgba.parse(account_color)
  39.  
  40.     desc = Pango.FontDescription()
  41.     desc.set_size(9 * Pango.SCALE)
  42.     desc.set_weight(Pango.Weight.SEMIBOLD)
  43.  
  44.     # scale_attr = Pango.attr_scale_new(scale)
  45.     # attr_list = Pango.AttrList.new()
  46.     # attr_list.insert(scale_attr)
  47.  
  48.     pcontext = Gdk.pango_context_get()
  49.     for fam in pcontext.list_families():
  50.         print(fam.get_name())
  51.     layout = Pango.Layout.new(pcontext)
  52.     # layout.set_attributes(attr_list)
  53.     layout.set_font_description(desc)
  54.     layout.set_text(account_label, -1)
  55.     layout.set_ellipsize(Pango.EllipsizeMode.END)
  56.     layout.set_alignment(Pango.Alignment.CENTER)
  57.  
  58.  
  59.     width, height = layout.get_size()
  60.     width = int(Pango.units_to_double(width))
  61.     height = int(Pango.units_to_double(height))
  62.  
  63.     if width >= 70:
  64.         width = 70
  65.  
  66.     layout.set_width(Pango.units_from_double(width))
  67.     layout.set_justify(True)
  68.  
  69.     padding = 7
  70.  
  71.     context_w = width + padding * 2
  72.     context_h = height + padding * 2
  73.  
  74.     surface = cairo.ImageSurface(
  75.         cairo.FORMAT_ARGB32, context_w, context_h)
  76.     context = cairo.Context(surface)
  77.  
  78.     context.set_source_rgb(rgba.red, rgba.green, rgba.blue)
  79.     context.rectangle(0, 0, context_w, context_h)
  80.     context.fill()
  81.  
  82.     context.set_source_rgb(0.95, 0.95, 0.95)
  83.  
  84.     context.move_to(padding, padding)
  85.  
  86.     PangoCairo.update_context(context, pcontext)
  87.     PangoCairo.show_layout(context, layout)
  88.  
  89.     return context.get_target()
  90.  
  91.  
  92. def _clip_badge(surface):
  93.     new_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32,
  94.                                      surface.get_width(),
  95.                                      surface.get_height())
  96.  
  97.     new_surface.set_device_scale(*surface.get_device_scale())
  98.     context = cairo.Context(new_surface)
  99.     context.set_source_surface(surface, 0, 0)
  100.  
  101.     scale = surface.get_device_scale()[0]
  102.  
  103.     width = surface.get_width() * scale
  104.     height = surface.get_height() * scale
  105.  
  106.     radius = height / 4
  107.     degrees = pi / 180.0
  108.  
  109.     context.new_sub_path()
  110.     context.arc(width - radius, radius, radius, -90 * degrees, 0 * degrees)
  111.     context.arc(
  112.         width - radius, height - radius, radius, 0 * degrees, 90 * degrees)
  113.     context.arc(radius, height - radius, radius, 90 * degrees, 180 * degrees)
  114.     context.arc(radius, radius, radius, 180 * degrees, 270 * degrees)
  115.     context.close_path()
  116.  
  117.     context.clip()
  118.     context.paint()
  119.  
  120.     return context.get_target()
  121.  

Reply to "Untitled"

Here you can reply to the paste above