Beispiel #1
0
int process_info_list(struct section *osconfig, InfoListItem *ci)
{
	int i=0,type,errCount=0;
	InfoItem *pItem;

	while(1) {
		type = ci[i].attr_type;
		if(type == END_LIST) break;	// exit list...
		if(type == GET_VALUE) {			// process list entry for GET_VALUE type
			pItem  = ci[i].item;
			if(pItem != 0) {
				char str_len[81];
				pItem->off = get_property_value(osconfig, ci[i].attr_path, ci[i].attr_name,	ci[i].attr_default);
				// printf("get_property_value( %s, %s)\n",ci[i].attr_path,ci[i].attr_name);
				snprintf(str_len, sizeof(str_len), "%s_len", ci[i].attr_name);
				pItem->len = get_property_value(osconfig, ci[i].attr_path, str_len,	ci[i].attr_default_len);
				// printf("get_property_value( %s, %s)\n",ci[i].attr_path, str_len);
				if(pItem->off == 0) {
					errCount++;
					// printf("Warning: Failed to get value for %s %s\n",ci[i].attr_path, ci[i].attr_name);
				}
			} else {
				printf("Error: Invalid storage for property, check property list definition, item %d\n",i);
			}
		} else {
			printf("Unsupported property accessor type, check propertylist, item %d\n", i);
		}
		i++;
	}
	// printf("Processed %d elements with %d issues\n",i,errCount);
	return errCount;
}
Beispiel #2
0
  /* Calculate storage filename using notification keys. */
  string
  NotifConfig::get_storage_filename() const
  throw (NotifConfig::GeneralConfigError)
  {
    string filename;

    try
    {
      /* Get data path key. */
      filename = get_property_value(DATA_PATH_KEY).to_string() + "/";

      /* Get data root key. */
      filename.append(get_property_value(DATA_ROOT_KEY).to_string() + "/");

      /* Get admin port key. */
      filename.append(get_property_value(ADMIN_PORT_KEY).to_string() + "/");

      /* Get properties filename key. */
      filename.append(get_property_value(PROPS_FILENAME_KEY).to_string());
    }
    catch (PropertyNotFound & e)
    {
      string msg = "cannot resolve storage filename: property '";
      msg.append(e.property_name + "' was not found");
      throw GeneralConfigError(msg);
    }

    return filename;
  }
Beispiel #3
0
TEST_FIXTURE(e2e_raw_client, update_entity_with_patch)
{
	auto model = client.get_model().get();

	//check the old value
	auto query_result = client.get_data_from_server(U("Accounts(101)")).get();
	auto old_entity = std::dynamic_pointer_cast<odata_entity_value>(query_result[0]);
	std::shared_ptr<odata_value> old_value;
	old_entity->get_property_value(U("Country"), old_value);
	auto old_country = std::dynamic_pointer_cast<odata_primitive_value>(old_value);
	VERIFY_ARE_EQUAL(U("US"), old_country->as<::utility::string_t>());

	//update the entity with patch
	old_entity->set_value(U("Country"), U("GB"));

	auto response_code = client.patch_entity(U("Accounts"), old_entity).get();
	VERIFY_ARE_EQUAL(204, response_code);

	//query the updated entity
	auto check_query = client.get_data_from_server(U("Accounts(101)")).get();

	auto new_entity = std::dynamic_pointer_cast<odata_entity_value>(check_query[0]);
	std::shared_ptr<odata_value> property_value;
	VERIFY_IS_TRUE(new_entity->get_property_value(U("Country"), property_value));
	auto primitive_value = std::dynamic_pointer_cast<odata_primitive_value>(property_value);
	::utility::string_t new_country = primitive_value->as<::utility::string_t>();
	VERIFY_ARE_EQUAL(U("GB"), new_country);
}
Beispiel #4
0
void
interp_err(dbref player, dbref program, struct inst *pc,
		   struct inst *arg, int atop, dbref origprog, const char *msg1, const char *msg2)
{
	char buf[BUFFER_LEN];
	char buf2[BUFFER_LEN];
	char tbuf[40];
	int errcount;
	time_t lt;

