static void
matekbd_indicator_config_load_colors (MatekbdIndicatorConfig * ind_config)
{
	GError *gerror = NULL;

	ind_config->foreground_color =
	    mateconf_client_get_string (ind_config->conf_client,
				     MATEKBD_INDICATOR_CONFIG_KEY_FOREGROUND_COLOR,
				     &gerror);
	if (gerror != NULL) {
		g_warning ("Error reading configuration:%s\n",
			   gerror->message);
		g_error_free (gerror);
		gerror = NULL;
	}

	if (ind_config->foreground_color == NULL ||
	    ind_config->foreground_color[0] == '\0') {
		GtkStyle *style =
		    gtk_rc_get_style_by_paths (gtk_settings_get_default (),
					       GTK_STYLE_PATH,
					       GTK_STYLE_PATH,
					       GTK_TYPE_LABEL);
		if (style != NULL) {
			ind_config->foreground_color =
			    g_strdup_printf ("%g %g %g", ((double)
							  style->
							  fg
							  [GTK_STATE_NORMAL].red)
					     / 0x10000, ((double)
							 style->
							 fg
							 [GTK_STATE_NORMAL].green)
					     / 0x10000, ((double)
							 style->
							 fg
							 [GTK_STATE_NORMAL].blue)
					     / 0x10000);
		}

	}

	ind_config->background_color =
	    mateconf_client_get_string (ind_config->conf_client,
				     MATEKBD_INDICATOR_CONFIG_KEY_BACKGROUND_COLOR,
				     &gerror);
	if (gerror != NULL) {
		g_warning ("Error reading configuration:%s\n",
			   gerror->message);
		g_error_free (gerror);
		gerror = NULL;
	}
}
Exemplo n.º 2
0
void
panel_menu_button_load_from_mateconf (PanelWidget *panel,
				   gboolean     locked,
				   int          position,
				   gboolean     exactpos,
				   const char  *id)
{
	MateConfClient *client;
	const char  *key;
	char        *menu_path;
	char        *custom_icon;
	char        *tooltip;
	gboolean     use_menu_path;
	gboolean     use_custom_icon;
	gboolean     has_arrow;

	client  = panel_mateconf_get_client ();

	key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "menu_path");
	menu_path = mateconf_client_get_string (client, key, NULL);

	key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "custom_icon");
	custom_icon = mateconf_client_get_string (client, key, NULL);

	key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "tooltip");
	tooltip = mateconf_client_get_string (client, key, NULL);

	key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "use_menu_path");
	use_menu_path = mateconf_client_get_bool (client, key, NULL);

	key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "use_custom_icon");
	use_custom_icon = mateconf_client_get_bool (client, key, NULL);

	key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "has_arrow");
	has_arrow = mateconf_client_get_bool (client, key, NULL);

	panel_menu_button_load (menu_path,
				use_menu_path,
				custom_icon,
				use_custom_icon,
				tooltip,
				panel,
				locked,
				position,
				exactpos,
				has_arrow,
				id);

	g_free (menu_path);
	g_free (custom_icon);
	g_free (tooltip);
}
void
visual_menu_changed (GtkComboBox *combobox, Idol *idol)
{
	GList *list;
	char *old_name, *name;
	int i;

	i = gtk_combo_box_get_active (combobox);
	list = bacon_video_widget_get_visuals_list (idol->bvw);
	name = g_list_nth_data (list, i);

	old_name = mateconf_client_get_string (idol->gc,
			MATECONF_PREFIX"/visual", NULL);

	if (old_name == NULL || strcmp (old_name, name) != 0)
	{
		mateconf_client_set_string (idol->gc, MATECONF_PREFIX"/visual",
				name, NULL);

		if (bacon_video_widget_set_visuals (idol->bvw, name) != FALSE)
			idol_action_info (_("Changing the visuals effect type will require a restart to take effect."), idol);
	}

	g_free (old_name);
}
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 char *
panel_util_get_file_display_for_common_files (GFile *file)
{
	GFile *compare;

	compare = g_file_new_for_path (g_get_home_dir ());
	if (g_file_equal (file, compare)) {
		char *mateconf_name;

		g_object_unref (compare);

		mateconf_name = mateconf_client_get_string (panel_mateconf_get_client (),
						      HOME_NAME_KEY,
						      NULL);
		if (PANEL_GLIB_STR_EMPTY (mateconf_name)) {
			g_free (mateconf_name);
			return g_strdup (_("Home Folder"));
		} else {
			return mateconf_name;
		}
	}
	g_object_unref (compare);

	compare = g_file_new_for_path ("/");
	if (g_file_equal (file, compare)) {
		g_object_unref (compare);
		/* Translators: this is the same string as the one found in
		 * caja */
		return g_strdup (_("File System"));
	}
	g_object_unref (compare);

	return NULL;
}
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;
}
gchar *
mate_panel_applet_mateconf_get_string (MatePanelApplet  *applet,
			       const gchar  *key,
			       GError      **opt_error)
{
	MateConfClient  *client;
	gchar        *full_key;
	gchar        *retval;
	GError      **error = NULL;
	GError       *our_error = NULL;

	g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);

	if (opt_error)
		error = opt_error;
	else
		error = &our_error;

	full_key = mate_panel_applet_mateconf_get_full_key (applet, key);

	client = mate_panel_applet_mateconf_get_client ();

	retval = mateconf_client_get_string (client, full_key, error);

	g_free (full_key);

	if (!opt_error && our_error) {
		g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message);
		g_error_free (our_error);
	}

	return retval;
}
Exemplo n.º 8
0
gunichar
mcharmap_settings_get_last_char (void)
{
  /* See bug 469053 */
  gchar *str, *endptr;
  guint64 value;

  if (!mcharmap_settings_initialized ()) {
      return mcharmap_unicode_get_locale_character ();
  }

  str = mateconf_client_get_string (client, MATECONF_PREFIX"/last_char", NULL);
  if (!str || !g_str_has_prefix (str, "U+")) {
    g_free (str);
    return mcharmap_unicode_get_locale_character  ();
  }

  endptr = NULL;
  errno = 0;
  value = g_ascii_strtoull (str + 2 /* skip the "U+" */, &endptr, 16);
  if (errno || endptr == str || value > UNICHAR_MAX) {
    g_free (str);
    return mcharmap_unicode_get_locale_character  ();
  }

  g_free (str);

  return (gunichar) value;
}
Exemplo n.º 9
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);
}
static void
matekbd_indicator_config_load_font (MatekbdIndicatorConfig * ind_config)
{
	GError *gerror = NULL;

	ind_config->font_family =
	    mateconf_client_get_string (ind_config->conf_client,
				     MATEKBD_INDICATOR_CONFIG_KEY_FONT_FAMILY,
				     &gerror);
	if (gerror != NULL) {
		g_warning ("Error reading configuration:%s\n",
			   gerror->message);
		ind_config->font_family = g_strdup ("Helvetica");
		g_error_free (gerror);
		gerror = NULL;
	}

	ind_config->font_size =
	    mateconf_client_get_int (ind_config->conf_client,
				  MATEKBD_INDICATOR_CONFIG_KEY_FONT_SIZE,
				  &gerror);
	if (gerror != NULL) {
		g_warning ("Error reading configuration:%s\n",
			   gerror->message);
		ind_config->font_size = 10;
		g_error_free (gerror);
		gerror = NULL;
	}

	if (ind_config->font_family == NULL ||
	    ind_config->font_family[0] == '\0') {
		PangoFontDescription *fd = NULL;
		GtkStyle *style =
		    gtk_rc_get_style_by_paths (gtk_settings_get_default (),
					       GTK_STYLE_PATH,
					       GTK_STYLE_PATH,
					       GTK_TYPE_LABEL);
		if (style != NULL)
			fd = style->font_desc;
		if (fd != NULL) {
			ind_config->font_family =
			    g_strdup (pango_font_description_get_family
				      (fd));
			ind_config->font_size =
			    pango_font_description_get_size (fd) /
			    PANGO_SCALE;
		}
	}
	xkl_debug (150, "font: [%s], size %d\n", ind_config->font_family,
		   ind_config->font_size);

}
/*
 * 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;
}
Exemplo n.º 12
0
void
idol_preferences_visuals_setup (Idol *idol)
{
	char *visual;

	visual = mateconf_client_get_string (idol->gc,
			MATECONF_PREFIX"/visual", NULL);
	if (visual == NULL || strcmp (visual, "") == 0) {
		g_free (visual);
		visual = g_strdup ("goom");
	}

	bacon_video_widget_set_visuals (idol->bvw, visual);
	g_free (visual);
}
Exemplo n.º 13
0
gchar *
mcharmap_settings_get_font (void)
{
  char *font;

  if (!mcharmap_settings_initialized ()) {
      return get_default_font ();
  }
  
  font = mateconf_client_get_string (client, MATECONF_PREFIX"/font", NULL);
  if (!font || !font[0]) {
    g_free (font);
    return NULL;
  }

  return font;
}
/* Create a GtkLabel inside a frame, that we can "configure"
 * (the label displays the value of the config key).
 */
