예제 #1
0
static void
init_display (GdkDisplay *dpy,
              XfceRc     *rc,
              gboolean disable_tcp)
{
  const gchar *engine;
  gint n;

  xfce_rc_set_group (rc, "Splash Screen");
  engine = xfce_rc_read_entry (rc, "Engine", NULL);

  splash_screen = xfsm_splash_screen_new (dpy, engine);  
  xfsm_splash_screen_next (splash_screen, _("Loading desktop settings"));

  gdk_flush ();

  xfce_rc_set_group (rc, "General");
  sm_init (rc, disable_tcp);
  
  /* start a MCS manager process per screen (FIXME: parallel to loading logo) */
  for (n = 0; n < gdk_display_get_n_screens (dpy); ++n)
    {
      mcs_client_check_manager (gdk_x11_display_get_xdisplay (dpy), n,
                                "xfce-mcs-manager");
    }

  /* gtk resource files may have changed */
  gtk_rc_reparse_all ();
}
예제 #2
0
void
xfce_xkb_save_config (XfcePanelPlugin *plugin, t_xkb *xkb)
{
    gchar* filename;
    XfceRc* rcfile;


    filename = xfce_panel_plugin_save_location (plugin, TRUE);
    if (!filename)
        return;


    rcfile = xfce_rc_simple_open (filename, FALSE);
    if (!rcfile)
    {
        g_free (filename);
        return;
    }

    xfce_rc_set_group (rcfile, NULL);

    xfce_rc_write_int_entry (rcfile, "display_type", xkb->display_type);
    xfce_rc_write_int_entry (rcfile, "display_textscale", xkb->display_text_scale);
    xfce_rc_write_int_entry (rcfile, "display_imgscale", xkb->display_img_scale);
    xfce_rc_write_int_entry (rcfile, "group_policy", xkb->group_policy);

    xfce_rc_close (rcfile);
    g_free (filename);
}
예제 #3
0
static void
migrate_46_plugin_systray (XfconfChannel *channel,
                           XfceRc        *rc)
{
  if (xfce_rc_has_group (rc, "Global"))
    {
      xfce_rc_set_group (rc, "Global");

      migrate_46_plugin_bool ("ShowFrame", "show-frame", TRUE);
      migrate_46_plugin_uint ("Rows", "rows", 1);
    }

  if (xfce_rc_has_group (rc, "Applications"))
    {
      xfce_rc_set_group (rc, "Applications");

      /* TODO */
      /* xfce_rc_read_bool_entry (rc, appname, hidden); */
    }
}
예제 #4
0
void
launcher_save_config(t_launcher *launcher, XfceRc *rcfile, guint16 num)
{
	char group[15];
	g_sprintf(group, "launcher_%d%c", num,0);
	xfce_rc_set_group(rcfile, group);
	xfce_rc_write_entry(rcfile, "command", launcher->command);
	if(launcher->icon_name)
		xfce_rc_write_entry(rcfile, "icon_name", launcher->icon_name);
	xfce_rc_write_int_entry(rcfile, "icon_id", launcher->icon_id);
	xfce_rc_flush(rcfile);
}
예제 #5
0
/**
 * xfae_model_edit:
 * @model       : a #XfaeModel.
 * @iter        : the #GtkTreeIter referring to the item that should be removed.
 * @name        : the user visible name of the new item.
 * @description : the description for the new item.
 * @command     : the command for the new item.
 * @error       : return locations for errors or %NULL.
 *
 * Attempts to edit an item with the given parameters
 * to @model.
 *
 * Return value: %TRUE if successfull, else %FALSE.
 **/