	err++;

	if (OWNER(origprog) == OWNER(player)) {
		strcpyn(buf, sizeof(buf), "\033[1;31;40mProgram Error.  Your program just got the following error.\033[0m");
	} else {
		snprintf(buf, sizeof(buf), "\033[1;31;40mProgrammer Error.  Please tell %s what you typed, and the following message.\033[0m",
				NAME(OWNER(origprog)));
	}
	notify_nolisten(player, buf, 1);

	snprintf(buf, sizeof(buf), "\033[1m%s(#%d), line %d; %s: %s\033[0m",
			 NAME(program), program, pc ? pc->line : -1, msg1, msg2);
	notify_nolisten(player, buf, 1);

	lt = time(NULL);
#ifndef WIN32
	format_time(tbuf, 32, "%c", localtime(&lt));
#else
	format_time(tbuf, 32, "%c", uw32localtime(&lt));
#endif

	strip_ansi(buf2, buf);
	errcount = get_property_value(origprog, ".debug/errcount");
	errcount++;
	add_property(origprog, ".debug/errcount", NULL, errcount);
	add_property(origprog, ".debug/lasterr", buf2, 0);
	add_property(origprog, ".debug/lastcrash", NULL, (int)lt);
	add_property(origprog, ".debug/lastcrashtime", tbuf, 0);

	if (origprog != program) {
		errcount = get_property_value(program, ".debug/errcount");
		errcount++;
		add_property(program, ".debug/errcount", NULL, errcount);
		add_property(program, ".debug/lasterr", buf2, 0);
		add_property(program, ".debug/lastcrash", NULL, (int)lt);
		add_property(program, ".debug/lastcrashtime", tbuf, 0);
	}
}
int set_property_value(void)
{
        #ifdef CONFIGFILE
        //use it
        #else
        char CONFIGFILE[BUFSIZ];
        strcpy(CONFIGFILE,getenv("HOME"));
        strcat(CONFIGFILE,"/.jasm_config");
        #endif

        FILE * fconfig;
        char get_buffer_from_file[BUFSIZ];
        int index=0;

        if((fconfig=fopen(CONFIGFILE,"r"))==NULL){
          property_values[0]=3;
          property_values[1]=3;
          return 1;
        }

        while(fgets(get_buffer_from_file,BUFSIZ,fconfig) != NULL){
          index++;
          char * get_val;
          get_val = get_property_value(get_buffer_from_file);
          property_values[index] = atoi(get_buffer_from_file);
        }

        fclose(fconfig);

        return 0;
}
Beispiel #6
0
static void
flags_changed (GObject *object, GParamSpec *pspec, gpointer data)
{
  GList *children, *c;
  GValue val = G_VALUE_INIT;
  GFlagsClass *fclass;
  guint flags;
  gint i;
  GtkWidget *viewport;
  GtkWidget *box;

  fclass = G_FLAGS_CLASS (g_type_class_peek (pspec->value_type));

  g_value_init (&val, pspec->value_type);
  get_property_value (object, pspec, &val);
  flags = g_value_get_flags (&val);
  g_value_unset (&val);

  viewport = gtk_bin_get_child (GTK_BIN (data));
  box = gtk_bin_get_child (GTK_BIN (viewport));
  children = gtk_container_get_children (GTK_CONTAINER (box));

  for (c = children; c; c = c->next)
    block_controller (G_OBJECT (c->data));

  for (c = children, i = 0; c; c = c->next, i++)
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (c->data),
                                  (fclass->values[i].value & flags) != 0);

  for (c = children; c; c = c->next)
    unblock_controller (G_OBJECT (c->data));

  g_list_free (children);
}
Beispiel #7
0
/*
 * Inputs:
 *   lpg is the property group to look up
 *   lprop is the property within that group to look up
 * Outputs:
 *   answer is a pointer to the property value
 * Returns:
 *    0 on success
 *   -1 on failure
 * If successful, the property value is retured in *answer.
 * Otherwise, *answer is undefined, and it is up to the caller to decide
 * how to handle that case.
 */