static GtkWidget*
create_configurable_widget (MateConfClient *client,
                            const gchar *config_key)
{
  GtkWidget *frame;
  GtkWidget *label;
  guint notify_id;
  gchar *str;

  str = g_strdup_printf ("Value of \"%s\"", config_key);
  frame = gtk_frame_new (str);
  g_free (str);
  
  label = gtk_label_new ("");

  gtk_container_add (GTK_CONTAINER (frame), label);
  
  str = mateconf_client_get_string (client, config_key, NULL);

  if (str != NULL)
    {
      gtk_label_set_text (GTK_LABEL (label), str);
      g_free (str);
    }

  notify_id = mateconf_client_notify_add (client,
                                       config_key,
                                       configurable_widget_config_notify,
                                       label,
                                       NULL, NULL);

  /* Note that notify_id will be 0 if there was an error,
   * so we handle that in our destroy callback.
   */
  
  g_object_set_data (G_OBJECT (label), "notify_id", GUINT_TO_POINTER (notify_id));
  g_object_set_data (G_OBJECT (label), "client", client);

  g_signal_connect (G_OBJECT (label), "destroy",
                    G_CALLBACK (configurable_widget_destroy_callback),
                    NULL);
  
  return frame;
}
Exemplo n.º 15
0
McharmapChaptersMode
mcharmap_settings_get_chapters_mode (void)
{
  McharmapChaptersMode ret;
  gchar *mode;
  
  mode = mateconf_client_get_string (client, MATECONF_PREFIX"/chapters_mode", NULL);
  if (mode == NULL)
    return get_default_chapters_mode ();

  if (strcmp (mode, "script") == 0)
    ret = MCHARMAP_CHAPTERS_SCRIPT;
  else if (strcmp (mode, "block") == 0)
    ret = MCHARMAP_CHAPTERS_BLOCK;
  else
    ret = get_default_chapters_mode ();

  g_free (mode);
  return ret;
}
static MateThemeMetaInfo *
theme_load_from_mateconf (MateConfClient *client)
{
  MateThemeMetaInfo *theme;
  gchar *scheme;

  theme = mate_theme_meta_info_new ();

  theme->gtk_theme_name = mateconf_client_get_string (client, GTK_THEME_KEY, NULL);
  if (theme->gtk_theme_name == NULL)
    theme->gtk_theme_name = g_strdup ("Clearlooks");

  scheme = mateconf_client_get_string (client, COLOR_SCHEME_KEY, NULL);
  if (scheme == NULL || !strcmp (scheme, "")) {
    g_free (scheme);
    scheme = gtkrc_get_color_scheme_for_theme (theme->gtk_theme_name);
  }
  theme->gtk_color_scheme = scheme;

  theme->marco_theme_name = mateconf_client_get_string (client, MARCO_THEME_KEY, NULL);
  if (theme->marco_theme_name == NULL)
    theme->marco_theme_name = g_strdup ("Clearlooks");

  theme->icon_theme_name = mateconf_client_get_string (client, ICON_THEME_KEY, NULL);
  if (theme->icon_theme_name == NULL)
    theme->icon_theme_name = g_strdup ("mate");

  theme->notification_theme_name = mateconf_client_get_string (client, NOTIFICATION_THEME_KEY, NULL);

  theme->cursor_theme_name = mateconf_client_get_string (client, CURSOR_THEME_KEY, NULL);
#ifdef HAVE_XCURSOR
  theme->cursor_size = mateconf_client_get_int (client, CURSOR_SIZE_KEY, NULL);
#endif
  if (theme->cursor_theme_name == NULL)
    theme->cursor_theme_name = g_strdup ("default");

  theme->application_font = mateconf_client_get_string (client, APPLICATION_FONT_KEY, NULL);

  return theme;
}
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;
}
/**
 * mate_prepend_terminal_to_vector:
 * @argc: a pointer to the vector size
 * @argv: a pointer to the vector
 *
 * Description:  Prepends a terminal (either the one configured as default in
 * the user's MATE setup, or one of the common xterm emulators) to the passed
 * in vector, modifying it in the process.  The vector should be allocated with
 * #g_malloc, as this will #g_free the original vector.  Also all elements must
 * have been allocated separately.  That is the standard glib/MATE way of
 * doing vectors however.  If the integer that @argc points to is negative, the
 * size will first be computed.  Also note that passing in pointers to a vector
 * that is empty, will just create a new vector for you.
 **/
