static void
panel_menu_button_gconf_notify (GConfClient     *client,
				guint            cnxn_id,
				GConfEntry      *entry,
				PanelMenuButton *button)
{
	GConfValue *value;
	const char *key;

	key = panel_gconf_basename (gconf_entry_get_key (entry));

	value = entry->value;

	if (!strcmp (key, "menu_path")) {
		if (value && value->type == GCONF_VALUE_STRING)
			panel_menu_button_set_menu_path (button,
							 gconf_value_get_string (value));
	} else if (!strcmp (key, "custom_icon")) {
		if (value && value->type == GCONF_VALUE_STRING)
			panel_menu_button_set_custom_icon (button,
							   gconf_value_get_string (value));
	} else if (!strcmp (key, "tooltip")) {
		if (value && value->type == GCONF_VALUE_STRING)
			panel_menu_button_set_tooltip (button,
						       gconf_value_get_string (value));
	} else if (!strcmp (key, "use_menu_path")) {
		if (value && value->type == GCONF_VALUE_BOOL)
			panel_menu_button_set_use_menu_path (button,
							     gconf_value_get_bool (value));
	} else if (!strcmp (key, "use_custom_icon")) {
		if (value && value->type == GCONF_VALUE_BOOL)
			panel_menu_button_set_use_custom_icon (button,
							       gconf_value_get_bool (value));
	}
}
示例#2
0
static void
em_junk_sa_setting_notify(GConfClient *gconf, guint cnxn_id, GConfEntry *entry, void *data)
{
	GConfValue *value;
	char *tkey;

	g_return_if_fail (gconf_entry_get_key (entry) != NULL);

	if (!(value = gconf_entry_get_value (entry)))
		return;

	tkey = strrchr(entry->key, '/');
	g_return_if_fail (tkey != NULL);

	if (!strcmp(tkey, "local_only"))
		em_junk_sa_local_only = gconf_value_get_bool(value);
	else if (!strcmp(tkey, "use_daemon"))
		em_junk_sa_use_daemon = gconf_value_get_bool(value);
	else if (!strcmp(tkey, "socket_path")) {
		pthread_mutex_lock (&em_junk_sa_preferred_socket_path_lock);
		g_free (em_junk_sa_preferred_socket_path);
		em_junk_sa_preferred_socket_path = g_strdup (gconf_value_get_string(value));
		pthread_mutex_unlock (&em_junk_sa_preferred_socket_path_lock);
	}
}
示例#3
0
文件: powersavemode.c 项目: guhl/mce
/**
 * GConf callback for power saving related settings
 *
 * @param gcc Unused
 * @param id Connection ID from gconf_client_notify_add()
 * @param entry The modified GConf entry
 * @param data Unused
 */