gboolean
xfae_model_edit (XfaeModel   *model,
                 GtkTreeIter *iter,
                 const gchar *name,
                 const gchar *description,
                 const gchar *command,
                 GError     **error)
{
  GtkTreePath *path;
  XfaeItem    *item;
  XfceRc      *rc;
  GList       *lp;

  g_return_val_if_fail (XFAE_IS_MODEL (model), FALSE);
  g_return_val_if_fail (iter->stamp == model->stamp, FALSE);
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

  lp = iter->user_data;
  item = lp->data;

  /* try to open the resource config */
  rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, item->relpath, FALSE);
  if (G_UNLIKELY (rc == NULL))
    {
      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (EIO),
                   _("Failed to open %s for writing"), item->relpath);
      return FALSE;
    }

  item->name = g_strdup (name);
  item->comment = g_strdup (description);

  /* write the result */
  xfce_rc_set_group (rc, "Desktop Entry");
  xfce_rc_write_entry (rc, "Name", name);
  xfce_rc_write_entry (rc, "Comment", description);
  xfce_rc_write_entry (rc, "Exec", command);
  xfce_rc_close (rc);

  /* tell the view that we have most probably a new state */
  path = gtk_tree_path_new_from_indices (g_list_position (model->items, lp), -1);
  gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, iter);
  gtk_tree_path_free (path);

  return TRUE;
}
예제 #6
0
t_launcher*
launcher_load_config(XfceRc *rcfile, gint num, t_quicklauncher *quicklauncher)
{
	char group[15];
	t_launcher *launcher;
	g_sprintf(group, "launcher_%d%c", num,0);
	xfce_rc_set_group(rcfile, group);

	launcher = g_new0 (t_launcher, 1);
	launcher->quicklauncher = quicklauncher;
	launcher->command = g_strdup(xfce_rc_read_entry(rcfile, "command", NULL));
	launcher->icon_name = g_strdup(xfce_rc_read_entry(rcfile, "icon_name", NULL));
	launcher->icon_id = xfce_rc_read_int_entry(rcfile, "icon_id", 0);

	create_launcher(launcher);
	return launcher;
}
예제 #7
0
static gboolean
xfapplet_read_configuration (XfAppletPlugin *xap)
{
	XfceRc		*config;
	gchar		*path;
	const gchar	*iid;
	const gchar	*name;
	const gchar	*mateconf_key;

	path = xfce_panel_plugin_lookup_rc_file (xap->plugin);
	if (!path)
		return FALSE;

	config = xfce_rc_simple_open (path, TRUE);
	g_free (path);

	if (!config)
		return FALSE;

	xfce_rc_set_group (config, "xfapplet");

	/* iid for matecomponent control */
	iid = xfce_rc_read_entry (config, "iid", NULL);

	/* applet name (used in dialog messages) */
	name = xfce_rc_read_entry (config, "name", NULL);

	/* mateconf key for applet preferences */
	mateconf_key = xfce_rc_read_entry (config, "mateconfkey", NULL);

	if (!iid || !mateconf_key || !name) {
		xfce_rc_close (config);
		return FALSE;
	}
	
	xap->iid = g_strdup (iid);
	xap->name = g_strdup (name);
	xap->mateconf_key = g_strdup (mateconf_key);

	xfce_rc_close (config);

	return TRUE;
}
unsigned int Plugin::get_fg_color()
{
  static unsigned int colors[] = {
    0x83A67FB0, 0xC1665AB0, 0x7590AEB0, 0xE0C39ED0, 0x887FA3B0
  };

  /* Saving 'current' next color - note that this is an index into the colors,
   * not a color itself */
  int color = next_color;
  
  // Updating next_color
  next_color = int((next_color + 1) %
    (sizeof(colors) / sizeof(unsigned int)));
  
  // Search for a writeable settings file, create one if it doesnt exist
  gchar* file = xfce_panel_plugin_save_location(xfce_plugin, true);
    
  if (file)
  {
    // Opening setting file
    XfceRc* settings_w = xfce_rc_simple_open(file, false);
    g_free(file);

    // Ensuring default group is in focus
    xfce_rc_set_group(settings_w, NULL);

    // Saving next_color
    xfce_rc_write_int_entry(settings_w, "next_color", next_color);
    
    // Close settings file
    xfce_rc_close(settings_w);
  }
  else
  {
    // Unable to obtain writeable config file - informing user and exiting
    std::cerr << _("Unable to obtain writeable config file path in order to"
      " save next_color!\n");
  }

  // Returning actual next color
  return colors[color];
}
예제 #9
0
static gboolean
xkb_load_config (t_xkb *xkb, const gchar *filename)
{
    XfceRc* rcfile;
    gint text_scale;

    if ((rcfile = xfce_rc_simple_open (filename, TRUE)))
    {
        xfce_rc_set_group (rcfile, NULL);

        xkb->display_type = xfce_rc_read_int_entry (rcfile, "display_type", DISPLAY_TYPE_IMAGE);
        text_scale = xfce_rc_read_int_entry (rcfile, "display_textscale", -1);
        if (text_scale < 0)
        {
            /* Check if the old textsize value is there */
            text_scale = xfce_rc_read_int_entry (rcfile, "display_textsize", -1);
            switch (text_scale)
            {
            case DISPLAY_TEXTSIZE_SMALL:
                text_scale = 47;
                break;
            case DISPLAY_TEXTSIZE_MEDIUM:
                text_scale = 70;
                break;
            case DISPLAY_TEXTSIZE_LARGE:
            default:
                text_scale = DISPLAY_TEXTSCALE_LARGE;
                break;
            }
        }
        xkb->display_text_scale = text_scale;
        xkb->display_img_scale = xfce_rc_read_int_entry (rcfile, "display_imgscale", DISPLAY_IMGSCALE_LARGE);
        xkb->group_policy = xfce_rc_read_int_entry (rcfile, "group_policy", GROUP_POLICY_PER_APPLICATION);

        xfce_rc_close (rcfile);

        return TRUE;
    }

    return FALSE;
}
예제 #10
0
void
quicklauncher_save_config(t_quicklauncher *quicklauncher, const gchar* filename)
{
	XfceRc* rcfile;
	GList* liste;
	guint16 i;
	//guint16 i = quicklauncher->nb_launcher; //hope it always works ==> seems that it does not ;)
	i = quicklauncher->nb_launcher;
	rcfile = xfce_rc_simple_open(filename, FALSE);
	if(!rcfile) return;

	xfce_rc_set_group(rcfile, NULL);
	xfce_rc_write_int_entry(rcfile, "nb_lines", quicklauncher->nb_lines);
	xfce_rc_write_int_entry(rcfile, "nb_launcher", quicklauncher->nb_launcher);
	xfce_rc_flush(rcfile);
	for( liste = quicklauncher->launchers; liste; liste = g_list_next(liste), --i)
		launcher_save_config((t_launcher*)liste->data, rcfile, i);

	g_assert(i == 0);
	xfce_rc_close(rcfile);
}
예제 #11
0
static GSList *
parole_pl_parser_parse_pls (const gchar *filename)
{
    XfceRc *rcfile;
    GSList *list = NULL;
    ParoleFile *file;
    const gchar *file_entry, *title_entry;
    guint i, nentries;
    gchar key[128];

    rcfile = xfce_rc_simple_open (filename, TRUE);

    if ( xfce_rc_has_group (rcfile, "playlist") ) 
    {
        xfce_rc_set_group (rcfile, "playlist");
        
        nentries = xfce_rc_read_int_entry (rcfile, "NumberOfEntries", 0);

        for (i = 1; i <= nentries; i++) 
	{
            g_snprintf (key, 128, "File%d", i);
	    
            file_entry = xfce_rc_read_entry (rcfile, key, NULL);
	    
            if (!file_entry)
                continue;
	    
	    g_snprintf (key, 128, "Title%d", i);
	    
            title_entry = xfce_rc_read_entry (rcfile, key, NULL);
	    
	    file = parole_file_new_with_display_name (file_entry, title_entry);
	    list = g_slist_append (list, file);
	}
    }
    
    xfce_rc_close (rcfile);
    
    return list;
}
예제 #12
0
gboolean quicklauncher_load_config(t_quicklauncher *quicklauncher, const gchar* filename)
{

	XfceRc* rcfile;
	gint i;
	
	if( (rcfile = xfce_rc_simple_open(filename, TRUE) ))
	{
		xfce_rc_set_group(rcfile, NULL);
		quicklauncher->nb_lines = xfce_rc_read_int_entry(rcfile, "nb_lines", 1);
		i = xfce_rc_read_int_entry(rcfile, "nb_launcher", 0);
		g_assert(i >= 0);
		while(i)
		{
			t_launcher *launcher = launcher_load_config(rcfile, i, quicklauncher);
			quicklauncher_add_element(quicklauncher, launcher);
			i--;
			if(!i)
				return TRUE;
		}
	}
	return FALSE;
}
예제 #13
0
static gboolean
xfapplet_save_configuration (XfAppletPlugin *xap)
{
	XfceRc         *config;
	gchar          *path;

	if (!xap->configured)
		return FALSE;

	path = xfce_panel_plugin_lookup_rc_file (xap->plugin);
	if (!path)
		path = xfce_panel_plugin_save_location (xap->plugin, TRUE);

	if (!path)
		return FALSE;

        config = xfce_rc_simple_open (path, FALSE);
	g_free (path);

	if (!config)
		return FALSE;

	xfce_rc_set_group (config, "xfapplet");

	/* iid for matecomponent control */
	xfce_rc_write_entry (config, "iid", xap->iid);

	/* applet name (used in dialog messages) */
	xfce_rc_write_entry (config, "name", xap->name);

	/* mateconf key for applet preferences */
	xfce_rc_write_entry (config, "mateconfkey", xap->mateconf_key);

	xfce_rc_close (config);

	return TRUE;
}
예제 #14
0
static void
migrate_46_plugin_launcher (XfconfChannel  *channel,
                            XfceRc         *rc,
                            guint           plugin_id,
                            GError        **error)
{
  guint      i;
  gchar      buf[128];
  XfceRc    *new_desktop;
  gchar     *path;
  GTimeVal   timeval;
  GPtrArray *array;
  GValue    *value;
  gchar     *filename;

  if (xfce_rc_has_group (rc, "Global"))
    {
      xfce_rc_set_group (rc, "Global");

      migrate_46_plugin_bool ("MoveFirst", "move-first", FALSE);
      migrate_46_plugin_bool ("ArrowPosition", "arrow-position", 0);
    }

  g_get_current_time (&timeval);
  array = g_ptr_array_new ();

  for (i = 0; i < 100 /* arbitrary */; i++)
    {
      g_snprintf (buf, sizeof (buf), "Entry %d", i);
      if (!xfce_rc_has_group (rc, buf))
        break;

      xfce_rc_set_group (rc, buf);

      g_snprintf (buf, sizeof (buf), "heartlenv" G_DIR_SEPARATOR_S "panel"
                  G_DIR_SEPARATOR_S LAUNCHER_FOLDER "-%d" G_DIR_SEPARATOR_S "%ld%d.desktop",
                  plugin_id, timeval.tv_sec, i);
      path = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, buf, TRUE);
      if (G_UNLIKELY (path == NULL))
        {
          g_set_error (error, G_FILE_ERROR_FAILED, G_FILE_ERROR,
                       "Failed to create new launcher desktop file in \"%s\"", buf);
          break;
        }
      else if (g_file_test (path, G_FILE_TEST_EXISTS))
        {
          g_set_error (error, G_FILE_ERROR_EXIST, G_FILE_ERROR,
                       "Deasktop item \"%s\" already exists", path);
          g_free (path);
          break;
        }

      new_desktop = xfce_rc_simple_open (path, FALSE);
      if (G_UNLIKELY (new_desktop == NULL))
        {
          g_set_error (error, G_FILE_ERROR_FAILED, G_FILE_ERROR,
                       "Failed to create new desktop file \"%s\"", path);
          g_free (path);
          break;
        }


      xfce_rc_set_group (new_desktop, G_KEY_FILE_DESKTOP_GROUP);

      xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_TYPE,
          G_KEY_FILE_DESKTOP_TYPE_APPLICATION);
      xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_NAME,
          xfce_rc_read_entry (rc, "Name", ""));
      xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_COMMENT,
          xfce_rc_read_entry (rc, "Comment", ""));
      xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_ICON,
          xfce_rc_read_entry (rc, "Icon", ""));
      xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_EXEC,
          xfce_rc_read_entry (rc, "Exec", ""));
      xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_PATH,
          xfce_rc_read_entry (rc, "Path", ""));
      xfce_rc_write_bool_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_TERMINAL,
          xfce_rc_read_bool_entry (rc, "Terminal", FALSE));
      xfce_rc_write_bool_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY,
          xfce_rc_read_bool_entry (rc, "StartupNotify", FALSE));

      xfce_rc_flush (new_desktop);
      if (xfce_rc_is_dirty (new_desktop))
        {
          g_set_error (error, G_FILE_ERROR_FAILED, G_FILE_ERROR,
                       "Failed to flush desktop file \"%s\"", path);
          g_free (path);
          xfce_rc_close (new_desktop);
          break;
        }

      g_free (path);
      xfce_rc_close (new_desktop);

      value = g_new0 (GValue, 1);
      g_value_init (value, G_TYPE_STRING);
      filename = g_strdup_printf ("%ld%d.desktop", timeval.tv_sec, i);
      g_value_take_string (value, filename);
      g_ptr_array_add (array, value);
    }

  xfconf_channel_set_arrayv (channel, "/items", array);
  xfconf_array_free (array);
}
static const gchar *
xfdesktop_regular_file_icon_peek_tooltip(XfdesktopIcon *icon)
{
    XfdesktopRegularFileIcon *regular_file_icon = XFDESKTOP_REGULAR_FILE_ICON(icon);
    
    if(!regular_file_icon->priv->tooltip) {
        GFileInfo *info = xfdesktop_file_icon_peek_file_info(XFDESKTOP_FILE_ICON(icon));
        const gchar *content_type, *comment = NULL;
        gchar *description, *size_string, *time_string;
        guint64 size, mtime;
        gboolean is_desktop_file = FALSE;

        if(!info)
            return NULL;

        if(g_content_type_equals(g_file_info_get_content_type(info),
                                 "application/x-desktop"))
        {
            is_desktop_file = TRUE;
        }
        else
        {
          gchar *uri = g_file_get_uri(regular_file_icon->priv->file);
          if(g_str_has_suffix(uri, ".desktop"))
              is_desktop_file = TRUE;
          g_free(uri);
        }

        content_type = g_file_info_get_content_type(info);
        description = g_content_type_get_description(content_type);

        size = g_file_info_get_attribute_uint64(info,
                                                G_FILE_ATTRIBUTE_STANDARD_SIZE);

        size_string = g_format_size(size);

        mtime = g_file_info_get_attribute_uint64(info,
                                                 G_FILE_ATTRIBUTE_TIME_MODIFIED);
        time_string = xfdesktop_file_utils_format_time_for_display(mtime);

        regular_file_icon->priv->tooltip =
            g_strdup_printf(_("Type: %s\nSize: %s\nLast modified: %s"),
                            description, size_string, time_string);

        /* Extract the Comment entry from the .desktop file */
        if(is_desktop_file)
        {
            gchar *path = g_file_get_path(regular_file_icon->priv->file);
            XfceRc *rcfile = xfce_rc_simple_open(path, TRUE);
            g_free(path);

            if(rcfile) {
                xfce_rc_set_group(rcfile, "Desktop Entry");
                comment = xfce_rc_read_entry(rcfile, "Comment", NULL);
            }
            /* Prepend the comment to the tooltip */
            if(comment != NULL && *comment != '\0') {
                gchar *tooltip = regular_file_icon->priv->tooltip;
                regular_file_icon->priv->tooltip = g_strdup_printf("%s\n%s",
                                                                   comment,
                                                                   tooltip);
                g_free(tooltip);
            }

            xfce_rc_close(rcfile);
        }

        g_free(time_string);
        g_free(size_string);
        g_free(description);
    }
    
    return regular_file_icon->priv->tooltip;
}
예제 #16
0
static gboolean
thunar_preferences_store_idle (gpointer user_data)
{
  ThunarPreferences *preferences = THUNAR_PREFERENCES (user_data);
  const gchar       *string;
  GParamSpec       **specs;
  GParamSpec        *spec;
  XfceRc            *rc;
  GValue             dst = { 0, };
  GValue             src = { 0, };
  gchar             *option;
  guint              nspecs;
  guint              n;

  rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, "Thunar/thunarrc", FALSE);
  if (G_UNLIKELY (rc == NULL))
    {
      g_warning ("Failed to store thunar preferences.");
      return FALSE;
    }

  /* suspend the monitor (hopefully tricking FAM to avoid unnecessary reloads) */
  thunar_preferences_suspend_monitor (preferences);

  xfce_rc_set_group (rc, "Configuration");

  specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (preferences), &nspecs);
  for (n = 0; n < nspecs; ++n)
    {
      spec = specs[n];

      g_value_init (&dst, G_TYPE_STRING);

      if (spec->value_type == G_TYPE_STRING)
        {
          g_object_get_property (G_OBJECT (preferences), spec->name, &dst);
        }
      else
        {
          g_value_init (&src, spec->value_type);
          g_object_get_property (G_OBJECT (preferences), spec->name, &src);
          g_value_transform (&src, &dst);
          g_value_unset (&src);
        }

      /* determine the option name for the spec */
      option = property_name_to_option_name (spec->name);

      /* store the setting */
      string = g_value_get_string (&dst);
      if (G_LIKELY (string != NULL))
        xfce_rc_write_entry (rc, option, string);

      /* cleanup */
      g_value_unset (&dst);
      g_free (option);
    }

  /* cleanup */
  xfce_rc_close (rc);
  g_free (specs);

  /* restart the monitor */
  thunar_preferences_resume_monitor (preferences);

  return FALSE;
}
예제 #17
0
static gboolean
thunar_preferences_load_idle (gpointer user_data)
{
  ThunarPreferences *preferences = THUNAR_PREFERENCES (user_data);
  const gchar       *string;
  GParamSpec       **specs;
  GParamSpec        *spec;
  XfceRc            *rc;
  GValue             dst = { 0, };
  GValue             src = { 0, };
  gchar             *option;
  guint              nspecs;
  guint              n;

  rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, "Thunar/thunarrc", TRUE);
  if (G_UNLIKELY (rc == NULL))
    {
      g_warning ("Failed to load thunar preferences.");
      return FALSE;
    }

  g_object_freeze_notify (G_OBJECT (preferences));

  xfce_rc_set_group (rc, "Configuration");

  preferences->loading_in_progress = TRUE;

  specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (preferences), &nspecs);
  for (n = 0; n < nspecs; ++n)
    {
      spec = specs[n];

      option = property_name_to_option_name (spec->name);
      string = xfce_rc_read_entry (rc, option, NULL);
      g_free (option);

      if (G_UNLIKELY (string == NULL))
        continue;

      g_value_init (&src, G_TYPE_STRING);
      g_value_set_static_string (&src, string);

      if (spec->value_type == G_TYPE_STRING)
        {
          g_object_set_property (G_OBJECT (preferences), spec->name, &src);
        }
      else if (g_value_type_transformable (G_TYPE_STRING, spec->value_type))
        {
          g_value_init (&dst, spec->value_type);
          if (g_value_transform (&src, &dst))
            g_object_set_property (G_OBJECT (preferences), spec->name, &dst);
          g_value_unset (&dst);
        }
      else
        {
          g_warning ("Failed to load property \"%s\"", spec->name);
        }

      g_value_unset (&src);
    }
  g_free (specs);

  preferences->loading_in_progress = FALSE;

  xfce_rc_close (rc);

  g_object_thaw_notify (G_OBJECT (preferences));

  return FALSE;
}
예제 #18
0
static void
initialize (int argc, char **argv)
{
  gboolean disable_tcp = FALSE;
  GdkDisplay *dpy;
  XfceRc *rc;
  
  for (++argv; --argc > 0; ++argv)
    {
      if (strcmp (*argv, "--version") == 0)
        {
          printf ("%s (Xfce %s)\n\n"
                  "Copyright (c) 2003-2006\n"
                  "        The Xfce development team. All rights reserved.\n\n"
                  "Written for Xfce by Benedikt Meurer <*****@*****.**>.\n\n"
                  "Built with Gtk+-%d.%d.%d, running with Gtk+-%d.%d.%d.\n\n"
                  "Please report bugs to <%s>.\n",
                  PACKAGE_STRING, xfce_version_string (),
                  GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION,
                  gtk_major_version, gtk_minor_version, gtk_micro_version,
                  PACKAGE_BUGREPORT);
          exit (EXIT_SUCCESS);
        }
      else if (strcmp (*argv, "--disable-tcp") == 0)
        {
          disable_tcp = TRUE;
        }
      else
        {
          usage (strcmp (*argv, "--help") == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
        }
    }

  setup_environment ();

  rc = xfsm_open_config (TRUE);

  dpy = gdk_display_get_default ();
  init_display (dpy, rc, disable_tcp);

  /* verify that the DNS settings are ok */
  xfsm_splash_screen_next (splash_screen, _("Verifying DNS settings"));
  xfsm_dns_check ();

  xfsm_splash_screen_next (splash_screen, _("Loading session data"));

  xfce_rc_set_group (rc, "Compatibility");
  compat_gnome = xfce_rc_read_bool_entry (rc, "LaunchGnome", FALSE);
  compat_kde = xfce_rc_read_bool_entry (rc, "LaunchKDE", FALSE);

  xfce_rc_set_group (rc, "General");
  xfsm_startup_init (rc);
  xfsm_manager_init (rc);

  /* cleanup obsolete entries */
  xfce_rc_set_group (rc, "General");
  if (xfce_rc_has_entry (rc, "ConfirmLogout"))
    xfce_rc_delete_entry (rc, "ConfirmLogout", FALSE);
  if (xfce_rc_has_entry (rc, "AlwaysDisplayChooser"))
    xfce_rc_delete_entry (rc, "AlwaysDisplayChooser", FALSE);
  xfce_rc_delete_group (rc, "Splash Theme", FALSE);

  xfce_rc_close (rc);
}
Plugin::Plugin(XfcePanelPlugin *xfce_plugin_)
  : xfce_plugin(xfce_plugin_),

  // Setting defaults
  icon_path("/usr/share/pixmaps/xfce4-hardware-monitor-plugin.png"),
  viewer_type("curve"),
  viewer_font(""),
  viewer_size(96),  // Arbitrary default, see later in this function for notes
  background_color(0x000000FF),  // Black as the night - note that the
                                 // transparency bits need to be set to max to
                                 // ensure the colour is visible
  use_background_color(false),
  next_color(0),
  viewer_text_overlay_enabled(false),
  viewer_text_overlay_format_string("%a %m"),
  viewer_text_overlay_separator(" "),
  viewer_text_overlay_font(""),
  viewer_text_overlay_use_font(false),
  viewer_text_overlay_color(0x000000FF),
  viewer_text_overlay_position(CanvasView::top_left),
  viewer_monitor_type_sync_enabled(true)
{
  // Search for settings file
  XfceRc* settings_ro = NULL;
  gchar* file = xfce_panel_plugin_lookup_rc_file(xfce_plugin);
  
  if (file)
  {
    // One exists - loading settings
    settings_ro = xfce_rc_simple_open(file, true);
    g_free(file);

    // Ensuring default group is in focus
    xfce_rc_set_group(settings_ro, NULL);

    icon_path = xfce_rc_read_entry(settings_ro, "icon-path", icon_path.c_str());
    viewer_type = xfce_rc_read_entry(settings_ro, "viewer_type",
      viewer_type.c_str());
    viewer_size = xfce_rc_read_int_entry(settings_ro, "viewer_size",
      viewer_size);
    viewer_font = xfce_rc_read_entry(settings_ro, "viewer_font",
      viewer_font.c_str());
    background_color = xfce_rc_read_int_entry(settings_ro, "background_color",
      background_color);
    use_background_color = xfce_rc_read_bool_entry(settings_ro,
      "use_background_color", use_background_color);
    next_color = xfce_rc_read_int_entry(settings_ro, "next_color",
      next_color);
    viewer_text_overlay_enabled = xfce_rc_read_bool_entry(settings_ro,
      "viewer_text_overlay_enabled", viewer_text_overlay_enabled);
    viewer_text_overlay_format_string = xfce_rc_read_entry(settings_ro,
      "viewer_text_overlay_format_string",
      viewer_text_overlay_format_string.c_str());
    viewer_text_overlay_separator = xfce_rc_read_entry(settings_ro,
      "viewer_text_overlay_separator", viewer_text_overlay_separator.c_str());
    viewer_text_overlay_font = xfce_rc_read_entry(settings_ro,
      "viewer_text_overlay_font", viewer_text_overlay_font.c_str());
    viewer_text_overlay_color = xfce_rc_read_int_entry(settings_ro,
      "viewer_text_overlay_color", viewer_text_overlay_color);
    viewer_monitor_type_sync_enabled = xfce_rc_read_bool_entry(settings_ro,
      "viewer_monitor_type_sync_enabled", viewer_monitor_type_sync_enabled);

    // Enum is validated in set_viewer_text_overlay_position
    CanvasView::TextOverlayPosition text_overlay_position =
        static_cast<CanvasView::TextOverlayPosition>(
          xfce_rc_read_int_entry(settings_ro, "viewer_text_overlay_position",
                                 CanvasView::top_left));
    set_viewer_text_overlay_position(text_overlay_position);
  }
  
  // Loading icon
  try
  {
    icon = Gdk::Pixbuf::create_from_file(icon_path);
  }
  catch (...)
  {
    std::cerr <<
      String::ucompose(_("Hardware Monitor: cannot load the icon '%1'.\n"),
          icon_path);

    // It's a minor problem if we can't find the icon
    icon = Glib::RefPtr<Gdk::Pixbuf>();
  }

  // Configuring viewer type
  viewer_type_listener(viewer_type);

  /* Actually setting the viewer size has no effect in this function -
   * seems that it needs to be done in or after the mainloop kicks off */

  // Loading up monitors
  /* Plugin& is initialised from non-transient address of this ('this' itself
   * is an rvalue so not allowed for a reference) */
  monitor_seq mon = load_monitors(settings_ro, *this);
  for (monitor_iter i = mon.begin(), end = mon.end(); i != end; ++i)
    add_monitor(*i);

  // All settings loaded
  if (settings_ro)
    xfce_rc_close(settings_ro);

  /* Connect plugin signals to functions - since I'm not really interested
   * in the plugin but the plugin pointer, swapped results in the signal
   * handler getting the plugin reference first - the plugin pointer is
   * passed next, but since the handler only takes one parameter this is
   * discarded
   * Providing About option */
  g_signal_connect_swapped(xfce_plugin, "about", G_CALLBACK(display_about),
    this);

  // Hooking into Properties option
  g_signal_connect_swapped(xfce_plugin, "configure-plugin",
    G_CALLBACK(display_preferences), this);

  // Hooking into plugin destruction signal
  g_signal_connect_swapped(xfce_plugin, "free-data", G_CALLBACK(plugin_free),
    this);

  // Hooking into save signal
  g_signal_connect_swapped(xfce_plugin, "save", G_CALLBACK(save_monitors),
    this);

  /* Not needed as the canvas resizes on the fly
  // Hooking into size changed signal
  g_signal_connect(xfce_plugin, "size-changed", G_CALLBACK(size_changed),
    this);
  */

  // Adding configure and about to the plugin's right-click menu
  xfce_panel_plugin_menu_show_configure(xfce_plugin);
  xfce_panel_plugin_menu_show_about(xfce_plugin);

  /* Add plugin to panel - I need to turn the Plugin (which inherits from
   * Gtk::EventBox) into a GtkWidget* - to do this I get at the GObject
   * pointer underneath the gtkmm layer */
  gtk_container_add(GTK_CONTAINER(xfce_plugin), GTK_WIDGET(this->gobj()));

  // Initialising timer to run every second (by default) to trigger main_loop
  timer =
    Glib::signal_timeout().connect(sigc::mem_fun(*this, &Plugin::main_loop),
      update_interval);

  // Initial main_loop run
  main_loop();
}
예제 #20
0
static void
clipman_read (ClipmanPlugin *clipman)
{
    XfceRc      *rc;
    gchar       *file;
    guint        type, i, clipslen;
    gchar        name[13];
    const gchar *value;
    
    /* Because Clipman is unique, we use 1 config file */
    /*
    file = xfce_panel_plugin_save_location (clipman->plugin, FALSE);
    DBG("Read from file: %s", file);
    */
    
    file = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, "xfce4/panel/clipman.rc", TRUE);

    if (G_UNLIKELY (!file))
        return;
    
    rc = xfce_rc_simple_open (file, FALSE);
    g_free (file);
    
    xfce_rc_set_group (rc, "Properties");
    
    clipman->ExitSave         = xfce_rc_read_bool_entry (rc, "ExitSave",     DEFEXITSAVE);
    clipman->IgnoreSelect     = xfce_rc_read_bool_entry (rc, "IgnoreSelect", DEFIGNORESELECT);
    clipman->PreventEmpty     = xfce_rc_read_bool_entry (rc, "PreventEmpty", DEFPREVENTEMPTY);
    
    switch (xfce_rc_read_int_entry (rc, "Behaviour", DEFBEHAVIOUR))
    {
        case 1:
            clipman->Behaviour = NORMAL;
            DBG ("Behaviour = NORMAL");
            break;
        case 2:
            clipman->Behaviour = STRICTLY;
            DBG ("Behaviour = STRICTLY");
            break;
    }
    
    clipman->ItemNumbers      = xfce_rc_read_bool_entry (rc, "ItemNumbers",    DEFITEMNUMBERS);
    clipman->SeparateMenu     = xfce_rc_read_bool_entry (rc, "SeparateMenu",   DEFSEPMENU);
    
    clipman->HistoryItems     = xfce_rc_read_int_entry  (rc, "HistoryItems",   DEFHISTORY);
    clipman->MenuCharacters   = xfce_rc_read_int_entry  (rc, "MenuCharacters", DEFCHARS);
    
    if (clipman->HistoryItems > MAXHISTORY)
        clipman->HistoryItems = MAXHISTORY;
    if (clipman->HistoryItems < MINHISTORY)
        clipman->HistoryItems = MINHISTORY;
    
    if (clipman->MenuCharacters > MAXCHARS)
        clipman->MenuCharacters = MAXCHARS;
    if (clipman->MenuCharacters < MINCHARS)
        clipman->MenuCharacters = MINCHARS;
    
    xfce_rc_set_group (rc, "Clips");
    clipslen = xfce_rc_read_int_entry (rc, "ClipsLen", 0);
    
    if (clipslen > MAXHISTORY)
        clipslen = MAXHISTORY;
    
    if (clipman->ExitSave && 
        clipslen > 0
       )
    {
        DBG("Restoring the clipboard");
        
        for (i = 0; i < clipslen; ++i)
        {
            g_snprintf (name, 13, "clip_%d_text", i);
            value = xfce_rc_read_entry (rc, name, "");
            
            g_snprintf (name, 13, "clip_%d_from", i);
            type = xfce_rc_read_int_entry (rc, name, 0);
            
            if (type == 0)
                clipman_add_clip (clipman, (gchar *)value, PRIMARY);
            else
                clipman_add_clip (clipman, (gchar *)value, DEFAULT);
        }
    }
    
    xfce_rc_close (rc);
}
예제 #21
0
void
clipman_save (XfcePanelPlugin *plugin,
              ClipmanPlugin   *clipman)
{
    XfceRc      *rc;
    gchar       *file;
    guint        i;
    gchar        name[13];
    ClipmanClip *clip;
    
    DBG("Saving clipman settings");

    file = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, "xfce4/panel/clipman.rc", TRUE);

    if (G_UNLIKELY (!file))
        return;
    
    rc = xfce_rc_simple_open (file, FALSE);
    g_free (file);
    
    /* Save the preferences */
    xfce_rc_set_group (rc, "Properties");
    
    xfce_rc_write_bool_entry (rc, "ExitSave",     clipman->ExitSave);
    xfce_rc_write_bool_entry (rc, "IgnoreSelect", clipman->IgnoreSelect);
    xfce_rc_write_bool_entry (rc, "PreventEmpty", clipman->PreventEmpty);
    
    switch (clipman->Behaviour)
    {
        case NORMAL:
            xfce_rc_write_int_entry (rc, "Behaviour", 1);
            break;
        case STRICTLY:
            xfce_rc_write_int_entry (rc, "Behaviour", 2);
            break;
    }
    
    xfce_rc_write_bool_entry (rc, "ItemNumbers",  clipman->ItemNumbers);
    xfce_rc_write_bool_entry (rc, "SeparateMenu", clipman->SeparateMenu);
    
    xfce_rc_write_int_entry (rc, "HistoryItems",   clipman->HistoryItems);
    xfce_rc_write_int_entry (rc, "MenuCharacters", clipman->MenuCharacters);
    
    /* Remove old content and create a new one */
    xfce_rc_delete_group (rc, "Clips", TRUE );
    
    if (clipman->ExitSave && 
        clipman->clips->len > 0
       )
    {
        DBG("Saving the clipboard history");
        
        xfce_rc_set_group (rc, "Clips");
        xfce_rc_write_int_entry (rc, "ClipsLen", clipman->clips->len);
        
        for (i = 0; i < clipman->clips->len; ++i)
        {
            clip = g_ptr_array_index (clipman->clips, i);
            
            g_snprintf (name, 13, "clip_%d_text", i);
            xfce_rc_write_entry (rc, name, clip->text);
            
            g_snprintf (name, 13, "clip_%d_from", i);
            if (clip->fromtype == PRIMARY)
                xfce_rc_write_int_entry (rc, name, 0);
            else
                xfce_rc_write_int_entry (rc, name, 1);
        }
    }

    xfce_rc_close (rc);
}
예제 #22
0
static XfaeItem*
xfae_item_new (const gchar *relpath)
{
  const gchar   *value;
  XfaeItem      *item = NULL;
  gboolean       skip = FALSE;
  XfceRc        *rc;
  gchar        **only_show_in;
  gchar        **not_show_in;
  gchar        **args;
  gint           m;
  GtkIconTheme  *icon_theme;
  gchar         *command;

  rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, relpath, TRUE);
  if (G_LIKELY (rc != NULL))
    {
      xfce_rc_set_group (rc, "Desktop Entry");

      /* verify that we have an application here */
      value = xfce_rc_read_entry (rc, "Type", NULL);
      if (G_LIKELY (value != NULL
          && g_ascii_strcasecmp (value, "Application") == 0))
        {
          icon_theme = gtk_icon_theme_get_default ();

          item = g_new0 (XfaeItem, 1);
          item->relpath = g_strdup (relpath);

          value = xfce_rc_read_entry (rc, "Name", NULL);
          if (G_LIKELY (value != NULL))
            item->name = g_strdup (value);

          value = xfce_rc_read_entry (rc, "Icon", "application-x-executable");
          if (G_UNLIKELY (value != NULL))
            item->icon = gtk_icon_theme_load_icon (icon_theme, value, 16, GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL);

          value = xfce_rc_read_entry (rc, "Comment", NULL);
          if (G_LIKELY (value != NULL))
            item->comment = g_strdup (value);

          value = xfce_rc_read_entry (rc, "Exec", NULL);
          if (G_LIKELY (value != NULL))
            item->tooltip = g_markup_printf_escaped ("<b>%s</b> %s", _("Command:"), value);

          item->hidden = xfce_rc_read_bool_entry (rc, "Hidden", FALSE);
        }
      else
        {
          return NULL;
        }

      item->show_in_override = xfce_rc_read_bool_entry (rc, "X-XFCE-Autostart-Override", FALSE);

      /* check the NotShowIn setting */
      not_show_in = xfce_rc_read_list_entry (rc, "NotShowIn", ";");
      if (G_UNLIKELY (not_show_in != NULL))
        {
          /* check if "XFCE" is specified */
          for (m = 0; not_show_in[m] != NULL; ++m)
            if (g_ascii_strcasecmp (not_show_in[m], "XFCE") == 0)
              {
                skip = TRUE;
                break;
              }

          g_strfreev (not_show_in);
        }

      /* check the OnlyShowIn setting */
      only_show_in = xfce_rc_read_list_entry (rc, "OnlyShowIn", ";");
      if (G_UNLIKELY (only_show_in != NULL))
        {
          /* check if "XFCE" is specified */
          for (m = 0; only_show_in[m] != NULL; ++m)
            if (g_ascii_strcasecmp (only_show_in[m], "XFCE") == 0)
              {
                item->show_in_xfce = TRUE;
                break;
              }

          g_strfreev (only_show_in);
        }
      else
        {
          /* no OnlyShowIn, treat it like a normal application */
          item->show_in_xfce = TRUE;
        }

      value = xfce_rc_read_entry (rc, "TryExec", NULL);
      if (value != NULL && g_shell_parse_argv (value, NULL, &args, NULL))
        {
          if (!g_file_test (args[0], G_FILE_TEST_EXISTS))
            {
               command = g_find_program_in_path (args[0]);
               if (command == NULL)
                 skip = TRUE;
               g_free (command);
            }

          g_strfreev (args);
        }

      xfce_rc_close (rc);

      /* check if we should skip the item */
      if (G_UNLIKELY (skip))
        {
          xfae_item_free (item);
          item = NULL;
        }
    }

  return item;
}
예제 #23
0
/**
 * xfae_model_add:
 * @model       : a #XfaeModel.
 * @name        : the user visible name of the new item.
 * @description : the description for the new item.
 * @command     : the command for the new item.
 * @error       : return locations for errors or %NULL.
 *
 * Attempts to add a new item with the given parameters
 * to @model.
 *
 * Return value: %TRUE if successfull, else %FALSE.
 **/