void mate_prepend_terminal_to_vector(int* argc, char*** argv)
{
	#ifndef G_OS_WIN32
		char** real_argv;
		int real_argc;
		int i, j;
		char** term_argv = NULL;
		int term_argc = 0;
		MateConfClient* client;

		gchar* terminal = NULL;

		char** the_argv;

		g_return_if_fail(argc != NULL);
		g_return_if_fail(argv != NULL);

		/* sanity */
		if (*argv == NULL)
			*argc = 0;

		the_argv = *argv;

		/* compute size if not given */
		if (*argc < 0)
		{
			for (i = 0; the_argv[i] != NULL; i++)
				/* nothing */;

			*argc = i;
		}

		/* init our mateconf stuff if necessary */
		mate_mateconf_lazy_init();

		client = mateconf_client_get_default();
		terminal = mateconf_client_get_string(client, "/desktop/mate/applications/terminal/exec", NULL);
		g_object_unref(client);

		if (terminal)
		{
			gchar* command_line;
			gchar* exec_flag;

			exec_flag = mateconf_client_get_string(client, "/desktop/mate/applications/terminal/exec_arg", NULL);

			if (exec_flag == NULL)
				command_line = g_strdup(terminal);
			else
				command_line = g_strdup_printf("%s %s", terminal, exec_flag);

			g_shell_parse_argv(command_line, &term_argc, &term_argv, NULL /* error */);

			g_free(command_line);
			g_free(exec_flag);
			g_free(terminal);
		}

		if (term_argv == NULL)
		{
			char* check;

			term_argc = 2;
			term_argv = g_new0(char*, 3);

			check = g_find_program_in_path("mate-terminal");

			if (check != NULL)
			{
				term_argv[0] = check;
				/* Note that mate-terminal takes -x and
				 * as -e in mate-terminal is broken we use that. */
				term_argv[1] = g_strdup("-x");
			}
			else
			{
				if (check == NULL)
					check = g_find_program_in_path("nxterm");
				if (check == NULL)
					check = g_find_program_in_path("color-xterm");
				if (check == NULL)
					check = g_find_program_in_path("rxvt");
				if (check == NULL)
					check = g_find_program_in_path("xterm");
				if (check == NULL)
					check = g_find_program_in_path("dtterm");
				if (check == NULL)
				{
					g_warning(_("Cannot find a terminal, using xterm, even if it may not work"));
					check = g_strdup("xterm");
				}

				term_argv[0] = check;
				term_argv[1] = g_strdup("-e");
			}
		}
static void
theme_message_area_response_cb (GtkWidget *w,
                                gint response_id,
                                AppearanceData *data)
{
  const MateThemeMetaInfo *theme;
  gchar *tmpfont;
  gchar *engine_path;

  theme = theme_get_selected (GTK_ICON_VIEW (appearance_capplet_get_widget (data, "theme_list")), data);
  if (!theme)
    return;

  switch (response_id)
  {
    case RESPONSE_APPLY_BG:
      mateconf_client_set_string (data->client, BACKGROUND_KEY,
                               theme->background_image, NULL);
      break;

    case RESPONSE_REVERT_FONT:
      if (data->revert_application_font != NULL) {
        mateconf_client_set_string (data->client, APPLICATION_FONT_KEY,
                                 data->revert_application_font, NULL);
        g_free (data->revert_application_font);
        data->revert_application_font = NULL;
      }

      if (data->revert_documents_font != NULL) {
        mateconf_client_set_string (data->client, DOCUMENTS_FONT_KEY,
                                 data->revert_documents_font, NULL);
        g_free (data->revert_documents_font);
        data->revert_documents_font = NULL;
      }

      if (data->revert_desktop_font != NULL) {
        mateconf_client_set_string (data->client, DESKTOP_FONT_KEY,
                                 data->revert_desktop_font, NULL);
        g_free (data->revert_desktop_font);
        data->revert_desktop_font = NULL;
      }

      if (data->revert_windowtitle_font != NULL) {
        mateconf_client_set_string (data->client, WINDOWTITLE_FONT_KEY,
                                 data->revert_windowtitle_font, NULL);
        g_free (data->revert_windowtitle_font);
        data->revert_windowtitle_font = NULL;
      }

      if (data->revert_monospace_font != NULL) {
        mateconf_client_set_string (data->client, MONOSPACE_FONT_KEY,
                                 data->revert_monospace_font, NULL);
        g_free (data->revert_monospace_font);
        data->revert_monospace_font = NULL;
      }
      break;

    case RESPONSE_APPLY_FONT:
      if (theme->application_font) {
        tmpfont = mateconf_client_get_string (data->client, APPLICATION_FONT_KEY, NULL);
        if (tmpfont != NULL) {
          g_free (data->revert_application_font);

          if (strcmp (theme->application_font, tmpfont) == 0) {
            g_free (tmpfont);
            data->revert_application_font = NULL;
          } else
            data->revert_application_font = tmpfont;
        }
        mateconf_client_set_string (data->client, APPLICATION_FONT_KEY,
                                 theme->application_font, NULL);
      }

      if (theme->documents_font) {
        tmpfont = mateconf_client_get_string (data->client, DOCUMENTS_FONT_KEY, NULL);
        if (tmpfont != NULL) {
          g_free (data->revert_documents_font);

          if (strcmp (theme->documents_font, tmpfont) == 0) {
            g_free (tmpfont);
            data->revert_documents_font = NULL;
          } else
            data->revert_documents_font = tmpfont;
        }
        mateconf_client_set_string (data->client, DOCUMENTS_FONT_KEY,
                                 theme->documents_font, NULL);
      }

      if (theme->desktop_font) {
        tmpfont = mateconf_client_get_string (data->client, DESKTOP_FONT_KEY, NULL);
        if (tmpfont != NULL) {
          g_free (data->revert_desktop_font);

          if (strcmp (theme->desktop_font, tmpfont) == 0) {
            g_free (tmpfont);
            data->revert_desktop_font = NULL;
          } else
            data->revert_desktop_font = tmpfont;
        }
        mateconf_client_set_string (data->client, DESKTOP_FONT_KEY,
                                 theme->desktop_font, NULL);
      }

      if (theme->windowtitle_font) {
        tmpfont = mateconf_client_get_string (data->client, WINDOWTITLE_FONT_KEY, NULL);
        if (tmpfont != NULL) {
          g_free (data->revert_windowtitle_font);

          if (strcmp (theme->windowtitle_font, tmpfont) == 0) {
            g_free (tmpfont);
            data->revert_windowtitle_font = NULL;
          } else
            data->revert_windowtitle_font = tmpfont;
        }
        mateconf_client_set_string (data->client, WINDOWTITLE_FONT_KEY,
                                 theme->windowtitle_font, NULL);
      }

      if (theme->monospace_font) {
        tmpfont = mateconf_client_get_string (data->client, MONOSPACE_FONT_KEY, NULL);
        if (tmpfont != NULL) {
          g_free (data->revert_monospace_font);

          if (strcmp (theme->monospace_font, tmpfont) == 0) {
            g_free (tmpfont);
            data->revert_monospace_font = NULL;
          } else
            data->revert_monospace_font = tmpfont;
        }
        mateconf_client_set_string (data->client, MONOSPACE_FONT_KEY,
                                 theme->monospace_font, NULL);
      }
      break;

		case RESPONSE_INSTALL_ENGINE:

			engine_path = gtk_theme_info_missing_engine(theme->gtk_theme_name, FALSE);

			if (engine_path != NULL)
			{
				theme_install_file(GTK_WINDOW(gtk_widget_get_toplevel(data->install_button)), engine_path);
				g_free (engine_path);
			}

			theme_message_area_update(data);
			break;
	}
}
Exemplo n.º 20
0
static char
*get_all_applets (void)
{
	MateConfClient *client;
	GError *error;
	GSList *list, *l;
	char *key, *oafiid, *name;
	GHashTable *hash_table;
	GString *string;

	error = NULL;
	hash_table = g_hash_table_new (g_str_hash, g_str_equal);
	insert_oafiids (hash_table);

	string = g_string_new ("");

	client = mateconf_client_get_default ();

	mateconf_client_suggest_sync (client, NULL);
	
	list = mateconf_client_all_dirs (client,
		"/apps/panel/applets",
		&error);

	if (error)
	{
		g_warning ("Error: %s", error->message);
		g_error_free (error);
		error = NULL;
	}

	for (l = list; l; l = l->next)
	{
	    key = g_strdup_printf ("%s/matecomponent_iid", (gchar *)l->data);
		oafiid = mateconf_client_get_string (client, key, &error);
		if (error)
		{
			g_warning ("Error: %s", error->message);
			g_error_free (error);
			error = NULL;
		}
		g_free (key);
	
		if (oafiid)
		{
			name = g_hash_table_lookup (hash_table, oafiid);
			if (name)
			{
				mateconf_client_recursive_unset (client, l->data,
					MATECONF_UNSET_INCLUDING_SCHEMA_NAMES,
					&error);
				if (error)
				{
					g_warning ("Error: %s", error->message);
					g_error_free (error);
					error = NULL;
				}
				g_string_append_printf (string,
						"    • %s\n", name);
			}
			g_free (oafiid);
		}
		g_free (l->data);
	}

	g_slist_free (list);
	g_hash_table_destroy (hash_table);
	
	return g_string_free (string, FALSE);
}
void themes_init(AppearanceData* data)
{
  GtkWidget *w, *del_button;
  GList *theme_list, *l;
  GtkListStore *theme_store;
  GtkTreeModel *sort_model;
  MateThemeMetaInfo *meta_theme = NULL;
  GtkIconView *icon_view;
  GtkCellRenderer *renderer;
  GtkSettings *settings;
  char *url;

  /* initialise some stuff */
  mate_theme_init ();
  mate_wm_manager_init ();

  data->revert_application_font = NULL;
  data->revert_documents_font = NULL;
  data->revert_desktop_font = NULL;
  data->revert_windowtitle_font = NULL;
  data->revert_monospace_font = NULL;
  data->theme_save_dialog = NULL;
  data->theme_message_area = NULL;
  data->theme_info_icon = NULL;
  data->theme_error_icon = NULL;
  data->theme_custom = mate_theme_meta_info_new ();
  data->theme_icon = gdk_pixbuf_new_from_file (MATECC_PIXMAP_DIR "/theme-thumbnailing.png", NULL);
  data->theme_store = theme_store =
      gtk_list_store_new (NUM_COLS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);

  /* set up theme list */
  theme_list = mate_theme_meta_info_find_all ();
  mate_theme_info_register_theme_change ((ThemeChangedCallback) theme_changed_on_disk_cb, data);

  data->theme_custom = theme_load_from_mateconf (data->client);
  data->theme_custom->name = g_strdup (CUSTOM_THEME_NAME);
  data->theme_custom->readable_name = g_strdup_printf ("<i>%s</i>", _("Custom"));

  for (l = theme_list; l; l = l->next) {
    MateThemeMetaInfo *info = l->data;

    gtk_list_store_insert_with_values (theme_store, NULL, 0,
        COL_LABEL, info->readable_name,
        COL_NAME, info->name,
        COL_THUMBNAIL, data->theme_icon,
        -1);

    if (!meta_theme && theme_is_equal (data->theme_custom, info))
      meta_theme = info;
  }

  if (!meta_theme) {
    /* add custom theme */
    meta_theme = data->theme_custom;

    gtk_list_store_insert_with_values (theme_store, NULL, 0,
        COL_LABEL, meta_theme->readable_name,
        COL_NAME, meta_theme->name,
        COL_THUMBNAIL, data->theme_icon,
        -1);

    theme_thumbnail_generate (meta_theme, data);
  }

  theme_list = g_list_sort (theme_list, (GCompareFunc) theme_list_sort_func);

  g_list_foreach (theme_list, (GFunc) theme_thumbnail_generate, data);
  g_list_free (theme_list);

  icon_view = GTK_ICON_VIEW (appearance_capplet_get_widget (data, "theme_list"));

  renderer = gtk_cell_renderer_pixbuf_new ();
  g_object_set (renderer, "xpad", 5, "ypad", 5,
                          "xalign", 0.5, "yalign", 1.0, NULL);
  gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (icon_view), renderer, FALSE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (icon_view), renderer,
                                  "pixbuf", COL_THUMBNAIL, NULL);

  renderer = gtk_cell_renderer_text_new ();
  g_object_set (renderer, "alignment", PANGO_ALIGN_CENTER,
			  "wrap-mode", PANGO_WRAP_WORD_CHAR,
			  "wrap-width", gtk_icon_view_get_item_width (icon_view),
			  "width", gtk_icon_view_get_item_width (icon_view),
			  "xalign", 0.0, "yalign", 0.0, NULL);
  gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (icon_view), renderer, FALSE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (icon_view), renderer,
                                  "markup", COL_LABEL, NULL);

  sort_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (theme_store));
  gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (sort_model), COL_LABEL, theme_store_sort_func, NULL, NULL);
  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model), COL_LABEL, GTK_SORT_ASCENDING);
  gtk_icon_view_set_model (icon_view, GTK_TREE_MODEL (sort_model));

  g_signal_connect (icon_view, "selection-changed", (GCallback) theme_selection_changed_cb, data);
  g_signal_connect_after (icon_view, "realize", (GCallback) theme_select_name, meta_theme->name);

  w = appearance_capplet_get_widget (data, "theme_install");
  gtk_button_set_image (GTK_BUTTON (w),
                        gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON));
  g_signal_connect (w, "clicked", (GCallback) theme_install_cb, data);

  w = appearance_capplet_get_widget (data, "theme_save");
  gtk_button_set_image (GTK_BUTTON (w),
                        gtk_image_new_from_stock (GTK_STOCK_SAVE_AS, GTK_ICON_SIZE_BUTTON));
  g_signal_connect (w, "clicked", (GCallback) theme_save_cb, data);

  w = appearance_capplet_get_widget (data, "theme_custom");
  gtk_button_set_image (GTK_BUTTON (w),
                        gtk_image_new_from_stock (GTK_STOCK_EDIT, GTK_ICON_SIZE_BUTTON));
  g_signal_connect (w, "clicked", (GCallback) theme_custom_cb, data);

  del_button = appearance_capplet_get_widget (data, "theme_delete");
  g_signal_connect (del_button, "clicked", (GCallback) theme_delete_cb, data);

  w = appearance_capplet_get_widget (data, "theme_vbox");
  gtk_drag_dest_set (w, GTK_DEST_DEFAULT_ALL,
		     drop_types, G_N_ELEMENTS (drop_types),
		     GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_MOVE);
  g_signal_connect (w, "drag-data-received", (GCallback) theme_drag_data_received_cb, data);
  if (is_locked_down (data->client))
    gtk_widget_set_sensitive (w, FALSE);

  w = appearance_capplet_get_widget (data, "more_themes_linkbutton");
  url = mateconf_client_get_string (data->client, MORE_THEMES_URL_KEY, NULL);
  if (url != NULL && url[0] != '\0') {
    gtk_link_button_set_uri (GTK_LINK_BUTTON (w), url);
    gtk_widget_show (w);
  } else {
    gtk_widget_hide (w);
  }
  g_free (url);

  /* listen to mateconf changes, too */
  mateconf_client_add_dir (data->client, "/apps/marco/general", MATECONF_CLIENT_PRELOAD_NONE, NULL);
  mateconf_client_add_dir (data->client, "/desktop/mate/interface", MATECONF_CLIENT_PRELOAD_NONE, NULL);
  mateconf_client_notify_add (data->client, MARCO_THEME_KEY, (MateConfClientNotifyFunc) theme_mateconf_changed, data, NULL, NULL);
  mateconf_client_notify_add (data->client, CURSOR_THEME_KEY, (MateConfClientNotifyFunc) theme_mateconf_changed, data, NULL, NULL);