static void psm_gconf_cb(GConfClient *const gcc, const guint id,
			 GConfEntry *const entry, gpointer const data)
{
	const GConfValue *gcv = gconf_entry_get_value(entry);

	(void)gcc;
	(void)data;

	/* Key is unset */
	if (gcv == NULL) {
		mce_log(LL_DEBUG,
			"GConf Key `%s' has been unset",
			gconf_entry_get_key(entry));
		goto EXIT;
	}

	if (id == psm_gconf_cb_id) {
		power_saving_mode = gconf_value_get_bool(gcv);
		update_power_saving_mode();
	} else if (id == force_psm_gconf_cb_id) {
		force_psm = gconf_value_get_bool(gcv);
		update_power_saving_mode();
	} else if (id == psm_threshold_gconf_cb_id) {
		psm_threshold = gconf_value_get_int(gcv);
		update_power_saving_mode();
	} else {
		mce_log(LL_WARN,
			"Spurious GConf value received; confused!");
	}

EXIT:
	return;
}
示例#4
0
static gboolean
simple_value_is_equal (const GConfValue *a,
                       const GConfValue *b)
{
    g_assert (a != NULL);
    g_assert (b != NULL);

    switch (a->type) {
    case GCONF_VALUE_STRING:
        return eel_str_is_equal (gconf_value_get_string (a),
                                 gconf_value_get_string (b));

    case GCONF_VALUE_INT:
        return gconf_value_get_int (a) ==
               gconf_value_get_int (b);

    case GCONF_VALUE_FLOAT:
        return gconf_value_get_float (a) ==
               gconf_value_get_float (b);

    case GCONF_VALUE_BOOL:
        return gconf_value_get_bool (a) ==
               gconf_value_get_bool (b);
    default:
        g_assert_not_reached ();
    }

    return FALSE;
}
示例#5
0
static void
gconf_value_changed (GConfClient *client,
		     const gchar *key,
		     GConfValue  *value,
		     gpointer     data)
{
    MTClosure *mt = data;

    if (g_str_equal (key, OPT_THRESHOLD) && value->type == GCONF_VALUE_INT)
	mt->threshold = gconf_value_get_int (value);
    else if (g_str_equal (key, OPT_DELAY) && value->type == GCONF_VALUE_BOOL)
	mt->delay_enabled = gconf_value_get_bool (value);
    else if (g_str_equal (key, OPT_DELAY_T) && value->type == GCONF_VALUE_FLOAT)
	mt_timer_set_target (mt->delay_timer, gconf_value_get_float (value));
    else if (g_str_equal (key, OPT_DWELL) && value->type == GCONF_VALUE_BOOL) {
	mt->dwell_enabled = gconf_value_get_bool (value);
	mt_ctw_update_sensitivity (mt);
	mt_ctw_update_visibility (mt);
    }
    else if (g_str_equal (key, OPT_DWELL_T) && value->type == GCONF_VALUE_FLOAT)
	mt_timer_set_target (mt->dwell_timer, gconf_value_get_float (value));
    else if (g_str_equal (key, OPT_CTW) && value->type == GCONF_VALUE_BOOL) {
	mt->dwell_show_ctw = gconf_value_get_bool (value);
	mt_ctw_update_visibility (mt);
    }
    else if (g_str_equal (key, OPT_MODE) && value->type == GCONF_VALUE_INT) {
	mt->dwell_mode = gconf_value_get_int (value);
	mt_ctw_update_sensitivity (mt);
    }
    else if (g_str_equal (key, OPT_STYLE) && value->type == GCONF_VALUE_INT) {
	mt->style = gconf_value_get_int (value);
	mt_ctw_update_style (mt, mt->style);
    }
    else if (g_str_equal (key, OPT_G_SINGLE) && value->type == GCONF_VALUE_INT)
	mt->dwell_dirs[DWELL_CLICK_TYPE_SINGLE] = gconf_value_get_int (value);
    else if (g_str_equal (key, OPT_G_DOUBLE) && value->type == GCONF_VALUE_INT)
	mt->dwell_dirs[DWELL_CLICK_TYPE_DOUBLE] = gconf_value_get_int (value);
    else if (g_str_equal (key, OPT_G_DRAG) && value->type == GCONF_VALUE_INT)
	mt->dwell_dirs[DWELL_CLICK_TYPE_DRAG] = gconf_value_get_int (value);
    else if (g_str_equal (key, OPT_G_RIGHT) && value->type == GCONF_VALUE_INT)
	mt->dwell_dirs[DWELL_CLICK_TYPE_RIGHT] = gconf_value_get_int (value);
    else if (g_str_equal (key, OPT_ANIMATE) && value->type == GCONF_VALUE_BOOL) {
	MtCursorManager *manager;

	manager = mt_cursor_manager_get_default ();
	mt->animate_cursor = gconf_value_get_bool (value);

	if (mt->animate_cursor)
	    mt->cursor = mt_cursor_manager_current_cursor (manager);
	else
	    mt_cursor_manager_restore_all (manager);
    }
}
示例#6
0
文件: main.c 项目: hsgg/quark
static void
config_changed (GConfClient *gconf,
                guint cnxn_id,
                GConfEntry *entry,
                gpointer data)
{
    if (!strcmp (entry->key, LOOP_PLAYLIST)) {
        main_set_loop_at_end (gconf_value_get_bool (entry->value));
    } else if (!strcmp (entry->key, RANDOM_ORDER)) {
        main_set_random_order (gconf_value_get_bool (entry->value));
    }
}
static WnckTasklistGroupingType
get_grouping_type (GConfValue *value)
{
	WnckTasklistGroupingType type = -1;
	const char *str;

	g_assert (value != NULL);

	/* Backwards compat for old type: */
	if (value->type == GCONF_VALUE_BOOL) {
		type = (gconf_value_get_bool (value)) ? WNCK_TASKLIST_AUTO_GROUP:WNCK_TASKLIST_NEVER_GROUP;

	} else if (value->type == GCONF_VALUE_STRING) {
		str = gconf_value_get_string (value);
		if (g_ascii_strcasecmp (str, "never") == 0) {
			type = WNCK_TASKLIST_NEVER_GROUP;
		} else if (g_ascii_strcasecmp (str, "auto") == 0) {
			type = WNCK_TASKLIST_AUTO_GROUP;
		} else if (g_ascii_strcasecmp (str, "always") == 0) {
			type = WNCK_TASKLIST_ALWAYS_GROUP;
		}
	}

	return type;
}
示例#8
0
static gboolean
gconf_client_get_bool_with_default (GConfClient* client, const gchar* key,
                                    gboolean def, GError** err)
{
  GError* error = NULL;
  GConfValue* val;

  g_return_val_if_fail (err == NULL || *err == NULL, def);

  val = gconf_client_get (client, key, &error);

  if (val != NULL)
    {
      gboolean retval = def;

      g_return_val_if_fail (error == NULL, retval);
      
      if (check_type (key, val, GCONF_VALUE_BOOL, &error))
        retval = gconf_value_get_bool (val);
      else
        handle_error (client, error, err);

      gconf_value_free (val);

      return retval;
    }
  else
    {
      if (error != NULL)
        handle_error (client, error, err);
      return def;
    }
}
示例#9
0
文件: confsection.C 项目: ggcov/ggcov
gboolean
confsection_t::get_bool(const char *name, gboolean deflt)
{
    gboolean val;
    string_var key = make_key(name);

#if HAVE_LIBGCONF
    GError *e = 0;
    GConfValue *gcv = gconf_client_get(gconf_client_get_default(), key, &e);
    handle_error(secname_, e);
    if (gcv == 0)
    {
	val = deflt;
    }
    else
    {
	val = gconf_value_get_bool(gcv);
	gconf_value_free(gcv);
    }
#else
    gboolean defaulted = FALSE;
    val = gnome_config_get_bool_with_default(key.data(), &defaulted);
    if (defaulted)
	val = deflt;
#endif
    return val;
}
示例#10
0
static void
panel_drawer_use_custom_icon_changed (GConfClient *client,
				      guint        cnxn_id,
				      GConfEntry  *entry,
				      Drawer      *drawer)
{
	gboolean  use_custom_icon;
	char     *custom_icon = NULL;

	if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
		return;

	use_custom_icon = gconf_value_get_bool (entry->value);

	if (use_custom_icon) {
		const char *key;

		key = panel_gconf_full_key (PANEL_GCONF_OBJECTS, drawer->info->id, "custom_icon");
		custom_icon = gconf_client_get_string (client, key, NULL);
	}

	button_widget_set_icon_name (BUTTON_WIDGET (drawer->button), custom_icon);

	g_free (custom_icon);
}
static void
all_workspaces_changed (GConfClient *client,
			guint        cnxn_id,
			GConfEntry  *entry,
			PagerData   *pager)
{
	gboolean value = TRUE; /* Default value */
	
	if (entry->value != NULL &&
	    entry->value->type == GCONF_VALUE_BOOL) {
		value = gconf_value_get_bool (entry->value);
	}

	pager->display_all = value;
	pager_update (pager);

	if (pager->all_workspaces_radio){
		if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pager->all_workspaces_radio)) != value) {
			if (value) {
				gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pager->all_workspaces_radio), TRUE);
			} else {
				gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pager->current_only_radio), TRUE);
			}
		}
		if ( ! g_object_get_data (G_OBJECT (pager->num_rows_spin), NEVER_SENSITIVE))
			gtk_widget_set_sensitive (pager->num_rows_spin, value);
	}
}
示例#12
0
文件: mce-dbus.c 项目: Vesuri/mce
/** Helper for appending gconf bool list to dbus message
 *
 * @param conf GConfValue of bool list type
 * @param pcount number of items in the returned array is stored here
 * @return array of booleans that can be easily added to DBusMessage
 */