gboolean
xfae_model_add (XfaeModel   *model,
                const gchar *name,
                const gchar *description,
                const gchar *command,
                GError     **error)
{
  GtkTreePath *path;
  GtkTreeIter  iter;
  XfaeItem    *item;
  XfceRc      *rc;
  gchar       *file;
  gchar       *dir;
  gchar        relpath[4096];
  guint        n;

  g_return_val_if_fail (XFAE_IS_MODEL (model), FALSE);
  g_return_val_if_fail (name != NULL, FALSE);
  g_return_val_if_fail (description != NULL, FALSE);
  g_return_val_if_fail (command != NULL, FALSE);
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

  dir = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, "autostart/", TRUE);

  /* generate a unique file name */
  for (n = 0;; ++n)
    {
      file = (n == 0)
        ?  g_strdup_printf ("%s.desktop", name)
        : g_strdup_printf ("%s-%u.desktop", name, n);
      file = g_strdelimit (file, G_DIR_SEPARATOR_S, '-'); /* not a copy */

      g_snprintf (relpath, 4096, "%s%s", dir, file);
      if (!g_file_test (relpath, G_FILE_TEST_IS_REGULAR))
        break;

      g_free (file);
    }

  /* generate the file spec */
  g_snprintf (relpath, 4096, "autostart/%s", file);
  g_free (file);
  g_free (dir);

  /* generate the .desktop file */
  rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, relpath, FALSE);
  if (G_UNLIKELY (rc == NULL))
    {
      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (EIO),
                   _("Failed to create file %s"), relpath);
      return FALSE;
    }

  /* write the content */
  xfce_rc_set_group (rc, "Desktop Entry");
  xfce_rc_write_entry (rc, "Encoding", "UTF-8");
  xfce_rc_write_entry (rc, "Version", "0.9.4");
  xfce_rc_write_entry (rc, "Type", "Application");
  xfce_rc_write_entry (rc, "Name", name);
  xfce_rc_write_entry (rc, "Comment", description);
  xfce_rc_write_entry (rc, "Exec", command);
  xfce_rc_write_entry (rc, "OnlyShowIn", "XFCE;");
  xfce_rc_write_bool_entry (rc, "StartupNotify", FALSE);
  xfce_rc_write_bool_entry (rc, "Terminal", FALSE);
  xfce_rc_write_bool_entry (rc, "Hidden", FALSE);
  xfce_rc_close (rc);

  /* now load the matching item for the list */
  item = xfae_item_new (relpath);
  if (G_UNLIKELY (item == NULL))
    {
      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (EIO),
                   _("Failed to write file %s"), relpath);
      return FALSE;
    }

  /* append it to our list */
  model->items = g_list_append (model->items, item);

  /* generate the iter for the newly appended item */
  iter.stamp = model->stamp;
  iter.user_data = g_list_last (model->items);

  /* tell the view about it */
  path = gtk_tree_path_new_from_indices (g_list_length (model->items) - 1, -1);
  gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, &iter);
  gtk_tree_path_free (path);

  return TRUE;
}
예제 #24
0
/**
 * xfae_model_toggle:
 * @model : a #XfaeModel.
 * @iter  : the #GtkTreeIter referring to the item that should be toggled.
 * @error : return location for errors or %NULL.
 *
 * Attempts to toggle the state of the item referrred to by @iter.
 *
 * Return value: %TRUE on success, else %FALSE.
 **/