#ifdef HAVE_XCURSOR
  mateconf_client_notify_add (data->client, CURSOR_SIZE_KEY, (MateConfClientNotifyFunc) theme_mateconf_changed, data, NULL, NULL);
#endif
  mateconf_client_notify_add (data->client, BACKGROUND_KEY, (MateConfClientNotifyFunc) background_or_font_changed, data, NULL, NULL);
  mateconf_client_notify_add (data->client, APPLICATION_FONT_KEY, (MateConfClientNotifyFunc) background_or_font_changed, data, NULL, NULL);
  mateconf_client_notify_add (data->client, DOCUMENTS_FONT_KEY, (MateConfClientNotifyFunc) background_or_font_changed, data, NULL, NULL);
  mateconf_client_notify_add (data->client, DESKTOP_FONT_KEY, (MateConfClientNotifyFunc) background_or_font_changed, data, NULL, NULL);
  mateconf_client_notify_add (data->client, WINDOWTITLE_FONT_KEY, (MateConfClientNotifyFunc) background_or_font_changed, data, NULL, NULL);
  mateconf_client_notify_add (data->client, MONOSPACE_FONT_KEY, (MateConfClientNotifyFunc) background_or_font_changed, data, NULL, NULL);

  settings = gtk_settings_get_default ();
  g_signal_connect (settings, "notify::gtk-color-scheme", (GCallback) theme_setting_changed_cb, data);
  g_signal_connect (settings, "notify::gtk-theme-name", (GCallback) theme_setting_changed_cb, data);
  g_signal_connect (settings, "notify::gtk-icon-theme-name", (GCallback) theme_setting_changed_cb, data);

  /* monitor individual font choice buttons, so
     "revert font" option (if any) can be cleared */
  w = appearance_capplet_get_widget (data, "application_font");
  g_signal_connect (w, "font_set", (GCallback) custom_font_cb, data);
  w = appearance_capplet_get_widget (data, "document_font");
  g_signal_connect (w, "font_set", (GCallback) custom_font_cb, data);
  w = appearance_capplet_get_widget (data, "desktop_font");
  g_signal_connect (w, "font_set", (GCallback) custom_font_cb, data);
  w = appearance_capplet_get_widget (data, "window_title_font");
  g_signal_connect (w, "font_set", (GCallback) custom_font_cb, data);
  w = appearance_capplet_get_widget (data, "monospace_font");
  g_signal_connect (w, "font_set", (GCallback) custom_font_cb, data);
}
static void
theme_message_area_update (AppearanceData *data)
{
  const MateThemeMetaInfo *theme;
  gboolean show_apply_background = FALSE;
  gboolean show_apply_font = FALSE;
  gboolean show_revert_font = FALSE;
  gboolean show_error;
  const gchar *message;
  gchar *font;
  GError *error = NULL;

  theme = theme_get_selected (GTK_ICON_VIEW (appearance_capplet_get_widget (data, "theme_list")), data);

  if (!theme) {
    if (data->theme_message_area != NULL)
      gtk_widget_hide (data->theme_message_area);
    return;
  }

  show_error = !mate_theme_meta_info_validate (theme, &error);

  if (!show_error) {
    if (theme->background_image != NULL) {
      gchar *background;

      background = mateconf_client_get_string (data->client, BACKGROUND_KEY, NULL);
      show_apply_background =
          (!background || strcmp (theme->background_image, background) != 0);
      g_free (background);
    }

    if (theme->application_font) {
      font = mateconf_client_get_string (data->client, APPLICATION_FONT_KEY, NULL);
      show_apply_font =
          (!font || strcmp (theme->application_font, font) != 0);
      g_free (font);
    }

    if (!show_apply_font && theme->documents_font) {
      font = mateconf_client_get_string (data->client, DOCUMENTS_FONT_KEY, NULL);
      show_apply_font =
          (!font || strcmp (theme->application_font, font) != 0);
      g_free (font);
    }

    if (!show_apply_font && theme->desktop_font) {
      font = mateconf_client_get_string (data->client, DESKTOP_FONT_KEY, NULL);
      show_apply_font =
          (!font || strcmp (theme->application_font, font) != 0);
      g_free (font);
    }

    if (!show_apply_font && theme->windowtitle_font) {
      font = mateconf_client_get_string (data->client, WINDOWTITLE_FONT_KEY, NULL);
      show_apply_font =
          (!font || strcmp (theme->application_font, font) != 0);
      g_free (font);
    }

    if (!show_apply_font && theme->monospace_font) {
      font = mateconf_client_get_string (data->client, MONOSPACE_FONT_KEY, NULL);
      show_apply_font =
          (!font || strcmp (theme->application_font, font) != 0);
      g_free (font);
    }

    show_revert_font = (data->revert_application_font != NULL ||
      data->revert_documents_font != NULL || data->revert_desktop_font != NULL ||
      data->revert_windowtitle_font != NULL || data->revert_monospace_font != NULL);
  }

  if (data->theme_message_area == NULL) {
    GtkWidget *hbox;
    GtkWidget *parent;
    GtkWidget *content;

    if (!show_apply_background && !show_revert_font && !show_apply_font && !show_error)
      return;

    data->theme_message_area = gtk_info_bar_new ();
    gtk_widget_set_no_show_all (data->theme_message_area, TRUE);

    g_signal_connect (data->theme_message_area, "response",
                      (GCallback) theme_message_area_response_cb, data);

    data->apply_background_button = gtk_info_bar_add_button (
        GTK_INFO_BAR (data->theme_message_area),
        _("Apply Background"),
        RESPONSE_APPLY_BG);
    data->apply_font_button = gtk_info_bar_add_button (
        GTK_INFO_BAR (data->theme_message_area),
        _("Apply Font"),
        RESPONSE_APPLY_FONT);
    data->revert_font_button = gtk_info_bar_add_button (
        GTK_INFO_BAR (data->theme_message_area),
        _("Revert Font"),
        RESPONSE_REVERT_FONT);
    data->install_button = gtk_info_bar_add_button (
        GTK_INFO_BAR (data->theme_message_area),
        _("Install"),
        RESPONSE_INSTALL_ENGINE);

    data->theme_message_label = gtk_label_new (NULL);
    gtk_widget_show (data->theme_message_label);
    gtk_label_set_line_wrap (GTK_LABEL (data->theme_message_label), TRUE);
    gtk_misc_set_alignment (GTK_MISC (data->theme_message_label), 0.0, 0.5);

    hbox = gtk_hbox_new (FALSE, 9);
    gtk_widget_show (hbox);
    data->theme_info_icon = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
    data->theme_error_icon = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
    gtk_misc_set_alignment (GTK_MISC (data->theme_info_icon), 0.5, 0);
    gtk_misc_set_alignment (GTK_MISC (data->theme_error_icon), 0.5, 0);
    gtk_box_pack_start (GTK_BOX (hbox), data->theme_info_icon, FALSE, FALSE, 0);
    gtk_box_pack_start (GTK_BOX (hbox), data->theme_error_icon, FALSE, FALSE, 0);
    gtk_box_pack_start (GTK_BOX (hbox), data->theme_message_label, TRUE, TRUE, 0);
    content = gtk_info_bar_get_content_area (GTK_INFO_BAR (data->theme_message_area));
    gtk_container_add (GTK_CONTAINER (content), hbox);

    parent = appearance_capplet_get_widget (data, "theme_list_vbox");
    gtk_box_pack_start (GTK_BOX (parent), data->theme_message_area, FALSE, FALSE, 0);
  }

  if (show_error)
    message = error->message;
  else if (show_apply_background && show_apply_font && show_revert_font)
    message = _("The current theme suggests a background and a font. Also, the last applied font suggestion can be reverted.");
  else if (show_apply_background && show_revert_font)
    message = _("The current theme suggests a background. Also, the last applied font suggestion can be reverted.");
  else if (show_apply_background && show_apply_font)
    message = _("The current theme suggests a background and a font.");
  else if (show_apply_font && show_revert_font)
    message = _("The current theme suggests a font. Also, the last applied font suggestion can be reverted.");
  else if (show_apply_background)
    message = _("The current theme suggests a background.");
  else if (show_revert_font)
    message = _("The last applied font suggestion can be reverted.");
  else if (show_apply_font)
    message = _("The current theme suggests a font.");
  else
    message = NULL;

  if (show_apply_background)
    gtk_widget_show (data->apply_background_button);
  else
    gtk_widget_hide (data->apply_background_button);

  if (show_apply_font)
    gtk_widget_show (data->apply_font_button);
  else
    gtk_widget_hide (data->apply_font_button);

  if (show_revert_font)
    gtk_widget_show (data->revert_font_button);
  else
    gtk_widget_hide (data->revert_font_button);

  if (show_error
      && g_error_matches (error, MATE_THEME_ERROR, MATE_THEME_ERROR_GTK_ENGINE_NOT_AVAILABLE)
      && packagekit_available ())
    gtk_widget_show (data->install_button);
  else
    gtk_widget_hide (data->install_button);

  if (show_error || show_apply_background || show_apply_font || show_revert_font) {
    gtk_widget_show (data->theme_message_area);
    gtk_widget_queue_draw (data->theme_message_area);

    if (show_error) {
      gtk_widget_show (data->theme_error_icon);
      gtk_widget_hide (data->theme_info_icon);
    } else {
      gtk_widget_show (data->theme_info_icon);
      gtk_widget_hide (data->theme_error_icon);
    }
  } else {
    gtk_widget_hide (data->theme_message_area);
  }

  gtk_label_set_text (GTK_LABEL (data->theme_message_label), message);
  g_clear_error (&error);
}
/* Create an entry used to edit the given config key */
static GtkWidget*
create_config_entry (GtkWidget   *prefs_dialog,
                     MateConfClient *client,
                     const gchar *config_key,
                     gboolean     focus)
{
  GtkWidget *hbox;
  GtkWidget *entry;
  GtkWidget *label;
  char *str;

  hbox = gtk_hbox_new (FALSE, 5);

  label = gtk_label_new (config_key);
  
  entry = gtk_entry_new ();

  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
  gtk_box_pack_end (GTK_BOX (hbox), entry, FALSE, FALSE, 0);

  /* this will print an error via default error handler
   * if the key isn't set to a string
   */
  str = mateconf_client_get_string (client, config_key, NULL);

  if (str)
    {
      gtk_entry_set_text (GTK_ENTRY (entry), str);
      g_free (str);
    }
  
  g_object_set_data (G_OBJECT (entry), "client", client);
  g_object_set_data_full (G_OBJECT (entry), "key",
                          g_strdup (config_key),
                          (GDestroyNotify) g_free);

  /* Commit changes if the user focuses out, or hits enter; we don't
   * do this on "changed" since it'd probably be a bit too slow to
   * round-trip to the server on every "changed" signal.
   */
  g_signal_connect (G_OBJECT (entry), "focus_out_event",
                    G_CALLBACK (config_entry_commit),
                    NULL);

  g_signal_connect (G_OBJECT (entry), "activate",
                    G_CALLBACK (config_entry_commit),
                    NULL);  

  /* Set the entry insensitive if the key it edits isn't writable.
   * Technically, we should update this sensitivity if the key gets
   * a change notify, but that's probably overkill.
   */
  gtk_widget_set_sensitive (entry,
                            mateconf_client_key_is_writable (client,
                                                          config_key, NULL));

  if (focus)
    gtk_widget_grab_focus (entry);
  
  return hbox;
}
Exemplo n.º 24
0
gchar *
panel_compatibility_get_applet_iid (const gchar *id)
{
	MateConfClient *client = panel_mateconf_get_client ();
	MatePanelAppletInfo *info;
	const char *key;
	gchar *applet_iid;
	gboolean needs_migration;
	const char *iid;

	/*
	 * There are two compatibility steps here:
	 *
	 * 1) we need to migrate from bonobo_iid to applet_iid if there's no
	 *    value in the applet_iid key. Always.
	 *
	 * 2) we need to try to migrate the iid to a new iid. We can't assume
	 *    that the fact that the applet_iid key was used mean anything
	 *    since the value there could well be a bonobo iid.
	 *    The reason we really have to try to migrate first is this case:
	 *    if an applet was added with the bonobo iid but gets ported later
	 *    to dbus, then the reference to the bonobo iid will only be valid
	 *    as an old reference.
	 *    And if migration fails, we just use the iid as it is.
	 */

	needs_migration = FALSE;

	key = panel_mateconf_full_key (PANEL_MATECONF_APPLETS, id, "applet_iid");
	applet_iid = mateconf_client_get_string (client, key, NULL);

	if (!applet_iid || !applet_iid[0]) {
		needs_migration = TRUE;

		key = panel_mateconf_full_key (PANEL_MATECONF_APPLETS, id, "bonobo_iid");
		applet_iid = mateconf_client_get_string (client, key, NULL);

		if (!applet_iid || !applet_iid[0])
			return NULL;
	}

	info = mate_panel_applets_manager_get_applet_info_from_old_id (applet_iid);
	if (!info)
		info = mate_panel_applets_manager_get_applet_info (applet_iid);

	if (!info)
		return NULL;

	iid = mate_panel_applet_info_get_iid (info);

	/* migrate if the iid in the configuration is different than the real
	 * iid that will get used */
	if (!g_str_equal (iid, applet_iid))
		needs_migration = TRUE;

	g_free (applet_iid);

	if (needs_migration) {
		key = panel_mateconf_full_key (PANEL_MATECONF_APPLETS, id, "applet_iid");
		mateconf_client_set_string (client, key, iid, NULL);
	}

	return g_strdup (iid);
}
Exemplo n.º 25
0
void
idol_setup_preferences (Idol *idol)
{
	GtkWidget *menu, *content_area;
	gboolean show_visuals, auto_resize, is_local, no_deinterlace, lock_screensaver_on_audio, auto_chapters;
	int connection_speed;
	guint i, hidden;
	char *visual, *font, *encoding;
	GList *list, *l;
	BvwAudioOutType audio_out;
	MateConfValue *value;
	GObject *item;

	static struct {
		const char *name;
		BvwVideoProperty prop;
		const char *label;
	} props[4] = {
		{ "tpw_contrast_scale", BVW_VIDEO_CONTRAST, "tpw_contrast_label" },
		{ "tpw_saturation_scale", BVW_VIDEO_SATURATION, "tpw_saturation_label" },
		{ "tpw_bright_scale", BVW_VIDEO_BRIGHTNESS, "tpw_brightness_label" },
		{ "tpw_hue_scale", BVW_VIDEO_HUE, "tpw_hue_label" }
	};

	g_return_if_fail (idol->gc != NULL);

	is_local = idol_display_is_local ();

	mateconf_client_add_dir (idol->gc, MATECONF_PREFIX,
			MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL);
	mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/auto_resize",
			(MateConfClientNotifyFunc) auto_resize_changed_cb,
			idol, NULL, NULL);
	mateconf_client_add_dir (idol->gc, "/desktop/mate/lockdown",
			MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL);

	/* Work-around builder dialogue not parenting properly for
	 * On top windows */
	item = gtk_builder_get_object (idol->xml, "tpw_notebook");
	idol->prefs = gtk_dialog_new_with_buttons (_("Preferences"),
			GTK_WINDOW (idol->win),
			GTK_DIALOG_DESTROY_WITH_PARENT,
			GTK_STOCK_CLOSE,
			GTK_RESPONSE_ACCEPT,
			NULL);
	gtk_container_set_border_width (GTK_CONTAINER (idol->prefs), 5);
	content_area = gtk_dialog_get_content_area (GTK_DIALOG (idol->prefs));
	gtk_box_set_spacing (GTK_BOX (content_area), 2);
	gtk_widget_reparent (GTK_WIDGET (item), content_area);
	gtk_widget_show_all (content_area);
	item = gtk_builder_get_object (idol->xml, "idol_preferences_window");
	gtk_widget_destroy (GTK_WIDGET (item));

	g_signal_connect (G_OBJECT (idol->prefs), "response",
			G_CALLBACK (gtk_widget_hide), NULL);
	g_signal_connect (G_OBJECT (idol->prefs), "delete-event",
			G_CALLBACK (gtk_widget_hide_on_delete), NULL);
        g_signal_connect (idol->prefs, "destroy",
                          G_CALLBACK (gtk_widget_destroyed), &idol->prefs);

	/* Remember position */
	idol->remember_position = mateconf_client_get_bool (idol->gc,
			MATECONF_PREFIX"/remember_position", NULL);
	item = gtk_builder_get_object (idol->xml, "tpw_remember_position_checkbutton");
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), idol->remember_position);
	mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/remember_position",
	                         (MateConfClientNotifyFunc) remember_position_changed_cb,
	                         idol, NULL, NULL);

	/* Auto-resize */
	auto_resize = mateconf_client_get_bool (idol->gc,
			MATECONF_PREFIX"/auto_resize", NULL);
	item = gtk_builder_get_object (idol->xml, "tpw_display_checkbutton");
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), auto_resize);
	bacon_video_widget_set_auto_resize
		(BACON_VIDEO_WIDGET (idol->bvw), auto_resize);

	/* Screensaver audio locking */
	lock_screensaver_on_audio = mateconf_client_get_bool (idol->gc,
							   MATECONF_PREFIX"/lock_screensaver_on_audio", NULL);
	if (lock_screensaver_on_audio != FALSE)
		item = gtk_builder_get_object (idol->xml, "tpw_audio_toggle_button");
	else
		item = gtk_builder_get_object (idol->xml, "tpw_video_toggle_button");
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), TRUE);
	mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/lock_screensaver_on_audio",
				 (MateConfClientNotifyFunc) lock_screensaver_on_audio_changed_cb,
				 idol, NULL, NULL);

	/* Disable deinterlacing */
	item = gtk_builder_get_object (idol->xml, "tpw_no_deinterlace_checkbutton");
	no_deinterlace = mateconf_client_get_bool (idol->gc,
						MATECONF_PREFIX"/disable_deinterlacing", NULL);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), no_deinterlace);
	bacon_video_widget_set_deinterlacing (idol->bvw, !no_deinterlace);
	mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/disable_deinterlacing",
				 (MateConfClientNotifyFunc) no_deinterlace_changed_cb,
				 idol, NULL, NULL);

	/* Connection Speed */
	connection_speed = bacon_video_widget_get_connection_speed (idol->bvw);
	item = gtk_builder_get_object (idol->xml, "tpw_speed_combobox");
	gtk_combo_box_set_active (GTK_COMBO_BOX (item), connection_speed);

	/* Enable visuals */
	item = gtk_builder_get_object (idol->xml, "tpw_visuals_checkbutton");
	show_visuals = mateconf_client_get_bool (idol->gc,
			MATECONF_PREFIX"/show_vfx", NULL);
	if (is_local == FALSE && show_visuals != FALSE)
		show_visuals = ask_show_visuals (idol);

	g_signal_handlers_disconnect_by_func (item, checkbutton2_toggled_cb, idol);
	gtk_toggle_button_set_active
		(GTK_TOGGLE_BUTTON (item), show_visuals);
	idol_prefs_set_show_visuals (idol, show_visuals);
	g_signal_connect (item, "toggled", G_CALLBACK (checkbutton2_toggled_cb), idol);

	mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/show_vfx",
			(MateConfClientNotifyFunc) show_vfx_changed_cb,
			idol, NULL, NULL);

	/* Auto-load subtitles */
	item = gtk_builder_get_object (idol->xml, "tpw_auto_subtitles_checkbutton");
	idol->autoload_subs = mateconf_client_get_bool (idol->gc,
					      MATECONF_PREFIX"/autoload_subtitles", NULL);

	g_signal_handlers_disconnect_by_func (item, checkbutton3_toggled_cb, idol);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), idol->autoload_subs);
	g_signal_connect (item, "toggled", G_CALLBACK (checkbutton3_toggled_cb), idol);

	mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/autoload_subtitles",
				 (MateConfClientNotifyFunc) autoload_subtitles_changed_cb,
				 idol, NULL, NULL);

	/* Auto-load external chapters */
	item = gtk_builder_get_object (idol->xml, "tpw_auto_chapters_checkbutton");
	auto_chapters = mateconf_client_get_bool (idol->gc,
					       MATECONF_PREFIX"/autoload_chapters", NULL);

	g_signal_handlers_disconnect_by_func (item, auto_chapters_toggled_cb, idol);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), auto_chapters);
	g_signal_connect (item, "toggled", G_CALLBACK (auto_chapters_toggled_cb), idol);

	mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/autoload_chapters",
				 (MateConfClientNotifyFunc) autoload_chapters_changed_cb,
				 idol, NULL, NULL);

	/* Visuals list */
	list = bacon_video_widget_get_visuals_list (idol->bvw);
	menu = gtk_menu_new ();
	gtk_widget_show (menu);

	visual = mateconf_client_get_string (idol->gc,
			MATECONF_PREFIX"/visual", NULL);
	if (visual == NULL || strcmp (visual, "") == 0) {
		g_free (visual);
		visual = g_strdup ("goom");
	}

	item = gtk_builder_get_object (idol->xml, "tpw_visuals_type_combobox");

	i = 0;
	for (l = list; l != NULL; l = l->next) {
		const char *name = l->data;

		gtk_combo_box_append_text (GTK_COMBO_BOX (item), name);

		if (strcmp (name, visual) == 0)
			gtk_combo_box_set_active (GTK_COMBO_BOX (item), i);

		i++;
	}
	g_free (visual);

	/* Visualisation quality */
	i = mateconf_client_get_int (idol->gc,
			MATECONF_PREFIX"/visual_quality", NULL);
	bacon_video_widget_set_visuals_quality (idol->bvw, i);
	item = gtk_builder_get_object (idol->xml, "tpw_visuals_size_combobox");
	gtk_combo_box_set_active (GTK_COMBO_BOX (item), i);

	/* Brightness and all */
	hidden = 0;
	for (i = 0; i < G_N_ELEMENTS (props); i++) {
		int prop_value;
		item = gtk_builder_get_object (idol->xml, props[i].name);
		prop_value = bacon_video_widget_get_video_property (idol->bvw,
							       props[i].prop);
		if (prop_value >= 0)
			gtk_range_set_value (GTK_RANGE (item), (gdouble) prop_value);
		else {
			gtk_range_set_value (GTK_RANGE (item), (gdouble) 65535/2);
			gtk_widget_hide (GTK_WIDGET (item));
			item = gtk_builder_get_object (idol->xml, props[i].label);
			gtk_widget_hide (GTK_WIDGET (item));
			hidden++;
		}
	}

	if (hidden == G_N_ELEMENTS (props)) {
		item = gtk_builder_get_object (idol->xml, "tpw_bright_contr_vbox");
		gtk_widget_hide (GTK_WIDGET (item));
	}

	/* Sound output type */
	item = gtk_builder_get_object (idol->xml, "tpw_sound_output_combobox");
	audio_out = bacon_video_widget_get_audio_out_type (idol->bvw);
	gtk_combo_box_set_active (GTK_COMBO_BOX (item), audio_out);

	/* Subtitle font selection */
	item = gtk_builder_get_object (idol->xml, "font_sel_button");
	gtk_font_button_set_title (GTK_FONT_BUTTON (item),
				   _("Select Subtitle Font"));
	font = mateconf_client_get_string (idol->gc,
		MATECONF_PREFIX"/subtitle_font", NULL);
	if (font && strcmp (font, "") != 0) {
		gtk_font_button_set_font_name (GTK_FONT_BUTTON (item), font);
		bacon_video_widget_set_subtitle_font (idol->bvw, font);
	}
	g_free (font);
	mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/subtitle_font",
			(MateConfClientNotifyFunc) font_changed_cb,
			idol, NULL, NULL);

	/* Subtitle encoding selection */
	item = gtk_builder_get_object (idol->xml, "subtitle_encoding_combo");
	idol_subtitle_encoding_init (GTK_COMBO_BOX (item));
	value = mateconf_client_get_without_default (idol->gc,
			MATECONF_PREFIX"/subtitle_encoding", NULL);
	/* Make sure the default is UTF-8 */
	if (value != NULL) {
		if (mateconf_value_get_string (value) == NULL) {
			encoding = g_strdup ("UTF-8");
		} else {
			encoding = g_strdup (mateconf_value_get_string (value));
			if (encoding[0] == '\0') {
				g_free (encoding);
				encoding = g_strdup ("UTF-8");
			}
		}
		mateconf_value_free (value);
	} else {
		encoding = g_strdup ("UTF-8");
	}
	idol_subtitle_encoding_set (GTK_COMBO_BOX(item), encoding);
	if (encoding && strcasecmp (encoding, "") != 0) {
		bacon_video_widget_set_subtitle_encoding (idol->bvw, encoding);
	}
	g_free (encoding);
	mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/subtitle_encoding",
			(MateConfClientNotifyFunc) encoding_changed_cb,
			idol, NULL, NULL);

	/* Disable keyboard shortcuts */
	idol->disable_kbd_shortcuts = mateconf_client_get_bool (idol->gc,
							      MATECONF_PREFIX"/disable_keyboard_shortcuts", NULL);
	mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/disable_keyboard_shortcuts",
				 (MateConfClientNotifyFunc) disable_kbd_shortcuts_changed_cb,
				 idol, NULL, NULL);
}
static void mate_wp_xml_load_xml (AppearanceData *data,
                                  const gchar * filename) {
    xmlDoc * wplist;
    xmlNode * root, * list, * wpa;
    xmlChar * nodelang;
    const gchar * const * syslangs;
    GdkColor color1, color2;
    gint i;

    wplist = xmlParseFile (filename);

    if (!wplist)
        return;

    syslangs = g_get_language_names ();

    root = xmlDocGetRootElement (wplist);

    for (list = root->children; list != NULL; list = list->next) {
        if (!strcmp ((gchar *)list->name, "wallpaper")) {
            MateWPItem * wp;
            gchar *pcolor = NULL, *scolor = NULL;
            gchar *s;
            gboolean have_scale = FALSE, have_shade = FALSE;

            wp = g_new0 (MateWPItem, 1);

            wp->deleted = mate_wp_xml_get_bool (list, "deleted");

            for (wpa = list->children; wpa != NULL; wpa = wpa->next) {
                if (wpa->type == XML_COMMENT_NODE) {
                    continue;
                } else if (!strcmp ((gchar *)wpa->name, "filename")) {
                    if (wpa->last != NULL && wpa->last->content != NULL) {
                        const char * none = "(none)";
                        gchar *content = g_strstrip ((gchar *)wpa->last->content);

                        if (!strcmp (content, none))
                            wp->filename = g_strdup (content);
                        else if (g_utf8_validate (content, -1, NULL) &&
                                 g_file_test (content, G_FILE_TEST_EXISTS))
                            wp->filename = g_strdup (content);
                        else
                            wp->filename = g_filename_from_utf8 (content, -1, NULL, NULL, NULL);
                    } else {
                        break;
                    }
                } else if (!strcmp ((gchar *)wpa->name, "name")) {
                    if (wpa->last != NULL && wpa->last->content != NULL) {
                        nodelang = xmlNodeGetLang (wpa->last);

                        if (wp->name == NULL && nodelang == NULL) {
                            wp->name = g_strdup (g_strstrip ((gchar *)wpa->last->content));
                        } else {
                            for (i = 0; syslangs[i] != NULL; i++) {
                                if (!strcmp (syslangs[i], (gchar *)nodelang)) {
                                    g_free (wp->name);
                                    wp->name = g_strdup (g_strstrip ((gchar *)wpa->last->content));
                                    break;
                                }
                            }
                        }

                        xmlFree (nodelang);
                    } else {
                        break;
                    }
                } else if (!strcmp ((gchar *)wpa->name, "options")) {
                    if (wpa->last != NULL) {
                        wp->options = wp_item_string_to_option (g_strstrip ((gchar *)wpa->last->content));
                        have_scale = TRUE;
                    }
                } else if (!strcmp ((gchar *)wpa->name, "shade_type")) {
                    if (wpa->last != NULL) {
                        wp->shade_type = wp_item_string_to_shading (g_strstrip ((gchar *)wpa->last->content));
                        have_shade = TRUE;
                    }
                } else if (!strcmp ((gchar *)wpa->name, "pcolor")) {
                    if (wpa->last != NULL) {
                        pcolor = g_strdup (g_strstrip ((gchar *)wpa->last->content));
                    }
                } else if (!strcmp ((gchar *)wpa->name, "scolor")) {
                    if (wpa->last != NULL) {
                        scolor = g_strdup (g_strstrip ((gchar *)wpa->last->content));
                    }
                } else if (!strcmp ((gchar *)wpa->name, "text")) {
                    /* Do nothing here, libxml2 is being weird */
                } else {
                    g_warning ("Unknown Tag: %s", wpa->name);
                }
            }

            /* Make sure we don't already have this one and that filename exists */
            if (wp->filename == NULL ||
                    g_hash_table_lookup (data->wp_hash, wp->filename) != NULL) {

                mate_wp_item_free (wp);
                g_free (pcolor);
                g_free (scolor);
                continue;
            }

            /* Verify the colors and alloc some GdkColors here */
            if (!have_scale) {
                s = mateconf_client_get_string (data->client, WP_OPTIONS_KEY, NULL);
                wp->options = wp_item_string_to_option (s);
                g_free (s);
            }

            if (!have_shade) {
                s = mateconf_client_get_string (data->client, WP_SHADING_KEY, NULL);
                wp->shade_type = wp_item_string_to_shading (s);
                g_free (s);
            }

            if (pcolor == NULL) {
                pcolor = mateconf_client_get_string (data->client,
                                                     WP_PCOLOR_KEY, NULL);
            }
            if (scolor == NULL) {
                scolor = mateconf_client_get_string (data->client,
                                                     WP_SCOLOR_KEY, NULL);
            }
            gdk_color_parse (pcolor, &color1);
            gdk_color_parse (scolor, &color2);
            g_free (pcolor);
            g_free (scolor);

            wp->pcolor = gdk_color_copy (&color1);
            wp->scolor = gdk_color_copy (&color2);

            if ((wp->filename != NULL &&
                    g_file_test (wp->filename, G_FILE_TEST_EXISTS)) ||
                    !strcmp (wp->filename, "(none)")) {
                wp->fileinfo = mate_wp_info_new (wp->filename, data->thumb_factory);

                if (wp->name == NULL || !strcmp (wp->filename, "(none)")) {
                    g_free (wp->name);
                    wp->name = g_strdup (wp->fileinfo->name);
                }

                mate_wp_item_ensure_mate_bg (wp);
                mate_wp_item_update_description (wp);
                g_hash_table_insert (data->wp_hash, wp->filename, wp);
            } else {
                mate_wp_item_free (wp);
                wp = NULL;
            }
        }
    }
    xmlFreeDoc (wplist);
}
Exemplo n.º 27
0
void
mate_panel_applet_save_position (AppletInfo *applet_info,
			    const char *id,
			    gboolean    immediate)
{
	PanelMateConfKeyType  key_type;
	MateConfClient       *client;
	PanelWidget       *panel_widget;
	const char        *key;
	const char        *toplevel_id;
	char              *old_toplevel_id;
	gboolean           right_stick;
	gboolean           locked;
	int                position;

	g_return_if_fail (applet_info != NULL);

	if (!immediate) {
		if (!queued_position_source)
			queued_position_source =
				g_timeout_add_seconds (1,
						       (GSourceFunc) mate_panel_applet_position_save_timeout,
						       NULL);

		if (!g_slist_find (queued_position_saves, applet_info))
			queued_position_saves =
				g_slist_prepend (queued_position_saves, applet_info);

		return;
	}

	if (!(toplevel_id = mate_panel_applet_get_toplevel_id (applet_info)))
		return;

	client  = panel_mateconf_get_client ();

	key_type = applet_info->type == PANEL_OBJECT_APPLET ? PANEL_MATECONF_APPLETS : PANEL_MATECONF_OBJECTS;

	panel_widget = mate_panel_applet_get_panel_widget (applet_info);

	/* FIXME: Instead of getting keys, comparing and setting, there
	   should be a dirty flag */

	key = panel_mateconf_full_key (key_type, id, "toplevel_id");
	old_toplevel_id = mateconf_client_get_string (client, key, NULL);
	if (old_toplevel_id == NULL || strcmp (old_toplevel_id, toplevel_id) != 0)
		mateconf_client_set_string (client, key, toplevel_id, NULL);
	g_free (old_toplevel_id);

	/* Note: changing some properties of the panel that may not be locked down
	   (e.g. background) can change the state of the "panel_right_stick" and
	   "position" properties of an applet that may in fact be locked down.
	   So check if these are writable before attempting to write them */

	right_stick = panel_is_applet_right_stick (applet_info->widget) ? 1 : 0;
	key = panel_mateconf_full_key (
			key_type, id, "panel_right_stick");
	if (mateconf_client_key_is_writable (client, key, NULL) &&
	    (mateconf_client_get_bool (client, key, NULL) ? 1 : 0) != right_stick)
		mateconf_client_set_bool (client, key, right_stick, NULL);

	position = mate_panel_applet_get_position (applet_info);
	if (right_stick && !panel_widget->packed)
		position = panel_widget->size - position;

	key = panel_mateconf_full_key (key_type, id, "position");
	if (mateconf_client_key_is_writable (client, key, NULL) &&
	    mateconf_client_get_int (client, key, NULL) != position)
		mateconf_client_set_int (client, key, position, NULL);

	locked = panel_widget_get_applet_locked (panel_widget, applet_info->widget) ? 1 : 0;
	key = panel_mateconf_full_key (key_type, id, "locked");
	if (mateconf_client_get_bool (client, key, NULL) ? 1 : 0 != locked)
		mateconf_client_set_bool (client, key, locked, NULL);
}