Exemplo n.º 1
0
void
xfce_randr_apply (XfceRandr     *randr,
                  const gchar   *scheme,
                  XfconfChannel *channel)
{
    g_return_if_fail (randr != NULL && scheme != NULL);
    g_return_if_fail (XFCONF_IS_CHANNEL (channel));

    /* tell the helper to apply this theme */
    xfconf_channel_set_string (channel, "/Schemes/Apply", scheme);
}
Exemplo n.º 2
0
static void _xfdashboard_settings_xfconf_changed_notification_timeout(XfdashboardSettings *self,
																		const gchar *inProperty,
																		const GValue *inValue,
																		XfconfChannel *inChannel)
{
	XfdashboardSettingsPrivate		*priv;
	guint							newValue;

	g_return_if_fail(XFDASHBOARD_IS_SETTINGS(self));
	g_return_if_fail(inValue);
	g_return_if_fail(XFCONF_IS_CHANNEL(inChannel));

	priv=self->priv;

	/* Get new value to set at widget */
	if(G_UNLIKELY(G_VALUE_TYPE(inValue)!=G_TYPE_UINT)) newValue=DEFAULT_NOTIFICATION_TIMEOUT;
		else newValue=g_value_get_uint(inValue);

	/* Set new value at widget */
	gtk_range_set_value(GTK_RANGE(priv->widgetNotificationTimeout), newValue/1000.0);
}
Exemplo n.º 3
0
static void _xfdashboard_settings_xfconf_changed_switch_view_on_resume(XfdashboardSettings *self,
																		const gchar *inProperty,
																		const GValue *inValue,
																		XfconfChannel *inChannel)
{
	XfdashboardSettingsPrivate		*priv;
	GtkTreeModel					*model;
	GtkTreeIter						iter;
	gchar							*value;
	const gchar						*newValue;

	g_return_if_fail(XFDASHBOARD_IS_SETTINGS(self));
	g_return_if_fail(inValue);
	g_return_if_fail(XFCONF_IS_CHANNEL(inChannel));

	priv=self->priv;

	/* Get new value to lookup and set at combo box */
	if(G_UNLIKELY(G_VALUE_TYPE(inValue)!=G_TYPE_STRING)) newValue="";
		else newValue=g_value_get_string(inValue);

	/* Iterate through combo box value and set new value if match is found */
	model=gtk_combo_box_get_model(GTK_COMBO_BOX(priv->widgetSwitchViewOnResume));
	if(gtk_tree_model_get_iter_first(model, &iter))
	{
		do
		{
			gtk_tree_model_get(model, &iter, 1, &value, -1);
			if(G_UNLIKELY(g_str_equal(value, newValue)))
			{
				g_free(value);
				gtk_combo_box_set_active_iter(GTK_COMBO_BOX(priv->widgetSwitchViewOnResume), &iter);
				break;
			}
			g_free(value);
		}
		while(gtk_tree_model_iter_next(model, &iter));
	}
}
Exemplo n.º 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));
}
Exemplo n.º 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;
    }
}
Exemplo n.º 6
0
static void
migrate_46_start_element_handler (GMarkupParseContext  *context,
                                  const gchar          *element_name,
                                  const gchar         **attribute_names,
                                  const gchar         **attribute_values,
                                  gpointer              user_data,
                                  GError              **error)
{
  ConfigParser *parser = user_data;
  guint         i;
  const gchar  *name, *id, *value;
  GValue       *id_value;

  g_return_if_fail (XFCONF_IS_CHANNEL (parser->channel));

  switch (parser->state)
    {
    case START:
      if (strcmp (element_name, "panels") == 0)
        parser->state = PANELS;
      break;

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

          /* intialize new ids array */
          parser->panel_plugin_ids = g_ptr_array_new ();

          /* set defaults */
          parser->panel_screen_position = XFCE_SCREEN_POSITION_NONE;
          parser->panel_xoffset = 100;
          parser->panel_yoffset = 100;
          parser->panel_transparency = 100;
          parser->panel_activetrans = FALSE;
        }
      break;

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

    case PROPERTIES:
      if (strcmp (element_name, "property") == 0)
        {
          name = NULL;
          value = NULL;

          for (i = 0; attribute_names[i] != NULL; i++)
            {
              if (strcmp (attribute_names[i], "name") == 0)
                name = attribute_values[i];
              else if (strcmp (attribute_names[i], "value") == 0)
                value = attribute_values[i];
            }

          if (G_LIKELY (name != NULL && value != NULL))
            {
              migrate_46_panel_set_property (parser, name, value, error);
            }
          else
            {
              g_set_error (error, G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, G_MARKUP_ERROR,
                          "Unknown property name (%s) or value (%s) in element",
                           name, value);
            }
        }
      break;

    case ITEMS:
      if (strcmp (element_name, "item") == 0)
        {
          name = id = NULL;

          for (i = 0; attribute_names[i] != NULL; i++)
            {
              if (strcmp (attribute_names[i], "name") == 0)
                name = attribute_values[i];
              else if (strcmp (attribute_names[i], "id") == 0)
                id = attribute_values[i];
            }

          if (G_LIKELY (name != NULL && id != NULL))
            {
              parser->plugin_id_counter++;
              migrate_46_panel_add_plugin (parser, name, id, error);

              id_value = g_new0 (GValue, 1);
              g_value_init (id_value, G_TYPE_INT);
              g_value_set_int (id_value, parser->plugin_id_counter);
              g_ptr_array_add (parser->panel_plugin_ids, id_value);
            }
          else
            {
              g_set_error (error, G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, G_MARKUP_ERROR,
                          "Unknown item name (%s) or id (%s) in element",
                           name, id);
            }
        }
      break;

    default:
      g_set_error (error, G_MARKUP_ERROR_UNKNOWN_ELEMENT, G_MARKUP_ERROR,
                   "Unknown start element \"%s\"", element_name);
      break;
    }
}
Exemplo n.º 7
0
static void
migrate_46_panel_add_plugin (ConfigParser  *parser,
                             const gchar   *name,
                             const gchar   *id,
                             GError       **error)
{
  XfconfChannel *channel;
  gchar          base[256];
  XfceRc        *rc;
  const gchar   *plugin_name = name;

  g_return_if_fail (XFCONF_IS_CHANNEL (parser->channel));

  /* open the old rc file of the plugin */
  g_snprintf (base, sizeof (base), "heartlenv" G_DIR_SEPARATOR_S
             "panel" G_DIR_SEPARATOR_S "%s-%s.rc", name, id);
  rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, base, TRUE);

  /* open a panel with the propert base for the plugin */
  g_snprintf (base, sizeof (base), "/plugins/plugin-%d", parser->plugin_id_counter);
  channel = xfconf_channel_new_with_property_base (XFCE_PANEL_CHANNEL_NAME, base);

  if (strcmp (name, "actions") == 0)
    {
      if (G_LIKELY (rc != NULL))
        migrate_46_plugin_actions (channel, rc);
    }
  else if (strcmp (name, "clock") == 0)
    {
      if (G_LIKELY (rc != NULL))
        migrate_46_plugin_clock (channel, rc);
    }
  else if (strcmp (name, "iconbox") == 0)
    {
      plugin_name = "tasklist";
      if (G_LIKELY (rc != NULL))
        migrate_46_plugin_iconbox (channel, rc);
    }
  else if (strcmp (name, "launcher") == 0)
    {
      if (G_LIKELY (rc != NULL))
        migrate_46_plugin_launcher (channel, rc, parser->plugin_id_counter, error);
    }
  else if (strcmp (name, "pager") == 0)
    {
      if (G_LIKELY (rc != NULL))
        migrate_46_plugin_pager (channel, rc);
    }
  else if (strcmp (name, "separator") == 0)
    {
      if (G_LIKELY (rc != NULL))
        migrate_46_plugin_separator (channel, rc);
    }
  else if (strcmp (name, "showdesktop") == 0)
    {
      if (G_LIKELY (rc != NULL))
        migrate_46_plugin_showdesktop (channel, rc);
    }
  else if (strcmp (name, "systray") == 0)
    {
      if (G_LIKELY (rc != NULL))
        migrate_46_plugin_systray (channel, rc);
    }
  else if (strcmp (name, "tasklist") == 0)
    {
      if (G_LIKELY (rc != NULL))
        migrate_46_plugin_tasklist (channel, rc);
    }
  else if (strcmp (name, "windowlist") == 0)
    {
      plugin_name = "windowmenu";
      if (G_LIKELY (rc != NULL))
        migrate_46_plugin_windowlist (channel, rc);
    }
  else if (strcmp (name, "heartlenv-menu") == 0)
    {
      plugin_name = "applicationsmenu";
      if (G_LIKELY (rc != NULL))
        migrate_46_plugin_heartlenv_menu (channel, rc);
    }
  else
    {
      /* handle other "external" plugins */
    }

  /* close plugin configs */
  g_object_unref (G_OBJECT (channel));
  if (G_LIKELY (rc != NULL))
    xfce_rc_close (rc);

  /* store the (new) plugin name */
  xfconf_channel_set_string (parser->channel, base, plugin_name);
}
Exemplo n.º 8
0
/* Property for list of enabled plugins in xfconf has changed */
static void _xfdashboard_plugins_manager_on_enabled_plugins_changed(XfdashboardPluginsManager *self,
																	const gchar *inProperty,
																	const GValue *inValue,
																	gpointer inUserData)
{
	XfdashboardPluginsManagerPrivate	*priv;
	gchar								**enabledPlugins;

	g_return_if_fail(XFDASHBOARD_IS_PLUGINS_MANAGER(self));
	g_return_if_fail(XFCONF_IS_CHANNEL(inUserData));

	priv=self->priv;

	/* If plugin managed is not inited do not load or "unload" any plugin */
	if(!priv->isInited) return;

	/* Get new list of enabled plugins */
	enabledPlugins=xfconf_channel_get_string_list(xfdashboard_application_get_xfconf_channel(NULL),
													ENABLED_PLUGINS_XFCONF_PROP);

	/* Iterate through list of loaded plugin and check if it also in new list
	 * of enabled plugins. If it is not then disable this plugin.
	 */
	if(priv->plugins)
	{
		GList								*iter;
		XfdashboardPlugin					*plugin;
		const gchar							*pluginID;

		iter=priv->plugins;
		while(iter)
		{
			GList							*nextIter;
			gchar							**listIter;
			gchar							*listIterPluginID;
			gboolean						found;

			/* Get next item getting iterated before doing anything
			 * because the current item may get removed and the iterator
			 * would get invalid.
			 */
			nextIter=g_list_next(iter);

			/* Get currently iterated plugin */
			plugin=XFDASHBOARD_PLUGIN(iter->data);

			/* Get plugin ID */
			pluginID=xfdashboard_plugin_get_id(plugin);

			/* Check if plugin ID is still in new list of enabled plugins */
			found=FALSE;
			for(listIter=enabledPlugins; !found && *listIter; listIter++)
			{
				/* Get plugin ID of new enabled plugins currently iterated */
				listIterPluginID=*listIter;

				/* Check if plugin ID matches this iterated one. If so,
				 * set flag that plugin was found.
				 */
				if(g_strcmp0(pluginID, listIterPluginID)==0) found=TRUE;
			}

			/* Check that found flag is set. If it is not then disable plugin */
			if(!found)
			{
				XFDASHBOARD_DEBUG(self, PLUGINS,
									"Disable plugin '%s'",
									pluginID);

				/* Disable plugin */
				xfdashboard_plugin_disable(plugin);
			}

			/* Move iterator to next item */
			iter=nextIter;
		}
	}

	/* Iterate through new list of enabled plugin and check if it is already
	 * or still in the list of loaded plugins. If it not in this list then
	 * try to load this plugin. If it is then enable it again when it is in
	 * disable state.
	 */
	if(enabledPlugins)
	{
		gchar								**iter;
		gchar								*pluginID;
		GError								*error;
		XfdashboardPlugin					*plugin;

		error=NULL;

		/* Iterate through new list of enabled plugins and load new plugins */
		for(iter=enabledPlugins; *iter; iter++)
		{
			/* Get plugin ID to check */
			pluginID=*iter;

			/* Check if a plugin with this ID exists already */
			plugin=_xfdashboard_plugins_manager_find_plugin_by_id(self, pluginID);
			if(!plugin)
			{
				/* The plugin does not exist so try to load it */
				if(!_xfdashboard_plugins_manager_load_plugin(self, pluginID, &error))
				{
					/* Show error message */
					g_warning(_("Could not load plugin '%s': %s"),
								pluginID,
								error ? error->message : _("Unknown error"));

					/* Release allocated resources */
					if(error)
					{
						g_error_free(error);
						error=NULL;
					}
				}
					else
					{
						XFDASHBOARD_DEBUG(self, PLUGINS,
											"Loaded plugin '%s'",
											pluginID);
					}
			}
				else
				{
					/* The plugin exists already so check if it is disabled and
					 * re-enable it.
					 */
					if(!xfdashboard_plugin_is_enabled(plugin))
					{
						XFDASHBOARD_DEBUG(self, PLUGINS,
											"Re-enable plugin '%s'",
											pluginID);
						xfdashboard_plugin_enable(plugin);
					}
				}
		}
	}

	/* Release allocated resources */
	if(enabledPlugins) g_strfreev(enabledPlugins);
}
Exemplo n.º 9
0
static void _xfdashboard_settings_xfconf_changed_theme(XfdashboardSettings *self,
														const gchar *inProperty,
														const GValue *inValue,
														XfconfChannel *inChannel)
{
	XfdashboardSettingsPrivate		*priv;
	const gchar						*newValue;
	GtkTreeModel					*model;
	GtkTreeIter						iter;
	gboolean						selectionFound;

	g_return_if_fail(XFDASHBOARD_IS_SETTINGS(self));
	g_return_if_fail(inValue);
	g_return_if_fail(XFCONF_IS_CHANNEL(inChannel));

	priv=self->priv;
	newValue=DEFAULT_THEME;

	/* Get new value to set at widget */
	if(G_LIKELY(G_VALUE_TYPE(inValue)==G_TYPE_STRING)) newValue=g_value_get_string(inValue);

	/* Iterate through themes' model and lookup matching item
	 * against new theme name and select it
	 */
	selectionFound=FALSE;
	model=gtk_tree_view_get_model(GTK_TREE_VIEW(priv->widgetThemes));
	if(newValue && gtk_tree_model_get_iter_first(model, &iter))
	{
		do
		{
			gchar					*value;

			gtk_tree_model_get(model,
								&iter,
								COLUMN_THEME_NAME, &value,
								-1);
			if(G_UNLIKELY(g_str_equal(value, newValue)))
			{
				GtkTreePath			*selectionPath;

				selectionPath=gtk_tree_model_get_path(GTK_TREE_MODEL(model), &iter);
				gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->widgetThemes)), &iter);
				gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(priv->widgetThemes), selectionPath, NULL, TRUE, 0.5, 0.5);
				gtk_tree_path_free(selectionPath);

				selectionFound=TRUE;
			}
			g_free(value);
		}
		while(!selectionFound && gtk_tree_model_iter_next(model, &iter));
	}

	/* If no selection was found, deselect any selected entry at widget */
	if(!selectionFound)
	{
		GtkTreeSelection			*selection;

		selection=gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->widgetThemes));
		gtk_tree_selection_unselect_all(selection);
	}
}