static dbus_bool_t *bool_array_from_gconf_value(GConfValue *conf, int *pcount)
{
	dbus_bool_t *array = 0;
	int          count = 0;

	GSList *list, *item;

	if( conf->type != GCONF_VALUE_LIST )
		goto EXIT;

	if( gconf_value_get_list_type(conf) != GCONF_VALUE_BOOL )
		goto EXIT;

	list = gconf_value_get_list(conf);

	for( item = list; item; item = item->next )
		++count;

	array = g_malloc_n(count, sizeof *array);
	count = 0;

	for( item = list; item; item = item->next )
		array[count++] = gconf_value_get_bool(item->data);

EXIT:
	return *pcount = count, array;
}
示例#13
0
/**
 * GConf callback for ALS settings
 *
 * @param gcc Unused
 * @param id Connection ID from gconf_client_notify_add()
 * @param entry The modified GConf entry
 * @param data Unused
 */
static void use_als_gconf_cb(GConfClient *const gcc, const guint id,
			 GConfEntry *const entry, gpointer const data)
{
	const GConfValue *gcv = gconf_entry_get_value(entry);

	(void)gcc;
	(void)data;

	/* Key is unset */
	if (gcv == NULL) {
		mce_log(LL_DEBUG,
			"GConf Key `%s' has been unset",
			gconf_entry_get_key(entry));
		goto EXIT;
	}

	if (id == use_als_gconf_id) {
		use_als_flag = gconf_value_get_bool(gcv);
		rethink_als_status();
	} else {
		mce_log(LL_WARN,
			"Spurious GConf value received; confused!");
	}

EXIT:
	return;
}
static void
display_workspace_names_changed (GConfClient *client,
				 guint        cnxn_id,
				 GConfEntry  *entry,
				 PagerData   *pager)
{
	gboolean value = FALSE; /* Default value */
	
	if (entry->value != NULL &&
	    entry->value->type == GCONF_VALUE_BOOL) {
		value = gconf_value_get_bool (entry->value);
	}

	if (value) {
		pager->display_mode = WNCK_PAGER_DISPLAY_NAME;
	} else {
		pager->display_mode = WNCK_PAGER_DISPLAY_CONTENT;
	}
	pager_update (pager);
	
	if (pager->display_workspaces_toggle &&
	    gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pager->display_workspaces_toggle)) != value) {
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pager->display_workspaces_toggle),
					      value);
	}
}
示例#15
0
static GValue *gconf_value_to_g_value(GConfValue * confValue, GValue * value)
{
    GType gType = G_VALUE_TYPE(value);

    switch (confValue->type) {
    case GCONF_VALUE_BOOL:
        if (gType != G_TYPE_BOOLEAN) {
            return NULL;
        }
        g_value_set_boolean(value, gconf_value_get_bool(confValue));
        break;
    case GCONF_VALUE_INT:
        if (gType != G_TYPE_INT && gType != G_TYPE_UINT) {
            return NULL;
        } else if (gType == G_TYPE_INT) {
            g_value_set_int(value, gconf_value_get_int(confValue));
        } else {
            g_value_set_uint(value, gconf_value_get_int(confValue));
        }
        break;
    case GCONF_VALUE_STRING:
        if (gType != G_TYPE_STRING) {
            return NULL;
        }
        g_value_set_string(value, gconf_value_get_string(confValue));
        break;
    default:
        return NULL;
    }
    return value;
}
示例#16
0
/** GConf callback for powerkey related settings
 *
 * @param gcc    (not used)
 * @param id     Connection ID from gconf_client_notify_add()
 * @param entry  The modified GConf entry
 * @param data   (not used)
 */