int
lookup_boolean_property(const char *lpg, const char *lprop, boolean_t *answer)
{
	int result = -1;
	scf_resources_t res;
	uint8_t prop_val;

	if (get_property_value(lpg, lprop, &res) != 0) {
		/*
		 * an error was already logged by get_property_value,
		 * and it released any resources assigned to res before
		 * returning.
		 */
		return (result);
	}
	if (scf_value_get_boolean(res.sr_val, &prop_val) != 0) {
		syslog(LOG_ERR, "scf_value_get_boolean() failed: %s",
		    scf_strerror(scf_error()));
		goto cleanup;
	}
	*answer = (boolean_t)prop_val;
	dprintf("lookup_boolean_property(%s, %s) returns %s", lpg, lprop,
	    *answer ? "TRUE" : "FALSE");
	result = 0;
cleanup:
	release_scf_resources(&res);
	return (result);
}
Beispiel #8
0
/*
 * Inputs:
 *   lpg is the property group to look up
 *   lprop is the property within that group to look up
 * Outputs:
 *   answer is a pointer to the property value
 * Returns:
 *    0 on success
 *   -1 on failure
 * If successful, the property value is retured in *answer.
 * Otherwise, *answer is undefined, and it is up to the caller to decide
 * how to handle that case.
 */
