示例#1
0
static int
_action(Evry_Action *action)
{
   const Evry_Item *it = action->it1.item;

   ecore_x_selection_primary_set(clipboard_win, it->label, strlen(it->label));
   ecore_x_selection_clipboard_set(clipboard_win, it->label, strlen(it->label));

   return 1;
}
示例#2
0
文件: elicit.c 项目: rephorm/elicit
static void
cb_edje_signal(void *data, Evas_Object *obj, const char *emission, const char *source)
{
  Elicit *el = data;
  char *signal;
  char *tok;
  int invalid = 0;

  /* ignore signals we sent */
  if (!strcmp(source, "elicit"))
    return;

  signal = strdup(emission);
  printf("signal: %s\n", signal);

  tok = strtok(signal, ","); // first is 'elicit'
  tok = strtok(NULL, ",");

  if (!tok) {
    fprintf(stderr, "[Elicit] Error: invalid signal: %s\n", emission);
    free(signal);
    return;
  }

  /* magnification */
  if (!strcmp(tok, "magnify"))
  {
    tok = strtok(NULL, ",");
    if (tok && !strcmp(tok, "start"))
    {
      el->state.magnifying = 1;
      elicit_cursor_set_cross(el);
    }
    else if (tok && !strcmp(tok, "stop"))
    {
      el->state.magnifying = 0;
      elicit_magnify_stop(el);
    }
    else
      invalid = 1;
  }

  /* color selection */
  else if (!strcmp(tok, "pick")) 
  {
    tok = strtok(NULL, ",");
    if (tok && !strcmp(tok, "start"))
    {
      el->state.picking = 1;
      elicit_cursor_set_cross(el);
    }
    else if (tok && !strcmp(tok, "stop"))
    {
      el->state.picking = 0;
      elicit_cursor_set_default(el);
    }
    else
      invalid = 1;
  }

  else if (!strcmp(tok, "scroll"))
  {
    tok = strtok(NULL, ",");
    if (tok && !strcmp(tok, "up"))
      elicit_scroll(el, source, 1);
    else if (tok && !strcmp(tok, "down"))
      elicit_scroll(el, source, -1);
    else
      invalid = 1;
  }

  /* palette */
  else if (!strcmp(tok, "palette"))
  {
    tok = strtok(NULL, ",");
    if (tok && !strcmp(tok, "add"))
    {
      Color *c;

      c = color_clone(el->color);
      palette_color_append(el->palette, c);
      palette_view_select(el->obj.palette, c);
      color_unref(c); // (the palette retains a ref)
    }
    else if (tok && !strcmp(tok, "remove"))
    {
      Color *c;
      c = palette_view_selected(el->obj.palette);

      if (c)
      {
        palette_color_remove(el->palette, c);
        palette_view_select(el->obj.palette, NULL);
      }
    }
    else if (tok && !strcmp(tok, "columns"))
    {
      int col;
      tok = strtok(NULL, ",");

      col = palette_columns_get(el->palette);
      if (tok && !strcmp(tok, "up"))
        col += 1;
      else if (tok && !strcmp(tok, "down"))
        col -= 1;

      palette_columns_set(el->palette, col);
      palette_view_changed(el->obj.palette);
    }
    else
      invalid = 1;
  }

  /* band config */
  else if (!strcmp(tok, "band"))
  {
    tok = strtok(NULL, ",");
    if (tok && !strcmp(tok, "toggle"))
    {
      elicit_show_band_set(el, !el->conf.show_band);
    }
    else if (tok && !strcmp(tok, "on"))
    {
      elicit_show_band_set(el, 1);
    }
    else if (tok && !strcmp(tok, "off"))
    {
      elicit_show_band_set(el, 0);
    }
  }

  /* grid config */
  else if (!strcmp(tok, "grid"))
  {
    tok = strtok(NULL, ",");
    if (tok && !strcmp(tok, "toggle"))
    {
      elicit_grid_visible_set(el, !el->conf.grid_visible);
    }
    else if (tok && !strcmp(tok, "on"))
    {
      elicit_grid_visible_set(el, 1);
    }
    else if (tok && !strcmp(tok, "off"))
    {
      elicit_grid_visible_set(el, 0);
    }
  }

  /* color classes */
  else if (!strcmp(tok, "colorclass"))
  {
    int r,g,b,a;
    color_rgba_get(el->color, &r, &g, &b, &a);
    edje_object_color_class_set(el->obj.main, source, r, g, b, a, r, g, b, a, r, g, b, a);
  }

  else if (!strcmp(tok, "hex"))
  {
    tok = strtok(NULL, ",");
    if (tok && !strcmp(tok, "copy"))
    {
      Ecore_X_Window win;
      const char *hex;
      int len;

      win = ecore_evas_software_x11_window_get(el->ee);
      hex = color_hex_get(el->color, COLOR_HEX_HASH | COLOR_HEX_CAPS);
      if (hex)
      {
        len = strlen(hex);
        ecore_x_selection_primary_set(win, hex, len);
        ecore_x_selection_clipboard_set(win, hex, len);
      }
    }
    else
      invalid = 1;
  }

  /* quit */
  else if (!strcmp(tok, "quit"))
    ecore_main_loop_quit();

  /* unknown signal */
  else
    invalid = 1;

  if (invalid)
    fprintf(stderr, "[Elicit] Error: invalid signal: %s\n", emission);

  free(signal);
}