static void
fba_gconf_cb(GConfClient *const gcc, const guint id,
			    GConfEntry *const entry, gpointer const data)
{
	(void)gcc;
	(void)data;
	(void)id;

	const GConfValue *gcv = gconf_entry_get_value(entry);

	if( !gcv ) {
		mce_log(LL_DEBUG, "GConf Key `%s' has been unset",
			gconf_entry_get_key(entry));
		goto EXIT;
	}

	if( id == use_als_gconf_id ) {
		gboolean old = use_als_flag;
		use_als_flag = gconf_value_get_bool(gcv);

		if( use_als_flag != old ) {
			rethink_als_status();
		}
	}
	else if( id == als_input_filter_gconf_id ) {
		const char *val = gconf_value_get_string(gcv);

		if( !eq(als_input_filter, val) ) {
			g_free(als_input_filter);
			als_input_filter = g_strdup(val);
			inputflt_select(als_input_filter);
		}
	}
	else if( id == als_sample_time_gconf_id ) {
		gint old = als_sample_time;
		als_sample_time = gconf_value_get_int(gcv);

		if( als_sample_time != old ) {
			mce_log(LL_NOTICE, "als_sample_time: %d -> %d",
				old, als_sample_time);
			// NB: takes effect on the next sample timer restart
		}
	}
	else if (id == color_profile_gconf_id) {
		const gchar *val = gconf_value_get_string(gcv);

		if( !eq(color_profile_name, val) ) {
			if( !set_color_profile(val) )
				save_color_profile(color_profile_name);
		}
	}
	else {
		mce_log(LL_WARN, "Spurious GConf value received; confused!");
	}

EXIT:

	return;
}
static void
toolbar_detachable_cb (GConfClient    *client,
		       guint           id,
		       GConfEntry     *entry,
		       AppearanceData *data)
{
  show_handlebar (data, gconf_value_get_bool (entry->value));
}
示例#18
0
文件: proximity.c 项目: mlehtima/mce
/** GConf callback for use proximity sensor setting
 *
 * @param gcc   (not used)
 * @param id    Connection ID from gconf_client_notify_add()
 * @param entry The modified GConf entry
 * @param data  (not used)
 */