int
lookup_count_property(const char *lpg, const char *lprop, uint64_t *answer)
{
	int result = -1;
	scf_resources_t res;

	if (get_property_value(lpg, lprop, &res) != 0) {
		/*
		 * an error was already logged by get_property_value,
		 * and it released any resources assigned to res before
		 * returning.
		 */
		return (result);
	}
	if (scf_value_get_count(res.sr_val, answer) != 0) {
		syslog(LOG_ERR, "scf_value_get_count() failed: %s",
		    scf_strerror(scf_error()));
		goto cleanup;
	}
	dprintf("lookup_count_property(%s, %s) returns %lld", lpg, lprop,
	    *answer);
	result = 0;
cleanup:
	release_scf_resources(&res);
	return (result);
}
Beispiel #9
0
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static void
color_changed (GObject *object, GParamSpec *pspec, gpointer data)
{
  GtkColorChooser *cb = GTK_COLOR_CHOOSER (data);
  GValue val = G_VALUE_INIT;
  GdkColor *color;
  GdkRGBA rgba;

  g_value_init (&val, GDK_TYPE_COLOR);
  get_property_value (object, pspec, &val);
  color = g_value_get_boxed (&val);
  rgba.red = color->red / 65535.0;
  rgba.green = color->green / 65535.0;
  rgba.blue = color->blue / 65535.0;
  rgba.alpha = 1.0;

  if (g_value_get_boxed (&val))
    {
      block_controller (G_OBJECT (cb));
      gtk_color_chooser_set_rgba (cb, &rgba);
      unblock_controller (G_OBJECT (cb));
    }

  g_value_unset (&val);
}
Beispiel #10
0
int
ewmh_get_window_state(RDPCLIENT * This, Window w)
{
	unsigned long nitems_return;
	unsigned char *prop_return;
	uint32 *return_words;
	unsigned long item;
	BOOL maximized_vert, maximized_horz, hidden;

	maximized_vert = maximized_horz = hidden = False;

	if (get_property_value(This, w, "_NET_WM_STATE", 64, &nitems_return, &prop_return, 0) < 0)
		return SEAMLESSRDP_NORMAL;

	return_words = (uint32 *) prop_return;

	for (item = 0; item < nitems_return; item++)
	{
		if (return_words[item] == This->ewmhints.state_maximized_vert_atom)
			maximized_vert = True;
		if (return_words[item] == This->ewmhints.state_maximized_horz_atom)
			maximized_horz = True;
		if (return_words[item] == This->ewmhints.state_hidden_atom)
			hidden = True;
	}

	XFree(prop_return);

	if (maximized_vert && maximized_horz)
		return SEAMLESSRDP_MAXIMIZED;
	else if (hidden)
		return SEAMLESSRDP_MINIMIZED;
	else
		return SEAMLESSRDP_NORMAL;
}
Beispiel #11
0
static void
font_changed (GObject *object, GParamSpec *pspec, gpointer data)
{
  GtkFontChooser *fb = GTK_FONT_CHOOSER (data);
  GValue val = G_VALUE_INIT;
  const PangoFontDescription *font_desc;
  PangoFontDescription *fb_font_desc;

  g_value_init (&val, PANGO_TYPE_FONT_DESCRIPTION);
  get_property_value (object, pspec, &val);

  font_desc = g_value_get_boxed (&val);
  fb_font_desc = gtk_font_chooser_get_font_desc (fb);

  if (font_desc == NULL ||
      (fb_font_desc != NULL &&
       !pango_font_description_equal (fb_font_desc, font_desc)))
    {
      block_controller (G_OBJECT (fb));
      gtk_font_chooser_set_font_desc (fb, font_desc);
      unblock_controller (G_OBJECT (fb));
    }

  g_value_unset (&val);
  pango_font_description_free (fb_font_desc);
}
Beispiel #12
0
RD_BOOL
ewmh_is_window_above(Window w)
{
	unsigned long nitems_return;
	unsigned char *prop_return;
	unsigned long *return_words;
	unsigned long item;
	RD_BOOL above;

	above = False;

	if (get_property_value(w, "_NET_WM_STATE", 64, &nitems_return, &prop_return, 0) < 0)
		return False;

	return_words = (unsigned long *) prop_return;

	for (item = 0; item < nitems_return; item++)
	{
		if (return_words[item] == g_net_wm_state_above_atom)
			above = True;
	}

	XFree(prop_return);

	return above;
}
Beispiel #13
0
static void
unichar_changed (GObject *object, GParamSpec *pspec, gpointer data)
{
  GtkEntry *entry = GTK_ENTRY (data);
  gunichar new_val;
  gunichar old_val = unichar_get_value (entry);
  GValue val = G_VALUE_INIT;
  gchar buf[7];
  gint len;

  g_value_init (&val, pspec->value_type);
  get_property_value (object, pspec, &val);
  new_val = (gunichar)g_value_get_uint (&val);

  if (new_val != old_val)
    {
      if (!new_val)
        len = 0;
      else
        len = g_unichar_to_utf8 (new_val, buf);

      buf[len] = '\0';

      block_controller (G_OBJECT (entry));
      gtk_entry_set_text (entry, buf);
      unblock_controller (G_OBJECT (entry));
    }
}
Beispiel #14
0
int process_properties_list(struct section *osconfig, PropertyListItem *ci)
{
	int i=0,type,errCount=0;
	uint32_t *pAdr;

	while(1) {
		type = ci[i].attr_type;
		if(type == END_LIST) break;	// exit list...
		if(type == GET_VALUE) {			// process list entry for GET_VALUE type
			pAdr  = ci[i].attr_adr;
			if(pAdr != 0) {
				*pAdr = get_property_value(osconfig, ci[i].attr_path, ci[i].attr_name,	ci[i].attr_default);
				// printf("get_property_value( %s, %s)\n",ci[i].attr_path,ci[i].attr_name);
				if(*pAdr == 0) { 
					errCount++;
					// printf("Warning: Failed to get value for %s %s\n",ci[i].attr_path, ci[i].attr_name);
				}
			} else {
				printf("Error: Invalid storage for property, check property list definition, item %d\n",i);
			}
		} else {
			printf("Unsupported property accessor type, check propertylist, item %d\n", i);
		}
		i++;
	}
	// printf("Processed %d elements with %d issues\n",i,errCount);
	return errCount;
}
const char *
safegetprop_strict(dbref player, dbref what, dbref perms, const char *inbuf)
{
    const char *ptr;
    char  bbuf[BUFFER_LEN];
    static char  vl[32];

    if (!inbuf) {
        notify_nolisten(player, "PropFetch: Propname required.", 1);
        return NULL;
    }
    while (*inbuf == PROPDIR_DELIMITER)
        inbuf++;
    if (!*inbuf) {
        notify_nolisten(player, "PropFetch: Propname required.", 1);
        return NULL;
    }
    strcpy(bbuf, inbuf);
    ptr = get_property_class(what, bbuf);
    if (!ptr) {
        int i;

	i = get_property_value(what, bbuf);
	if (!i) {
	    dbref dd;

	    dd = get_property_dbref(what, bbuf);
	    if (dd == NOTHING) {
		*vl = '\0';
		ptr = vl;
		return ptr;
	    } else {
		sprintf(vl, "#%d", dd);
		ptr = vl;
	    }
	} else {
	    sprintf(vl, "%d", i);
	    ptr = vl;
	}
    }

#ifdef COMPRESS
    ptr = uncompress(ptr);
#endif

    if (!Wizperms(perms)) {
        if (Prop_Hidden(bbuf)) {
            notify_nolisten(player, "PropFetch: Permission denied.", 1);
            return NULL;
        }
//        if (Prop_Private(bbuf) && OWNER(perms) != OWNER(what)) {
        if (Prop_Private(bbuf) && !controls_nowizperm(OWNER(perms), what)) {
            notify_nolisten(player, "PropFetch: Permission denied.", 1);
            return NULL;
        }
    }
    return ptr;
}
Beispiel #16
0
void
ewmh_del_icon(Window wnd, uint32 width, uint32 height)
{
	unsigned long nitems, i, icon_size;
	unsigned char *props;
	unsigned long *cur_set, *new_set;

	cur_set = NULL;
	new_set = NULL;

	if (get_property_value(wnd, "_NET_WM_ICON", 10000, &nitems, &props, 1) < 0)
		return;

	cur_set = (unsigned long *) props;

	for (i = 0; i < nitems;)
	{
		if (cur_set[i] == width && cur_set[i + 1] == height)
			break;

		i += 2 + cur_set[i] * cur_set[i + 1];
	}

	if (i == nitems)
		goto out;

	icon_size = width * height + 2;
	new_set = xmalloc((nitems - icon_size) * sizeof(unsigned long));

	if (i != 0)
		memcpy(new_set, cur_set, i * sizeof(unsigned long));
	if (i != nitems - icon_size)
		memcpy(new_set + i, cur_set + i + icon_size,
		       (nitems - (i + icon_size)) * sizeof(unsigned long));

	nitems -= icon_size;

	XChangeProperty(g_display, wnd, g_net_wm_icon_atom, XA_CARDINAL, 32,
			PropModeReplace, (unsigned char *) new_set, nitems);

	xfree(new_set);

      out:
	XFree(cur_set);
}
//TaggedSection function bodies=================================================
TaggedSection::TaggedSection(data_tag pProps, bool mMain) :
    IsMainSection(mMain)
{
    //set the data separator for output filtering
    Separator = "\t";

    //extract section properties
    extract_properties(pProps, Properties);

    if (IsMainSection)
        //set tag type for subsections__________________________________________
    {
        TAG_TYPE  = get_property_value(Properties, SECTION_TYPE);
        OPEN_TAG  = construct_open(TAG_TYPE);
        CLOSE_TAG = construct_close(TAG_TYPE);
    }
    //______________________________________________________________________
}
Beispiel #18
0
static void
double_changed (GObject *object, GParamSpec *pspec, gpointer data)
{
  GtkAdjustment *adj = GTK_ADJUSTMENT (data);
  GValue val = G_VALUE_INIT;

  g_value_init (&val, G_TYPE_DOUBLE);
  get_property_value (object, pspec, &val);

  if (g_value_get_double (&val) != gtk_adjustment_get_value (adj))
    {
      block_controller (G_OBJECT (adj));
      gtk_adjustment_set_value (adj, g_value_get_double (&val));
      unblock_controller (G_OBJECT (adj));
    }

  g_value_unset (&val);
}
Beispiel #19
0
int
ewmh_get_window_desktop(Window wnd)
{
	unsigned long nitems_return;
	unsigned char *prop_return;
	int desktop;

	if (get_property_value(wnd, "_NET_WM_DESKTOP", 1, &nitems_return, &prop_return, 0) < 0)
		return (-1);

	if (nitems_return != 1)
	{
		logger(GUI, Error, "ewmh_get_window_desktop(), _NET_WM_DESKTOP has bad length");
		return (-1);
	}

	desktop = *prop_return;
	XFree(prop_return);
	return desktop;
}
Beispiel #20
0
int
ewmh_get_window_desktop(RDPCLIENT * This, Window wnd)
{
	unsigned long nitems_return;
	unsigned char *prop_return;
	int desktop;

	if (get_property_value(This, wnd, "_NET_WM_DESKTOP", 1, &nitems_return, &prop_return, 0) < 0)
		return (-1);

	if (nitems_return != 1)
	{
		fprintf(stderr, "_NET_WM_DESKTOP has bad length\n");
		return (-1);
	}

	desktop = *prop_return;
	XFree(prop_return);
	return desktop;
}
Beispiel #21
0
int
get_current_workarea(RDPCLIENT * This, uint32 * x, uint32 * y, uint32 * width, uint32 * height)
{
	int current_desktop;
	unsigned long nitems_return;
	unsigned char *prop_return;
	uint32 *return_words;
	const uint32 net_workarea_x_offset = 0;
	const uint32 net_workarea_y_offset = 1;
	const uint32 net_workarea_width_offset = 2;
	const uint32 net_workarea_height_offset = 3;
	const uint32 max_prop_length = 32 * 4;	/* Max 32 desktops */

	if (get_property_value
	    (This, DefaultRootWindow(This->display), "_NET_WORKAREA", max_prop_length, &nitems_return,
	     &prop_return, 0) < 0)
		return (-1);

	if (nitems_return % 4)
	{
		fprintf(stderr, "_NET_WORKAREA has odd length\n");
		return (-1);
	}

	current_desktop = get_current_desktop(This);

	if (current_desktop < 0)
		return -1;

	return_words = (uint32 *) prop_return;

	*x = return_words[current_desktop * 4 + net_workarea_x_offset];
	*y = return_words[current_desktop * 4 + net_workarea_y_offset];
	*width = return_words[current_desktop * 4 + net_workarea_width_offset];
	*height = return_words[current_desktop * 4 + net_workarea_height_offset];

	XFree(prop_return);

	return (0);

}
Beispiel #22
0
int
get_current_workarea(uint32 * x, uint32 * y, uint32 * width, uint32 * height)
{
	int current_desktop;
	unsigned long nitems_return;
	unsigned char *prop_return;
	long *return_words;
	const uint32 net_workarea_x_offset = 0;
	const uint32 net_workarea_y_offset = 1;
	const uint32 net_workarea_width_offset = 2;
	const uint32 net_workarea_height_offset = 3;
	const uint32 max_prop_length = 32 * 4;	/* Max 32 desktops */

	if (get_property_value
	    (DefaultRootWindow(g_display), "_NET_WORKAREA", max_prop_length, &nitems_return,
	     &prop_return, 0) < 0)
		return (-1);

	if (nitems_return % 4)
	{
		logger(GUI, Error, "get_current_workarea(),_NET_WORKAREA has bad length");
		return (-1);
	}

	current_desktop = get_current_desktop();

	if (current_desktop < 0)
		return -1;

	return_words = (long *) prop_return;

	*x = return_words[current_desktop * 4 + net_workarea_x_offset];
	*y = return_words[current_desktop * 4 + net_workarea_y_offset];
	*width = return_words[current_desktop * 4 + net_workarea_width_offset];
	*height = return_words[current_desktop * 4 + net_workarea_height_offset];

	XFree(prop_return);

	return (0);

}
Beispiel #23
0
/* 
   Get current desktop number
   Returns -1 on error
*/
static int
get_current_desktop(void)
{
	unsigned long nitems_return;
	uint32 *prop_return;
	int current_desktop;

	if (get_property_value("_NET_CURRENT_DESKTOP", 1, &nitems_return,
			       (unsigned char **) &prop_return) < 0)
		return (-1);

	if (nitems_return != 1)
	{
		fprintf(stderr, "_NET_CURRENT_DESKTOP has bad length\n");
		return (-1);
	}

	current_desktop = *prop_return;
	XFree(prop_return);
	return current_desktop;
}
Beispiel #24
0
static void
enum_changed (GObject *object, GParamSpec *pspec, gpointer data)
{
  GtkWidget *viewport;
  GtkWidget *box;
  GList *children, *c;
  GValue val = G_VALUE_INIT;
  GEnumClass *eclass;
  gint i, j;

  eclass = G_ENUM_CLASS (g_type_class_peek (pspec->value_type));

  g_value_init (&val, pspec->value_type);
  get_property_value (object, pspec, &val);

  i = 0;
  while (i < eclass->n_values)
    {
      if (eclass->values[i].value == g_value_get_enum (&val))
        break;
      ++i;
    }
  g_value_unset (&val);

  viewport = gtk_bin_get_child (GTK_BIN (data));
  box = gtk_bin_get_child (GTK_BIN (viewport));
  children = gtk_container_get_children (GTK_CONTAINER (box));

  for (c = children; c; c = c->next)
    block_controller (G_OBJECT (c->data));

  for (c = children, j = 0; c; c = c->next, j++)
    {
      if (j == i)
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (c->data), TRUE);
    }

  for (c = children; c; c = c->next)
    unblock_controller (G_OBJECT (c->data));
}
Beispiel #25
0
/* 
   Get current desktop number
   Returns -1 on error
*/
static int
get_current_desktop(void)
{
	unsigned long nitems_return;
	unsigned char *prop_return;
	int current_desktop;

	if (get_property_value
	    (DefaultRootWindow(g_display), "_NET_CURRENT_DESKTOP", 1, &nitems_return,
	     &prop_return, 0) < 0)
		return (-1);

	if (nitems_return != 1)
	{
		logger(GUI, Error, "get_current_desktop(), _NET_CURRENT_DESKTOP has bad length");
		return (-1);
	}

	current_desktop = *prop_return;
	XFree(prop_return);
	return current_desktop;
}
Beispiel #26
0
/*
   Get current desktop number
   Returns -1 on error
*/
static int
get_current_desktop(RDPCLIENT * This)
{
	unsigned long nitems_return;
	unsigned char *prop_return;
	int current_desktop;

	if (get_property_value
	    (This, DefaultRootWindow(This->display), "_NET_CURRENT_DESKTOP", 1, &nitems_return,
	     &prop_return, 0) < 0)
		return (-1);

	if (nitems_return != 1)
	{
		fprintf(stderr, "_NET_CURRENT_DESKTOP has bad length\n");
		return (-1);
	}

	current_desktop = *prop_return;
	XFree(prop_return);
	return current_desktop;
}
Beispiel #27
0
void
prim_getpropval(PRIM_PROTOTYPE)
{
	CHECKOP(2);
	oper1 = POP();
	oper2 = POP();
	if (oper1->type != PROG_STRING)
		abort_interp("Non-string argument (2)");
	if (!oper1->data.string)
		abort_interp("Empty string argument (2)");
	if (!valid_object(oper2))
		abort_interp("Non-object argument (1)");
	CHECKREMOTE(oper2->data.objref);

	if (!prop_read_perms(ProgUID, oper2->data.objref, oper1->data.string->data, mlev))
		abort_interp("Permission denied.");

	{
		char type[BUFFER_LEN];
		int len = oper1->data.string->length;

		strcpyn(type, sizeof(type), oper1->data.string->data);
		while (len-- > 0 && type[len] == PROPDIR_DELIMITER) {
			type[len] = '\0';
		}
		result = get_property_value(oper2->data.objref, type);

#ifdef LOG_PROPS
		log2file("props.log", "#%d (%d) GETPROPVAL: o=%d n=\"%s\" v=%d",
				 program, pc->line, oper2->data.objref, type, result);
#endif

		/* if (Typeof(oper2->data.objref) != TYPE_PLAYER)
		   ts_lastuseobject(oper2->data.objref); */
	}
	CLEAR(oper1);
	CLEAR(oper2);
	PushInt(result);
}
Beispiel #28
0
static void
rgba_changed (GObject *object, GParamSpec *pspec, gpointer data)
{
  GtkColorChooser *cb = GTK_COLOR_CHOOSER (data);
  GValue val = G_VALUE_INIT;
  GdkRGBA *color;
  GdkRGBA cb_color;

  g_value_init (&val, GDK_TYPE_RGBA);
  get_property_value (object, pspec, &val);

  color = g_value_get_boxed (&val);
  gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (cb), &cb_color);

  if (color != NULL && !gdk_rgba_equal (color, &cb_color))
    {
      block_controller (G_OBJECT (cb));
      gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (cb), color);
      unblock_controller (G_OBJECT (cb));
    }
 g_value_unset (&val);
}
Beispiel #29
0
void 
check_properties(const char *dir, dbref obj)
{
    int     val;
    char   *buf, *prop;
    PropPtr pptr;
    PropPtr pref;
    char    name[BUFFER_LEN];

    pref = first_prop(obj, dir, &pptr, name);
    while (pref > 0) {
	buf = (char *) malloc(strlen(dir) + strlen(name) + 2);
	(void) strcat(strcpy(buf, dir), name);
	if (prop = (char *) get_property_class(obj, buf))
	    printf("%s%c%s\n", buf + 1, PROP_DELIMITER, uncompress(prop));
	else if (val = get_property_value(obj, buf))
	    printf("%s%c^%d\n", buf + 1, PROP_DELIMITER, val);
	if (is_propdir(obj, buf))
	    check_properties((char *) strcat(buf, "/"), obj);
	free(buf);
	pref = next_prop(pptr, pref, name);
    }
}
Beispiel #30
0
static void
bool_changed (GObject *object, GParamSpec *pspec, gpointer data)
{
  GtkToggleButton *tb = GTK_TOGGLE_BUTTON (data);
  GtkWidget *child;
  GValue val = G_VALUE_INIT;

  g_value_init (&val, G_TYPE_BOOLEAN);
  get_property_value (object, pspec, &val);

  if (g_value_get_boolean (&val) != gtk_toggle_button_get_active (tb))
    {
      block_controller (G_OBJECT (tb));
      gtk_toggle_button_set_active (tb, g_value_get_boolean (&val));
      unblock_controller (G_OBJECT (tb));
    }

  child = gtk_bin_get_child (GTK_BIN (tb));
  gtk_label_set_text (GTK_LABEL (child),
                      g_value_get_boolean (&val) ? "TRUE" : "FALSE");

  g_value_unset (&val);
}