Exemplo n.º 1
0
void
panel_action_button_load_from_mateconf (PanelWidget *panel,
				     gboolean     locked,
				     int          position,
				     gboolean     exactpos,
				     const char  *id)
{
	int          type;
	const char  *key;
	char        *action_type;

	key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "action_type");
	action_type = mateconf_client_get_string (panel_mateconf_get_client (), key, NULL);

	if (!mateconf_string_to_enum (panel_action_type_map, action_type, &type)) {
		g_warning ("Unkown action type '%s' from %s", action_type, key);
		g_free (action_type);
		return;
	}

	g_free (action_type);

	panel_action_button_load (type, panel, locked,
				  position, exactpos, id);
}
MateComponentUIToolbarStyle
matecomponent_ui_preferences_get_toolbar_style (void)
{
	MateComponentUIToolbarStyle style;
	char *str;

	if (!client)
		client = mateconf_client_get_default ();

	style = GTK_TOOLBAR_BOTH;

	str = mateconf_client_get_string (client,
				       "/desktop/mate/interface/toolbar_style",
				       NULL);
	
	if (str != NULL) {
		gint intstyle;

		mateconf_string_to_enum (toolbar_styles,
				      str, &intstyle);

		g_free (str);
		style = intstyle;
	}

	return style;
}
void
panel_action_button_load_from_mateconf (PanelWidget *panel,
				     gboolean     locked,
				     int          position,
				     gboolean     exactpos,
				     const char  *id)
{
	int          type;
	const char  *key;
	char        *action_type;

	key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "action_type");
	action_type = mateconf_client_get_string (panel_mateconf_get_client (), key, NULL);

	if (!mateconf_string_to_enum (panel_action_type_map, action_type, &type)) {
		g_warning ("Unkown action type '%s' from %s", action_type, key);
		g_free (action_type);
		return;
	}

	g_free (action_type);

	/* compatibility: migrate from MATE < 2.13.90 */
	if (type == PANEL_ACTION_SCREENSHOT)
		panel_compatibility_migrate_screenshot_action (panel_mateconf_get_client (),
							       id);
	else
		panel_action_button_load (type, panel, locked,
					  position, exactpos, id, FALSE);
}
static void
parse_distance_string (const gchar *mateconf_str, MateWeatherPrefs *prefs)
{
    gint value = 0;
#ifdef _NL_MEASUREMENT_MEASUREMENT
    char *imperial = NULL;
#endif

    prefs->distance_unit = DISTANCE_UNIT_INVALID;
    prefs->use_distance_default = TRUE;
    if (mateconf_str && mateconf_string_to_enum (distance_unit_enum_map, mateconf_str, &value)) {
        prefs->distance_unit = value;

	if ((prefs->distance_unit == DISTANCE_UNIT_DEFAULT) &&
	    (mateconf_string_to_enum (distance_unit_enum_map, _("DEFAULT_DISTANCE_UNIT"), &value)) ) {
	    prefs->distance_unit = value;
	} else {
            prefs->use_distance_default = FALSE;
        }
    }
    else {
        /* TRANSLATOR: This is the default unit to use for visibility distance. */
        /* Valid values are: "m" (meters), "km" (kilometers) and "mi" (miles)   */
        if (mateconf_string_to_enum (distance_unit_enum_map, _("DEFAULT_DISTANCE_UNIT"), &value) ) {
            prefs->distance_unit = value;
        }
    }

    if ((!prefs->distance_unit) || prefs->distance_unit == DISTANCE_UNIT_DEFAULT) {
#ifdef _NL_MEASUREMENT_MEASUREMENT
        imperial = nl_langinfo (_NL_MEASUREMENT_MEASUREMENT);
        if (imperial && imperial[0] == 2)  {
            /* imperial */
            prefs->distance_unit = DISTANCE_UNIT_MILES;
        } else
#endif
            prefs->distance_unit = DISTANCE_UNIT_METERS;
    }

    return;
}
static void
parse_pressure_string (const gchar *mateconf_str, MateWeatherPrefs *prefs)
{
    gint value = 0;
#ifdef _NL_MEASUREMENT_MEASUREMENT
    char *imperial = NULL;
#endif

    prefs->pressure_unit = PRESSURE_UNIT_INVALID;
    prefs->use_pressure_default = TRUE;

    if ( mateconf_str && mateconf_string_to_enum (pressure_unit_enum_map, mateconf_str, &value) ) {
        prefs->pressure_unit = value;

        if ((prefs->pressure_unit == PRESSURE_UNIT_DEFAULT) &&
	    (mateconf_string_to_enum (pressure_unit_enum_map, _("DEFAULT_PRESSURE_UNIT"), &value)) ) {
	    prefs->pressure_unit = value;
	} else {
            prefs->use_pressure_default = FALSE;
        }
    }
    else {
        /* TRANSLATOR: This is the default unit to use for atmospheric pressure. */
        /* Valid values are: "kPa" (kiloPascals), "hPa" (hectoPascals),
           "mb" (millibars), "mmHg" (millimeters of mercury),
           "inHg" (inches of mercury) and "atm" (atmosphere) */
        if (mateconf_string_to_enum (pressure_unit_enum_map, _("DEFAULT_PRESSURE_UNIT"), &value) ) {
            prefs->pressure_unit = value;
        }
    }
    if ( (!prefs->pressure_unit) || prefs->pressure_unit == PRESSURE_UNIT_DEFAULT ) {
#ifdef _NL_MEASUREMENT_MEASUREMENT
        imperial = nl_langinfo (_NL_MEASUREMENT_MEASUREMENT);
        if (imperial && imperial[0] == 2)  {
            /* imperial */
            prefs->pressure_unit = PRESSURE_UNIT_INCH_HG;
        } else
#endif
            prefs->pressure_unit = PRESSURE_UNIT_HPA;
    }
}
static void
parse_speed_string (const gchar *mateconf_str, MateWeatherPrefs *prefs)
{
    gint value = 0;
#ifdef HAVE__NL_MEASUREMENT_MEASUREMENT
    char *imperial = NULL;
#endif

    prefs->speed_unit = SPEED_UNIT_INVALID;
    prefs->use_speed_default = TRUE;

    if (mateconf_str && mateconf_string_to_enum (speed_unit_enum_map, mateconf_str, &value) ) {
        prefs->speed_unit = value;
	if ((prefs->speed_unit == SPEED_UNIT_DEFAULT) &&
	    (mateconf_string_to_enum (speed_unit_enum_map, _("DEFAULT_SPEED_UNIT"), &value)) ) {
	    prefs->speed_unit = value;
	} else {
            prefs->use_speed_default = FALSE;
        }
    }
    else {
        /* TRANSLATOR: This is the default unit to use for wind speed. */
        /* Valid values are: "m/s" (meters per second), "km/h" (kilometers per hour), */
        /* "mph" (miles per hour) and "knots"  */
        if (mateconf_string_to_enum (speed_unit_enum_map, _("DEFAULT_SPEED_UNIT"), &value) ) {
            prefs->speed_unit = value;
        }
    }
    if ((!prefs->speed_unit) || prefs->speed_unit == SPEED_UNIT_DEFAULT) {
#ifdef HAVE__NL_MEASUREMENT_MEASUREMENT
        imperial = nl_langinfo (_NL_MEASUREMENT_MEASUREMENT);
        if (imperial && imperial[0] == 2)  {
            /* imperial */
            prefs->speed_unit = SPEED_UNIT_KNOTS;
        } else
#endif
            prefs->speed_unit = SPEED_UNIT_MS;
    }
}
static void
parse_temp_string (const gchar *mateconf_str, MateWeatherPrefs *prefs)
{
    gint value = 0;
#ifdef HAVE__NL_MEASUREMENT_MEASUREMENT
    char *imperial = NULL;
#endif

    prefs->temperature_unit = TEMP_UNIT_INVALID;
    prefs->use_temperature_default = TRUE;

    if ( mateconf_str && mateconf_string_to_enum (temp_unit_enum_map, mateconf_str, &value) ) {
        prefs->temperature_unit = value;

	if ((prefs->temperature_unit == TEMP_UNIT_DEFAULT) &&
	    (mateconf_string_to_enum (temp_unit_enum_map, _("DEFAULT_TEMP_UNIT"), &value)) ) {
	    prefs->temperature_unit = value;
	} else {
            prefs->use_temperature_default = FALSE;
        }
    } else {
        /* TRANSLATOR: This is the default unit to use for temperature measurements. */
        /* Valid values are: "K" (Kelvin), "C" (Celsius) and "F" (Fahrenheit) */
        if (mateconf_string_to_enum (temp_unit_enum_map, _("DEFAULT_TEMP_UNIT"), &value) ) {
            prefs->temperature_unit = value;
        }
    }
    if (!prefs->temperature_unit || prefs->temperature_unit == TEMP_UNIT_DEFAULT ) {
#ifdef HAVE__NL_MEASUREMENT_MEASUREMENT
        imperial = nl_langinfo (_NL_MEASUREMENT_MEASUREMENT);
        if ( imperial && imperial[0] == 2 )  {
            /* imperial */
            prefs->temperature_unit = TEMP_UNIT_FAHRENHEIT;
        } else
#endif
            prefs->temperature_unit = TEMP_UNIT_CENTIGRADE;
    }
}
/*
 * Code implementing a group of radio buttons with different Xft option combinations.
 * If one of the buttons is matched by the MateConf key, we pick it. Otherwise we
 * show the group as inconsistent.
 */
