Beispiel #1
0
static void
satip_device_dbus_notify( satip_device_t *sd, const char *sig_name )
{
#if ENABLE_DBUS_1
  char buf[256];

  htsmsg_t *msg = htsmsg_create_list();
  htsmsg_add_str(msg, NULL, sd->sd_info.addr);
  htsmsg_add_str(msg, NULL, sd->sd_info.location);
  htsmsg_add_str(msg, NULL, sd->sd_info.server);
  snprintf(buf, sizeof(buf), "/input/mpegts/satip/%s", idnode_uuid_as_str(&sd->th_id));
  dbus_emit_signal(buf, sig_name, msg);
#endif
}
Beispiel #2
0
/**
 * Callback called when the document is scrolled.
 */
static void on_document_scroll(WebKitDOMEventTarget *target, WebKitDOMEvent *event,
        WebKitWebPage *page)
{
    WebKitDOMDocument *doc;

    if (WEBKIT_DOM_IS_DOM_WINDOW(target)) {
        g_object_get(target, "document", &doc, NULL);
    } else {
        /* target is a doc document */
        doc = WEBKIT_DOM_DOCUMENT(target);
    }

    if (doc) {
        WebKitDOMElement *body, *de;
        glong max = 0, scrollTop, scrollHeight, clientHeight;
        guint percent = 0;

        de = webkit_dom_document_get_document_element(doc);
        if (!de) {
            return;
        }

        body = WEBKIT_DOM_ELEMENT(webkit_dom_document_get_body(doc));
        if (!body) {
            return;
        }

        scrollTop = webkit_dom_element_get_scroll_top(body);
        if (scrollTop) {
            clientHeight = webkit_dom_element_get_client_height(WEBKIT_DOM_ELEMENT(de));
            scrollHeight = webkit_dom_element_get_scroll_height(body);

            /* Get the maximum scrollable page size. This is the size of the whole
            * document - height of the viewport. */
            max = scrollHeight - clientHeight ;
            if (max) {
                percent = (guint)(0.5 + (scrollTop * 100 / max));
            }
        }

        dbus_emit_signal("VerticalScroll", g_variant_new("(ttq)",
                    webkit_web_page_get_id(page), max, percent));
    }
}