예제 #1
0
파일: menu.c 프로젝트: r0j3r/aewm-fork
int win_on_cur_desk(Window w)
{
    unsigned long w_desk, cur_desk;

    if (atom_get(root, net_cur_desk, XA_CARDINAL, 0, &cur_desk, 1, NULL) &&
            (atom_get(w, net_wm_desk, XA_CARDINAL, 0, &w_desk, 1, NULL)))
        return ON_DESK(w_desk, cur_desk);
    else
        return 1;
}
예제 #2
0
error filenamedb_add(filenamedb_t *db,
                     const char   *id,
                     const char   *filename)
{
  error                err;
  int                  kindex;
  atom_t               vindex;
  const unsigned char *key;
  const char          *value;

  err = digestdb_add((const unsigned char *) id, &kindex);
  if (err)
    return err;

  key = digestdb_get(kindex);

  err = atom_new(db->filenames, (const unsigned char *) filename,
                 strlen(filename) + 1, &vindex);
  if (err == error_ATOM_NAME_EXISTS)
    err = error_OK;
  else if (err)
    return err;

  value = (const char *) atom_get(db->filenames, vindex, NULL);

  /* this will update the value if the key is already present */

  hash_insert(db->hash, (unsigned char *) key, (char *) value);

  return error_OK;
}
예제 #3
0
파일: win.c 프로젝트: andreas-volker/owl-wb
void
win_load(Win *w) {
    char *c, *s, buf[BUFSIZ];
    unsigned int i;
    unsigned char *p;
    struct { char *id, *c; } alias[] = {
        { "wiki",   "%s.wikipedia.org"          },
        { "ddg",    "duckduckgo.com/?q=%s"      },
        { "git",    "github.com/andreas-volker" },
    };

    if(!atom_get(w, atoms[_OWL_URI], XA_STRING, sizeof(buf), &p))
        return;
    c = !p ? "about:blank" : (!strcmp((char*)p, "") ? HOMEPAGE : (char*)p);
    s = estrdup(c);
    for(i = 0; s[i] && s[i] != ' '; i++);
    s[i] = '\0';
    c = strstr(c, ":") || strstr(c, "/") || strstr(c, ".") ? g_strdup(c) :
        g_strdup_printf(SEARCH, c);
    XFree(p);
    for(i = 0; i < LEN(alias); i++) {
        if(strcmp(s, alias[i].id) != 0)
            continue;
        g_free(c);
        c = strchr(s, '\0');
        c = strstr(alias[i].c, "%s") ? g_strdup_printf(alias[i].c, ++c) :
            g_strdup(alias[i].c);
    }
    free(s);
    s = g_file_test(c, G_FILE_TEST_EXISTS) ? "file://" :
        (!strstr(c, ":") ? "http://" : "");
    snprintf(buf, sizeof(buf), "%s%s", s, c);
    g_free(c);
    webkit_web_view_load_uri(w->web, buf);
}
예제 #4
0
파일: menu.c 프로젝트: r0j3r/aewm-fork
int win_should_skip(Window w)
{
    Atom win_type, state;
    int i;
    unsigned long r;

    if (atom_get(w, net_wm_wintype, XA_ATOM, 0, &win_type, 1, NULL) &&
            (win_type == net_wm_type_dock || win_type == net_wm_type_desk))
        return 1;

    for (i = 0, r = 1; r; i += r)
        if ((r = atom_get(w, net_wm_state, XA_ATOM, i, &state, 1, NULL)) &&
                (state == net_wm_state_skipt || state == net_wm_state_skipp))
            return 1;

    return 0;
}
예제 #5
0
파일: win.c 프로젝트: andreas-volker/owl-wb
void
win_find(Win *w, gboolean b) {
    char buf[BUFSIZ];
    unsigned char *p;

    webkit_web_view_unmark_text_matches(w->web);
    if(!atom_get(w, atoms[_OWL_FIND], XA_STRING, sizeof(buf), &p) || !p)
        return;
    memset(&buf, '\0', sizeof(buf));
    strncpy(buf, (char*)p, sizeof(buf));
    XFree(p);
    webkit_web_view_mark_text_matches(w->web, buf, CASEFIND, 0);
    webkit_web_view_set_highlight_text_matches(w->web, TRUE);
    webkit_web_view_search_text(w->web, buf, CASEFIND, b, TRUE);
}
예제 #6
0
파일: test.c 프로젝트: dpt/PrivateEye
static error test_to_string(atom_set_t *d)
{
  int i;

  printf("test: to string\n");

  for (i = 0; i < NELEMS(data); i++)
  {
    const char *string;

    string = (const char *) atom_get(d, i, NULL);
    if (string)
      printf("%d is '%s'\n", i, string);
  }

  return error_OK;
}
예제 #7
0
파일: test.c 프로젝트: dpt/PrivateEye
static error test_to_string_and_len(atom_set_t *d)
{
  int i;

  printf("test: to string and length\n");

  for (i = 0; i < NELEMS(data); i++)
  {
    const char *string;
    size_t      len;

    string = (const char *) atom_get(d, i, &len);
    if (string)
      printf("%d is '%.*s' (length %u)\n", i, (int) len, string, len);
  }

  return error_OK;
}
예제 #8
0
static error unformat_value(const char *buf,
                            size_t      len,
                            void      **value,
                            void       *opaque)
{
  error         err;
  filenamedb_t *db = opaque;
  atom_t        vindex;

  NOT_USED(len);

  err = atom_new(db->filenames,
                 (const unsigned char *) buf,
                 strlen(buf) + 1, // use 'len'?
                &vindex);
  if (err == error_ATOM_NAME_EXISTS)
    err = error_OK;
  else if (err)
    return err;

  *value = (void *) atom_get(db->filenames, vindex, NULL); // casting away const

  return error_OK;
}
예제 #9
0
파일: digest-db.c 프로젝트: dpt/DPTLib
const unsigned char *digestdb_get(int index)
{
  return atom_get(LOCALS.digests, index, NULL);
}