示例#1
0
static void
migrate_46_plugin_heartlenv_menu (XfconfChannel *channel,
                              XfceRc        *rc)
{
  migrate_46_plugin_bool ("show_menu_icons", "show-menu-icons", TRUE);
  migrate_46_plugin_bool ("show_button_title", "show-button-title", TRUE);
  migrate_46_plugin_string ("menu_file", "custom-menu-file", "");
  migrate_46_plugin_string ("icon_file", "button-icon", "heartlenv-panel-menu");
  migrate_46_plugin_string ("button_title", "button-title", "");

  if (xfce_rc_has_entry (rc, "use_default_menu"))
    xfconf_channel_set_bool (channel, "/custom-menu",
       !xfce_rc_read_bool_entry (rc, "use_default_menu", TRUE));
}
示例#2
0
static void
migrate_46_plugin_windowlist (XfconfChannel *channel,
                              XfceRc        *rc)
{
  if (xfce_rc_has_entry (rc, "urgency_notify"))
    xfconf_channel_set_bool (channel, "/urgentcy-notification",
      xfce_rc_read_int_entry (rc, "button_layout", 0) > 0);

  migrate_46_plugin_uint ("button_layout", "style", 0);
  migrate_46_plugin_bool ("show_all_workspaces", "all-workspaces", TRUE);
  migrate_46_plugin_bool ("show_workspace_actions", "workspace-actions", FALSE);

  /* TODO
   * xfce_rc_read_bool_entry (rc, "show_window_icons", TRUE); */
}
示例#3
0
static void
migrate_46_plugin_separator (XfconfChannel *channel,
                             XfceRc        *rc)
{
  gint  type;
  guint style;

  if (!xfce_rc_has_entry (rc, "separator-type"))
    return;

  type = xfce_rc_read_int_entry (rc, "separator-type", 0);
  switch (type)
    {
    case 0: /* SEP_SPACE */
      style = 0; /* SEPARATOR_PLUGIN_STYLE_TRANSPARENT */
      break;

    case 1: /* SEP_EXPAND */
      style = 0; /* SEPARATOR_PLUGIN_STYLE_TRANSPARENT */
      xfconf_channel_set_bool (channel, "/expand", TRUE);
      break;

    case 2: /* SEP_LINE */
      style = 1; /* SEPARATOR_PLUGIN_STYLE_SEPARATOR */
      break;

    case 3: /* SEP_HANDLE */
      style = 2; /* SEPARATOR_PLUGIN_STYLE_HANDLE */
      break;

    default: /* SEP_DOTS */
      style = 3; /* SEPARATOR_PLUGIN_STYLE_DOTS */
      break;
    }

  xfconf_channel_set_uint (channel, "/style", style);
}
示例#4
0
void
xfce_randr_save_output (XfceRandr     *randr,
                        const gchar   *scheme,
                        XfconfChannel *channel,
                        guint          output,
                        gint           rel_changed)
{
    gchar             property[512];
    gchar            *str_value;
    const XfceRRMode *mode;
    gint              degrees;

    g_return_if_fail (randr != NULL && scheme != NULL);
    g_return_if_fail (XFCONF_IS_CHANNEL (channel));
    g_return_if_fail (output < randr->noutput);

    /* save the device name */
    g_snprintf (property, sizeof (property), "/%s/%s", scheme,
                randr->priv->output_info[output]->name);
    xfconf_channel_set_string (channel, property, randr->friendly_name[output]);

    /* find the resolution and refresh rate */
    mode = xfce_randr_find_mode_by_id (randr, output, randr->mode[output]);

    /* if no resolution was found, mark it as inactive and stop */
    g_snprintf (property, sizeof (property), "/%s/%s/Active", scheme,
                randr->priv->output_info[output]->name);
    xfconf_channel_set_bool (channel, property, mode != NULL);

    if (mode == NULL)
        return;

    /* save the resolution */
    str_value = g_strdup_printf ("%dx%d", mode->width, mode->height);
    g_snprintf (property, sizeof (property), "/%s/%s/Resolution", scheme,
                randr->priv->output_info[output]->name);
    xfconf_channel_set_string (channel, property, str_value);
    g_free (str_value);

    /* save the refresh rate */
    g_snprintf (property, sizeof (property), "/%s/%s/RefreshRate", scheme,
                randr->priv->output_info[output]->name);
    xfconf_channel_set_double (channel, property, mode->rate);

    /* convert the rotation into degrees */
    switch (randr->rotation[output] & XFCE_RANDR_ROTATIONS_MASK)
    {
        case RR_Rotate_90:  degrees = 90;  break;
        case RR_Rotate_180: degrees = 180; break;
        case RR_Rotate_270: degrees = 270; break;
        default:            degrees = 0;   break;
    }

    /* save the rotation in degrees */
    g_snprintf (property, sizeof (property), "/%s/%s/Rotation", scheme,
                randr->priv->output_info[output]->name);
    xfconf_channel_set_int (channel, property, degrees);

    /* convert the reflection into a string */
    switch (randr->rotation[output] & XFCE_RANDR_REFLECTIONS_MASK)
    {
        case RR_Reflect_X:              str_value = "X";  break;
        case RR_Reflect_Y:              str_value = "Y";  break;
        case RR_Reflect_X|RR_Reflect_Y: str_value = "XY"; break;
        default:                        str_value = "0";  break;
    }

    /* save the reflection string */
    g_snprintf (property, sizeof (property), "/%s/%s/Reflection", scheme,
                randr->priv->output_info[output]->name);
    xfconf_channel_set_string (channel, property, str_value);

#ifdef HAS_RANDR_ONE_POINT_THREE
    /* is it the primary output? */
    g_snprintf (property, sizeof (property), "/%s/%s/Primary", scheme,
                randr->priv->output_info[output]->name);
    xfconf_channel_set_bool (channel, property,
                             randr->status[output] == XFCE_OUTPUT_STATUS_PRIMARY);
#endif

    /* update positions according to the current relations */
    if (rel_changed)
        xfce_randr_update_positions (randr, output);

    /* save the position */
    g_snprintf (property, sizeof (property), "/%s/%s/Position/X", scheme,
                randr->priv->output_info[output]->name);
    xfconf_channel_set_int (channel, property, MAX (randr->priv->position[output].x, 0));
    g_snprintf (property, sizeof (property), "/%s/%s/Position/Y", scheme,
                randr->priv->output_info[output]->name);
    xfconf_channel_set_int (channel, property, MAX (randr->priv->position[output].y, 0));
}
示例#5
0
static void
migrate_46_end_element_handler (GMarkupParseContext  *context,
                                const gchar          *element_name,
                                gpointer              user_data,
                                GError              **error)
{
  ConfigParser *parser = user_data;
  SnapPosition  snap_position;
  gboolean      horizontal;
  gchar         prop[128];
  gchar        *position;

  g_return_if_fail (XFCONF_IS_CHANNEL (parser->channel));

  switch (parser->state)
    {
    case START:
      g_set_error (error, G_MARKUP_ERROR_PARSE, G_MARKUP_ERROR,
                   "Unexpected end element \"%s\"", element_name);
      break;

    case PANEL:
      if (strcmp ("panel", element_name) == 0)
        {
          parser->state = PANELS;

          /* store ids array */
          g_snprintf (prop, sizeof (prop), "/panels/panel-%u/plugin-ids", parser->panel_id_counter);
          xfconf_channel_set_arrayv (parser->channel, prop, parser->panel_plugin_ids);
          xfconf_array_free (parser->panel_plugin_ids);

          /* translate the old screen position to a snap position and orientation */
          migrate_46_panel_screen_position (parser->panel_screen_position,
                                            &snap_position, &horizontal);

          g_snprintf (prop, sizeof (prop), "/panels/panel-%u/horizontal", parser->panel_id_counter);
          xfconf_channel_set_bool (parser->channel, prop, horizontal);

          g_snprintf (prop, sizeof (prop), "/panels/panel-%u/position", parser->panel_id_counter);
          position = g_strdup_printf ("p=%d;x=%d;y=%d",
                                      snap_position,
                                      parser->panel_xoffset,
                                      parser->panel_yoffset);
          xfconf_channel_set_string (parser->channel, prop, position);
          g_free (position);

          /* set transparency */
          g_snprintf (prop, sizeof (prop), "/panels/panel-%u/leave-opacity", parser->panel_id_counter);
          xfconf_channel_set_uint (parser->channel, prop, 100 - parser->panel_transparency);

          g_snprintf (prop, sizeof (prop), "/panels/panel-%u/enter-opacity", parser->panel_id_counter);
          xfconf_channel_set_uint (parser->channel, prop,  parser->panel_activetrans ?
                                   100 - parser->panel_transparency : 100);

          /* prepare for the next panel */
          parser->panel_id_counter++;
        }
      break;

    case PANELS:
      if (strcmp ("panels", element_name) == 0)
        {
          parser->state = START;
          xfconf_channel_set_uint (parser->channel, "/panels", parser->panel_id_counter);
        }
      break;

    case PROPERTIES:
      if (strcmp ("properties", element_name) == 0)
        parser->state = PANEL;
      break;

    case ITEMS:
      if (strcmp ("items", element_name) == 0)
        parser->state = PANEL;
      break;

    default:
      g_set_error (error, G_MARKUP_ERROR_UNKNOWN_ELEMENT, G_MARKUP_ERROR,
                   "Unknown end element \"%s\"", element_name);
      break;
    }
}
示例#6
0
static void
migrate_46_panel_set_property (ConfigParser  *parser,
                               const gchar   *property_name,
                               const gchar   *value,
                               GError       **error)
{
  gchar       prop[128];
  GdkDisplay *display;
  gchar      *name;
  gint        num;

  if (strcmp (property_name, "size") == 0)
    {
      g_snprintf (prop, sizeof (prop), "/panels/panel-%u/size", parser->panel_id_counter);
      xfconf_channel_set_uint (parser->channel, prop, CLAMP (atoi (value), 16, 128));
    }
  else if (strcmp (property_name, "fullwidth") == 0)
    {
      g_snprintf (prop, sizeof (prop), "/panels/panel-%u/length", parser->panel_id_counter);
      xfconf_channel_set_uint (parser->channel, prop, (atoi (value) != 0) ? 100 : 0);
    }
  else if (strcmp (property_name, "screen-position") == 0)
    {
      parser->panel_screen_position = CLAMP (atoi (value),
                                             XFCE_SCREEN_POSITION_NONE,
                                             XFCE_SCREEN_POSITION_FLOATING_V);
    }
  else if (strcmp (property_name, "xoffset") == 0)
    {
      parser->panel_xoffset = MAX (0, atoi (value));
    }
  else if (strcmp (property_name, "yoffset") == 0)
    {
      parser->panel_yoffset = MAX (0, atoi (value));
    }
  else if (strcmp (property_name, "monitor") == 0)
    {
      /* in 4.4 and 4.6 we only use monitor and make no difference between monitors
       * and screen's, so check the setup of the user to properly convert this */
      num = MAX (0, atoi (value));
      if (G_LIKELY (num > 0))
        {
          display = gdk_display_get_default ();
          if (display != NULL && gdk_display_get_n_screens (display) > 1)
            name = g_strdup_printf ("screen-%d", num);
          else
            name = g_strdup_printf ("monitor-%d", num);

          g_snprintf (prop, sizeof (prop), "/panels/panel-%u/output", parser->panel_id_counter);
          xfconf_channel_set_string (parser->channel, prop, name);
          g_free (name);
        }
    }
  else if (strcmp (property_name, "handlestyle") == 0)
    {
      g_snprintf (prop, sizeof (prop), "/panels/panel-%u/locked", parser->panel_id_counter);
      xfconf_channel_set_bool (parser->channel, prop, atoi (value) == 0);
    }
  else if (strcmp (property_name, "autohide") == 0)
    {
      g_snprintf (prop, sizeof (prop), "/panels/panel-%u/autohide", parser->panel_id_counter);
      xfconf_channel_set_bool (parser->channel, prop, (atoi (value) == 1));
    }
  else if (strcmp (property_name, "transparency") == 0)
    {
      parser->panel_transparency = CLAMP (atoi (value), 0, 100);
    }
  else if (strcmp (property_name, "activetrans") == 0)
    {
      parser->panel_activetrans = (atoi (value) == 1);
    }
  else
    {
      g_set_error (error, G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, G_MARKUP_ERROR,
                   "Unknown property \"%s\" in #%d \"panel\" element",
                   property_name, parser->panel_id_counter);
    }
}