gboolean
xfae_model_toggle (XfaeModel   *model,
                   GtkTreeIter *iter,
                   GError     **error)
{
  GtkTreePath *path;
  XfaeItem    *item;
  XfceRc      *rc;
  GList       *lp;

  g_return_val_if_fail (XFAE_IS_MODEL (model), FALSE);
  g_return_val_if_fail (iter->stamp == model->stamp, FALSE);
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

  lp = iter->user_data;
  item = lp->data;

  /* try to open the resource config */
  rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, item->relpath, FALSE);
  if (G_UNLIKELY (rc == NULL))
    {
      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (EIO),
                   _("Failed to open %s for writing"), item->relpath);
      return FALSE;
    }

  xfce_rc_set_group (rc, "Desktop Entry");

  if (item->show_in_xfce)
    {
      /* This is an application with no OnlyShowIn categories or with
       * XFCE in it. In this case, toggle the Hidden flag */

      item->hidden = !item->hidden;
      xfce_rc_write_bool_entry (rc, "Hidden", item->hidden);
    }
  else
    {
      /* Normally a non-Xfce autostart application, toggle the override
       * boolean so we don't hide the service in other desktops */

      item->show_in_override = !item->show_in_override;
      xfce_rc_write_bool_entry (rc, "X-XFCE-Autostart-Override", item->show_in_override);

      /* if we override, but the item is still hidden, toggle that as well then */
      if (item->hidden && item->show_in_override)
        {
          item->hidden = !item->hidden;
          xfce_rc_write_bool_entry (rc, "Hidden", item->hidden);
        }
    }

  xfce_rc_close (rc);

  /* tell the view that we have most probably a new state */
  path = gtk_tree_path_new_from_indices (g_list_position (model->items, lp), -1);
  gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, iter);
  gtk_tree_path_free (path);

  return TRUE;
}