Beispiel #1
0
void Service::addCustomAction(QString action, QString text, QString iconstr)
{
    QIcon icon(descriptor_.file(iconstr));

    QAction* a = new QAction(!icon.availableSizes().size() ? QIcon::fromTheme(iconstr) : icon, text, this);
    install_action(a, action, true);
}
Beispiel #2
0
static int
add_user_handler(ABObj obj, ABObj module,
                 ISTRING handler, AB_WHEN when)
{
    int                 retval = 0;
    ABObj               project = NULL;
    ABObj               action = NULL;

    if (handler == NULL)
    {
        return 0;
    }
    project = obj_get_project(module);

    /*
     * With "callbacks," the to field is irrelevant.  The target is generally
     * whatever widget calls the callback, so we set the "to" field to NULL,
     * so that this action may be used by multiple widgets.  I.e., if the
     * function type, name and to fields match, an action will be shared.
     */
    action = obj_create(AB_TYPE_ACTION, NULL);
    obj_set_func_type(action, AB_FUNC_USER_DEF);
    obj_set_func_name(action, istr_string(handler));
    obj_set_arg_type(action, AB_ARG_VOID_PTR);
    action->info.action.to = NULL;

    obj_set_from(action, obj);
    obj_set_when(action, when);

    install_action(obj, module, action);
    return 0;
}
Beispiel #3
0
/*
 * Load the actions attributes
 */
int
gilP_load_att_actions(FILE * inFile, ABObj obj, ABObj module)
{
    int                 return_value = 0;
    int                 rc = 0; /* r turn code */
    ABObj               action = NULL;

    if (!abio_get_list_begin(inFile))
        return (abil_print_load_err(ERR_WANT_LIST), -1);

    while (!abio_get_list_end(inFile))
    {
        action = obj_create(AB_TYPE_ACTION, NULL);

        if ((rc = get_action(inFile, obj, module, action)) < 0)
        {
            obj_destroy(action);
            return rc;
        }
        else
        {
	    if (obj_get_when(action) == AB_WHEN_UNDEF)
	    {
		/* unsupported :when value - ignore it and continue */
		obj_destroy(action);
	    }
	    else
	    {
                install_action(obj, module, action);
	    }
        }
    }
    return return_value;
}
Beispiel #4
0
void Service::init_actions()
{
    frame_->evaluateJavaScript("CloudmusService.actions = {};");

    QAction* a;
    a = new QAction(QIcon::fromTheme("media-playback-start"), "play", this);
    install_action(a, "play");

    a = new QAction(QIcon::fromTheme("media-playback-pause"), "pause", this);
    install_action(a, "pause");

    a = new QAction(QIcon::fromTheme("media-playback-stop"), "stop", this);
    install_action(a, "stop");

    a = new QAction(QIcon::fromTheme("media-skip-forward"), "next", this);
    install_action(a, "next");

    a = new QAction(this);
    a->setSeparator(true);
    //     Q_EMIT addAction(a);
}
Beispiel #5
0
int read_message(Action *action, char **set_name, char **key_name) {
    /* protocol:
        first three chars = action (GET, SET, DEL)
        then /
        chars upto / or .: set
        chars upto / or . or \n: key
        set and key must each be a max of 255 chars
        line is thus a max of:
        3 + 1 + 255 + 1 + 255 + 1 = 516 chars
        sticking NULLs into your sets or keys will probably cause bad_ref errors
    */
    char action_str[5];
    static char set_slash_key[512];

    if(fread(action_str, 1, 4, stdin) != 4) {
        if(feof(stdin))
            return ERROR;
        return error("Could not read action from stdin\n");
    }
    action_str[4] = '\0';

    if(install_action(action_str, action) != SUCCESS)
        return respond_bad_act();

    if(!fgets(set_slash_key, 512, stdin))
        return respond_bad_ref();

    /* start both set name and key name at the front, then move key_name
       forward til it finds where it's supposed to start */    
    *set_name = *key_name = set_slash_key;
    while(**key_name) {
        if(**key_name == '/' || **key_name == '.') {
            **key_name = '\0';
            (*key_name)++;
            break;
        }
        (*key_name)++;
    }
    if(!(**key_name))
        return respond_bad_ref();

    sanitize_key(*key_name);

    debug("action: %s\n", action_str);
    debug("set: %s\n", *set_name);
    debug("key: %s\n", *key_name);
    return SUCCESS;
}
Beispiel #6
0
int
main(int argc, char** argv)
{
  cmdline_t options;
  exittype_t exit_type;
  parser_t* ctx = NULL;
  bool_t success = 0;

  // Parse the command line.
  fetchdeps_cmdline_init(&options, argc, argv);
  exit_type = fetchdeps_cmdline_parse(&options);
  if (exit_type == EXIT_FAIL)
    goto failure;
  if (exit_type == EXIT_OK) {
    fetchdeps_cmdline_cleanup(&options);
    exit(0);
  }

  // If no fname was given try to find the default deps file.
  if (!options.fname)
    options.fname = fetchdeps_filesys_default_deps_file();
  if (!options.fname) {
    fetchdeps_errors_set(ERR_NO_DEPS);
    goto failure;
  }

  switch (options.action) {
  case ACTION_HELP:
    success = help_action(&options);
    break;
  case ACTION_INIT:
    success = init_action(&options);
    break;
  case ACTION_GET:
    success = get_action(&options);
    break;
  case ACTION_LIST:
    success = list_action(&options);
    break;
  case ACTION_INSTALL:
    success = install_action(&options);
    break;
  case ACTION_UNINSTALL:
    success = uninstall_action(&options);
    break;
  case ACTION_DELETE:
    success = delete_action(&options);
    break;
  case ACTION_VARS:
    success = vars_action(&options);
    break;
  default:
    success = 0;
    break;
  }

  if (!success)
    goto failure;

  // Clean up.
  fetchdeps_cmdline_cleanup(&options);
  
  return 0;

failure:
  fetchdeps_errors_print(stderr);
  fetchdeps_cmdline_cleanup(&options);
  if (ctx)
    fetchdeps_parser_free(ctx);
  return 1;
}