static void
font_render_get_mateconf (MateConfClient  *client,
		       Antialiasing *antialiasing,
		       Hinting      *hinting)
{
  gchar *antialias_str = mateconf_client_get_string (client, FONT_ANTIALIASING_KEY, NULL);
  gchar *hint_str = mateconf_client_get_string (client, FONT_HINTING_KEY, NULL);
  gint val;

  val = ANTIALIAS_GRAYSCALE;
  if (antialias_str) {
    mateconf_string_to_enum (antialias_enums, antialias_str, &val);
    g_free (antialias_str);
  }
  *antialiasing = val;

  val = HINT_FULL;
  if (hint_str) {
    mateconf_string_to_enum (hint_enums, hint_str, &val);
    g_free (hint_str);
  }
  *hinting = val;
}
gboolean
panel_action_button_load_from_drag (PanelToplevel *toplevel,
				    int            position,
				    const char    *drag_string,
				    int           *old_applet_idx)
{
	PanelActionButtonType   type = PANEL_ACTION_NONE;
	gboolean                retval = FALSE;
	char                  **elements;

	if (strncmp (drag_string, "ACTION:", strlen ("ACTION:")))
		return retval;

	elements = g_strsplit (drag_string, ":", 0);

	g_assert (elements != NULL);

	if (!elements [1] || !elements [2]) {
		g_strfreev (elements);
		return retval;
	}

	if (!mateconf_string_to_enum (panel_action_type_map, elements [1], (gpointer) &type)) {
		g_strfreev (elements);
		return retval;
	}

	g_return_val_if_fail (type > PANEL_ACTION_NONE && type < PANEL_ACTION_LAST, FALSE);

	if (panel_action_get_is_deprecated (type))
		return retval;

	if (strcmp (elements [2], "NEW")) {
		*old_applet_idx = strtol (elements [2], NULL, 10);
		retval = TRUE; /* Remove the old applet */
	}

	g_strfreev (elements);

	panel_action_button_create (toplevel, position, type);

	return retval;
}
static void
panel_action_button_type_changed (MateConfClient       *client,
				  guint              cnxn_id,
				  MateConfEntry        *entry,
				  PanelActionButton *button)
{
	int         type;
	const char *action_type;

	g_return_if_fail (PANEL_IS_ACTION_BUTTON (button));

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

	action_type = mateconf_value_get_string (entry->value);

	if (!mateconf_string_to_enum (panel_action_type_map, action_type, &type))
		return;

	panel_action_button_set_type (button, type);
}
static void
enum_group_load (EnumGroup *group)
{
  gchar *str = mateconf_client_get_string (group->client, group->mateconf_key, NULL);
  gint val = group->default_value;
  GSList *tmp_list;

  if (str)
    mateconf_string_to_enum (group->enums, str, &val);

  g_free (str);

  in_change = TRUE;

  for (tmp_list = group->items; tmp_list; tmp_list = tmp_list->next) {
    EnumItem *item = tmp_list->data;

    if (val == item->value)
      gtk_toggle_button_set_active (item->widget, TRUE);
  }

  in_change = FALSE;
}