static void use_ps_conf_cb(GConfClient *const gcc, const guint id,
                           GConfEntry *const entry, gpointer const data)
{
    (void)gcc;
    (void)data;

    const GConfValue *gcv;

    if( !(gcv = gconf_entry_get_value(entry)) ) {
        mce_log(LL_WARN, "GConf value removed; confused!");
        goto EXIT;
    }

    if( id == use_ps_conf_id ) {
        gboolean old = use_ps_conf_value;
        use_ps_conf_value = gconf_value_get_bool(gcv);

        if( use_ps_conf_value == old )
            goto EXIT;

    }
    else if( id == ps_acts_as_lid_conf_id ) {
        gboolean old = ps_acts_as_lid;
        ps_acts_as_lid = gconf_value_get_bool(gcv);

        if( ps_acts_as_lid == old )
            goto EXIT;

        if( ps_acts_as_lid ) {
            // ps is lid now -> set ps to open state
            report_proximity(COVER_OPEN);
        }
        else {
            // ps is ps again -> invalidate lid state
            report_lid_input(COVER_UNDEF);
        }
    }
    else {
        mce_log(LL_WARN, "Spurious GConf value received; confused!");
        goto EXIT;
    }

    update_proximity_monitor();
EXIT:
    return;
}
static void
menus_have_icons_cb (GConfPropertyEditor *peditor,
		     gchar               *key,
		     GConfValue          *value,
		     AppearanceData      *data)
{
  set_have_icons (data, gconf_value_get_bool (value));
}
示例#20
0
static void
rb_plugins_engine_plugin_visible_cb (GConfClient *client,
				     guint cnxn_id,
				     GConfEntry *entry,
				     RBPluginInfo *info)
{
	info->visible = !gconf_value_get_bool (entry->value);
}
示例#21
0
static void
use_default_clipboard_key_changed_callback(GConfClient *client,
		    guint        cnxn_id,
		    GConfEntry  *entry,
		    gpointer     user_data)
{
	GConfValue *value = gconf_entry_get_value(entry);
	gtk_toggle_button_set_active((GtkToggleButton*)defaultCheck, gconf_value_get_bool(value));
}
示例#22
0
gpointer
config_read (const char *key)
{
  /* Create the connection to GConf database if it doesn't exist yet. */
  config_open_close (CONFIG_OP_OPEN);

  if (key)
    {
      GError *read_error = NULL;
      GConfValue *value = gconf_client_get (conf_client, key, &read_error);

      if (read_error)
	{
	  error (0, 0, _("Could not read GConf key: %s"), read_error->message);
	  g_clear_error (&read_error);
	  return NULL;
	}
      else
	{
	  if (value)
	    {
	      switch (value->type)
		{
		case GCONF_VALUE_STRING:
		  return (gpointer) gconf_value_get_string (value);
		  break;
		case GCONF_VALUE_BOOL:
		  return (gpointer) gconf_value_get_bool (value);
		  break;
		case GCONF_VALUE_INT:
		  return (gpointer) gconf_value_get_int (value);
		  break;
		  /* gdouble cannot be casted to gpointer somehow...

		     case GCONF_VALUE_FLOAT:
		     data = (gpointer) gconf_value_get_float (value);
		     break;*/
		case GCONF_VALUE_FLOAT:
		case GCONF_VALUE_SCHEMA:
		case GCONF_VALUE_LIST:
		case GCONF_VALUE_PAIR: 
		case GCONF_VALUE_INVALID:
		  error (0, 0, _("Error reading GConf database: Key type is not supported"));
		  break;
		}
	    }
	  else
	    {
	      error (0, 0, _("Key could not be read: key unset or no default exists"));

	    }
	}
    }
    return NULL;  
}
static GConfValue *
corner_flip_to_widget (GConfPropertyEditor *peditor, GConfValue *value)
{
	GConfValue *new_value;

	new_value = gconf_value_new (GCONF_VALUE_INT);
	gconf_value_set_int (new_value, (value 
				&& (value->type == GCONF_VALUE_BOOL)
				&& gconf_value_get_bool (value)) ? 1 : 0);
	return new_value;
}
示例#24
0
static void
auto_complete_history_changed (GConfClient  *client,
			       guint         cnxn_id,
			       GConfEntry   *entry,
			       MCData       *mc)
{
    if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
	return;

    mc->preferences.auto_complete_history = gconf_value_get_bool (entry->value);
}
示例#25
0
static void
rb_plugins_engine_plugin_active_cb (GConfClient *client,
				    guint cnxn_id,
				    GConfEntry *entry,
				    RBPluginInfo *info)
{
	if (gconf_value_get_bool (entry->value)) {
		rb_plugins_engine_activate_plugin (info);
	} else {
		rb_plugins_engine_deactivate_plugin (info);
	}
}
示例#26
0
文件: linux.c 项目: fjrti/subsurface
int subsurface_get_conf_bool(char *name)
{
	GConfValue *val;
	gboolean ret;

	val = gconf_client_get(gconf, gconf_name(name), NULL);
	if (!val)
		return -1;
	ret = gconf_value_get_bool(val);
	gconf_value_free(val);
	return ret;
}
static GConfValue *
left_handed_from_gconf (GConfPropertyEditor *peditor,
			const GConfValue *value)
{
	GConfValue *new_value;

	new_value = gconf_value_new (GCONF_VALUE_INT);

	gconf_value_set_int (new_value, gconf_value_get_bool (value));

	return new_value;
}
示例#28
0
/* GConf notification handlers
 */
static void
show_default_theme_changed (GConfClient  *client,
			    guint         cnxn_id,
			    GConfEntry   *entry,
			    MCData       *mc)
{
    if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
	return;

    mc->preferences.show_default_theme = gconf_value_get_bool (entry->value);

    mc_applet_draw (mc); /* FIXME: we shouldn't have to redraw the whole applet */
}
示例#29
0
gboolean
gm_conf_entry_get_bool (GmConfEntry *entry)
{
    GConfEntry *gconf_entry = NULL;

    g_return_val_if_fail (entry != NULL, FALSE);

    gconf_entry = (GConfEntry *)entry;
    if (gconf_entry->value)
        return gconf_value_get_bool (gconf_entry->value);

    return FALSE;
}
static void
disable_lock_screen_notify (GConfClient   *client,
                            guint          cnxn_id,
                            GConfEntry    *entry,
                            PanelLockdown *lockdown)
{
        if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
                return;

        lockdown->disable_lock_screen = gconf_value_get_bool (entry->value);

        panel_lockdown_invoke_closures (lockdown);
}