Commit 866a128f authored by Paolo Borelli's avatar Paolo Borelli Committed by Paolo Borelli

Remove all code and preferences related to setting colors. It has been

2007-07-23  Paolo Borelli  <pborelli@katamail.com>

	* bindings/python/gedit.defs:
	* data/gedit.schemas.in:
	* gedit/gedit-view.c:
	* gedit/gedit-view.h:
	* gedit/gedit-prefs-manager.c:
	* gedit/gedit-prefs-manager.h:
	* gedit/gedit-prefs-manager-app.c:

	Remove all code and preferences related to setting colors.
	It has been superceeded by style scheme support


svn path=/trunk/; revision=5737
parent 2033e09a
2007-07-23 Paolo Borelli <pborelli@katamail.com>
* bindings/python/gedit.defs:
* data/gedit.schemas.in:
* gedit/gedit-view.c:
* gedit/gedit-view.h:
* gedit/gedit-prefs-manager.c:
* gedit/gedit-prefs-manager.h:
* gedit/gedit-prefs-manager-app.c:
Remove all code and preferences related to setting colors.
It has been superceeded by style scheme support
2007-07-20 Steve Frécinaux <code@istique.net>
* gedit/gedit-document-loader.[ch]:
......
......@@ -791,19 +791,6 @@
(return-type "none")
)
(define-method set_colors
(of-object "GeditView")
(c-name "gedit_view_set_colors")
(return-type "none")
(parameters
'("gboolean" "def")
'("GdkColor*" "backgroud")
'("GdkColor*" "text")
'("GdkColor*" "selection")
'("GdkColor*" "sel_text")
)
)
(define-method set_font
(of-object "GeditView")
(c-name "gedit_view_set_font")
......
......@@ -30,78 +30,6 @@
</locale>
</schema>
<schema>
<key>/schemas/apps/gedit-2/preferences/editor/colors/use_default_colors</key>
<applyto>/apps/gedit-2/preferences/editor/colors/use_default_colors</applyto>
<owner>gedit</owner>
<type>bool</type>
<default>TRUE</default>
<locale name="C">
<short>Use Default Colors</short>
<long>Whether to use the system's default colors for the
editing area. If this option is turned off, then the colors
of the editing area will be those specified in the "Background
Color", "Text Color", "Selected Text Color", and "Selection
Color" options.</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gedit-2/preferences/editor/colors/background_color</key>
<applyto>/apps/gedit-2/preferences/editor/colors/background_color</applyto>
<owner>gedit</owner>
<type>string</type>
<default>#ffffffffffff</default>
<locale name="C">
<short>Background Color</short>
<long>Background color for unselected text in the editing
area. This will only take effect if the "Use Default Colors"
option is turned off.</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gedit-2/preferences/editor/colors/text_color</key>
<applyto>/apps/gedit-2/preferences/editor/colors/text_color</applyto>
<owner>gedit</owner>
<type>string</type>
<default>#000000000000</default>
<locale name="C">
<short>Text Color</short>
<long>Foreground color for the unselected text in the editing
area. This will only take effect if the "Use Default Colors"
option is turned off.</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gedit-2/preferences/editor/colors/selected_text_color</key>
<applyto>/apps/gedit-2/preferences/editor/colors/selected_text_color</applyto>
<owner>gedit</owner>
<type>string</type>
<default>#ffffffffffff</default>
<locale name="C">
<short>Selected Text Color</short>
<long>Foreground color for selected text in the editing area.
This will only take effect if the "Use Default Colors" option
is turned off.</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gedit-2/preferences/editor/colors/selection_color</key>
<applyto>/apps/gedit-2/preferences/editor/colors/selection_color</applyto>
<owner>gedit</owner>
<type>string</type>
<default>#000000009c9c</default>
<locale name="C">
<short>Selection Color</short>
<long>Background color for selected text in the editing area.
This will only take effect if the "Use Default Colors" option
is turned off.</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gedit-2/preferences/editor/save/create_backup_copy</key>
<applyto>/apps/gedit-2/preferences/editor/save/create_backup_copy</applyto>
......
This diff is collapsed.
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* gedit-output-window.h
* This file is part of gedit
*
* Copyright (C) 2002-2004 Paolo Maggi
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
/*
* Modified by the gedit Team, 2002-2004. See the AUTHORS file for a
* list of people on the gedit Team.
* See the ChangeLog files for a list of changes.
*/
#ifndef __GEDIT_OUTPUT_WINDOW_H__
#define __GEDIT_OUTPUT_WINDOW_H__
#include <gtk/gtkhbox.h>
#define GEDIT_TYPE_OUTPUT_WINDOW (gedit_output_window_get_type ())
#define GEDIT_OUTPUT_WINDOW(obj) (GTK_CHECK_CAST ((obj), GEDIT_TYPE_OUTPUT_WINDOW, GeditOutputWindow))
#define GEDIT_OUTPUT_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_OUTPUT_WINDOW, GeditOutputWindowClass))
#define GEDIT_IS_OUTPUT_WINDOW(obj) (GTK_CHECK_TYPE ((obj), GEDIT_TYPE_OUTPUT_WINDOW))
#define GEDIT_IS_OUTPUT_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_OUTPUT_WINDOW))
#define GEDIT_OUTPUT_WINDOW_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GEDIT_TYPE_OUTPUT_WINDOW, GeditOutputWindowClass))
typedef struct _GeditOutputWindow GeditOutputWindow;
typedef struct _GeditOutputWindowClass GeditOutputWindowClass;
typedef struct _GeditOutputWindowPrivate GeditOutputWindowPrivate;
struct _GeditOutputWindow
{
GtkHBox box;
GeditOutputWindowPrivate *priv;
};
struct _GeditOutputWindowClass
{
GtkHBoxClass parent_class;
void (*close_requested) (GeditOutputWindow *ow);
void (*selection_changed) (GeditOutputWindow *ow,
gint num_of_sel_lines);
void (*line_activated) (GeditOutputWindow *ow,
const gchar *line);
};
GtkType gedit_output_window_get_type (void) G_GNUC_CONST;
GtkWidget *gedit_output_window_new (void);
void gedit_output_window_clear (GeditOutputWindow *ow);
void gedit_output_window_append_line (GeditOutputWindow *ow,
const gchar *line,
gboolean scroll);
void gedit_output_window_prepend_line (GeditOutputWindow *ow,
const gchar *line,
gboolean scroll);
void gedit_output_window_set_selection_mode (GeditOutputWindow *ow,
const GtkSelectionMode type);
GtkSelectionMode gedit_output_window_get_selection_mode (GeditOutputWindow *ow);
GSList *gedit_output_window_get_selected_lines (GeditOutputWindow *ow);
#endif /* __GEDIT_OUTPUT_WINDOW_H__ */
......@@ -55,11 +55,6 @@ static void gedit_prefs_manager_system_font_changed (GConfClient *client,
GConfEntry *entry,
gpointer user_data);
static void gedit_prefs_manager_editor_colors_changed (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
gpointer user_data);
static void gedit_prefs_manager_tabs_size_changed (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
......@@ -624,11 +619,6 @@ gedit_prefs_manager_app_init (void)
gedit_prefs_manager_system_font_changed,
NULL, NULL, NULL);
gconf_client_notify_add (gedit_prefs_manager->gconf_client,
GPM_COLORS_DIR,
gedit_prefs_manager_editor_colors_changed,
NULL, NULL, NULL);
gconf_client_notify_add (gedit_prefs_manager->gconf_client,
GPM_TABS_DIR,
gedit_prefs_manager_tabs_size_changed,
......@@ -826,145 +816,6 @@ gedit_prefs_manager_system_font_changed (GConfClient *client,
g_free (font);
}
static void
set_colors (gboolean def,
GdkColor *backgroud,
GdkColor *text,
GdkColor *selection,
GdkColor *sel_text)
{
GList *views;
GList *l;
views = gedit_app_get_views (gedit_app_get_default ());
l = views;
while (l != NULL)
{
gedit_view_set_colors (GEDIT_VIEW (l->data),
def,
backgroud,
text,
selection,
sel_text);
l = l->next;
}
g_list_free (views);
}
static void
gedit_prefs_manager_editor_colors_changed (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
gpointer user_data)
{
gchar *str_color;
GdkColor color;
gedit_debug (DEBUG_PREFS);
g_return_if_fail (entry->key != NULL);
g_return_if_fail (entry->value != NULL);
if (strcmp (entry->key, GPM_USE_DEFAULT_COLORS) == 0)
{
gboolean def = TRUE;
if (entry->value->type == GCONF_VALUE_BOOL)
def = gconf_value_get_bool (entry->value);
else
def = GPM_DEFAULT_USE_DEFAULT_COLORS;
if (def)
set_colors (TRUE, NULL, NULL, NULL, NULL);
else
{
GdkColor background, text, selection, sel_text;
background = gedit_prefs_manager_get_background_color ();
text = gedit_prefs_manager_get_text_color ();
selection = gedit_prefs_manager_get_selection_color ();
sel_text = gedit_prefs_manager_get_selected_text_color ();
set_colors (FALSE,
&background,
&text,
&selection,
&sel_text);
}
return;
}
if (gedit_prefs_manager_get_use_default_colors ())
{
set_colors (TRUE, NULL, NULL, NULL, NULL);
return;
}
if (strcmp (entry->key, GPM_BACKGROUND_COLOR) == 0)
{
if (entry->value->type == GCONF_VALUE_STRING)
str_color = g_strdup (gconf_value_get_string (entry->value));
else
str_color = g_strdup (GPM_DEFAULT_BACKGROUND_COLOR);
gdk_color_parse (str_color, &color);
g_free (str_color);
set_colors (FALSE, &color, NULL, NULL, NULL);
return;
}
if (strcmp (entry->key, GPM_TEXT_COLOR) == 0)
{
if (entry->value->type == GCONF_VALUE_STRING)
str_color = g_strdup (gconf_value_get_string (entry->value));
else
str_color = g_strdup (GPM_DEFAULT_TEXT_COLOR);
gdk_color_parse (str_color, &color);
g_free (str_color);
set_colors (FALSE, NULL, &color, NULL, NULL);
return;
}
if (strcmp (entry->key, GPM_SELECTION_COLOR) == 0)
{
if (entry->value->type == GCONF_VALUE_STRING)
str_color = g_strdup (gconf_value_get_string (entry->value));
else
str_color = g_strdup (GPM_DEFAULT_SELECTION_COLOR);
gdk_color_parse (str_color, &color);
g_free (str_color);
set_colors (FALSE, NULL, NULL, &color, NULL);
return;
}
if (strcmp (entry->key, GPM_SELECTED_TEXT_COLOR) == 0)
{
if (entry->value->type == GCONF_VALUE_STRING)
str_color = g_strdup (gconf_value_get_string (entry->value));
else
str_color = g_strdup (GPM_DEFAULT_SELECTED_TEXT_COLOR);
gdk_color_parse (str_color, &color);
g_free (str_color);
set_colors (FALSE, NULL, NULL, NULL, &color);
return;
}
}
static void
gedit_prefs_manager_tabs_size_changed (GConfClient *client,
guint cnxn_id,
......
......@@ -294,93 +294,6 @@ gedit_prefs_manager_key_is_writable (const gchar* key)
return gconf_client_key_is_writable (gedit_prefs_manager->gconf_client, key, NULL);
}
static GdkColor
gconf_client_get_color_with_default (GConfClient* client, const gchar* key,
const gchar* def, GError** err)
{
gchar *str_color = NULL;
GdkColor color = {0, };
gedit_debug (DEBUG_PREFS);
g_return_val_if_fail (client != NULL, color);
g_return_val_if_fail (GCONF_IS_CLIENT (client), color);
g_return_val_if_fail (key != NULL, color);
g_return_val_if_fail (def != NULL, color);
str_color = gconf_client_get_string_with_default (client,
key,
def,
NULL);
g_return_val_if_fail (str_color != NULL, color);
gdk_color_parse (str_color, &color);
g_free (str_color);
return color;
}
static gboolean
gedit_gconf_client_set_color (GConfClient *client,
const gchar *key,
GdkColor val,
GError **err)
{
gchar *str_color = NULL;
gboolean res;
gedit_debug (DEBUG_PREFS);
g_return_val_if_fail (client != NULL, FALSE);
g_return_val_if_fail (GCONF_IS_CLIENT (client), FALSE);
g_return_val_if_fail (key != NULL, FALSE);
str_color = gedit_gdk_color_to_string (val);
g_return_val_if_fail (str_color != NULL, FALSE);
res = gconf_client_set_string (client,
key,
str_color,
err);
g_free (str_color);
return res;
}
static GdkColor
gedit_prefs_manager_get_color (const gchar* key, const gchar* def)
{
GdkColor color = {0, };
gedit_debug (DEBUG_PREFS);
if (def != NULL)
gdk_color_parse (def, &color);
g_return_val_if_fail (gedit_prefs_manager != NULL, color);
g_return_val_if_fail (gedit_prefs_manager->gconf_client != NULL, color);
return gconf_client_get_color_with_default (gedit_prefs_manager->gconf_client,
key,
def,
NULL);
}
static void
gedit_prefs_manager_set_color (const gchar* key, GdkColor value)
{
gedit_debug (DEBUG_PREFS);
g_return_if_fail (gedit_prefs_manager != NULL);
g_return_if_fail (gedit_prefs_manager->gconf_client != NULL);
g_return_if_fail (gconf_client_key_is_writable (
gedit_prefs_manager->gconf_client, key, NULL));
gedit_gconf_client_set_color (gedit_prefs_manager->gconf_client, key, value, NULL);
}
/* Use default font */
DEFINE_BOOL_PREF (use_default_font,
GPM_USE_DEFAULT_FONT,
......@@ -401,121 +314,6 @@ gedit_prefs_manager_get_system_font (void)
GPM_DEFAULT_SYSTEM_FONT);
}
/* Use default colors */
DEFINE_BOOL_PREF (use_default_colors,
GPM_USE_DEFAULT_COLORS,
GPM_DEFAULT_USE_DEFAULT_COLORS)
/* Background color */
GdkColor
gedit_prefs_manager_get_background_color (void)
{
gedit_debug (DEBUG_PREFS);
return gedit_prefs_manager_get_color (GPM_BACKGROUND_COLOR,
GPM_DEFAULT_BACKGROUND_COLOR);
}
void
gedit_prefs_manager_set_background_color (GdkColor color)
{
gedit_debug (DEBUG_PREFS);
gedit_prefs_manager_set_color (GPM_BACKGROUND_COLOR,
color);
}
gboolean
gedit_prefs_manager_background_color_can_set (void)
{
gedit_debug (DEBUG_PREFS);
return gedit_prefs_manager_key_is_writable (GPM_BACKGROUND_COLOR);
}
/* Text color */
GdkColor
gedit_prefs_manager_get_text_color (void)
{
gedit_debug (DEBUG_PREFS);
return gedit_prefs_manager_get_color (GPM_TEXT_COLOR,
GPM_DEFAULT_TEXT_COLOR);
}
void
gedit_prefs_manager_set_text_color (GdkColor color)
{
gedit_debug (DEBUG_PREFS);
gedit_prefs_manager_set_color (GPM_TEXT_COLOR,
color);
}
gboolean
gedit_prefs_manager_text_color_can_set (void)
{
gedit_debug (DEBUG_PREFS);
return gedit_prefs_manager_key_is_writable (GPM_TEXT_COLOR);
}
/* Selected text color */
GdkColor
gedit_prefs_manager_get_selected_text_color (void)
{
gedit_debug (DEBUG_PREFS);
return gedit_prefs_manager_get_color (GPM_SELECTED_TEXT_COLOR,
GPM_DEFAULT_SELECTED_TEXT_COLOR);
}
void
gedit_prefs_manager_set_selected_text_color (GdkColor color)
{
gedit_debug (DEBUG_PREFS);
gedit_prefs_manager_set_color (GPM_SELECTED_TEXT_COLOR,
color);
}
gboolean
gedit_prefs_manager_selected_text_color_can_set (void)
{
gedit_debug (DEBUG_PREFS);
return gedit_prefs_manager_key_is_writable (GPM_SELECTED_TEXT_COLOR);
}
/* Selection color */
GdkColor
gedit_prefs_manager_get_selection_color (void)
{
gedit_debug (DEBUG_PREFS);
return gedit_prefs_manager_get_color (GPM_SELECTION_COLOR,
GPM_DEFAULT_SELECTION_COLOR);
}
void
gedit_prefs_manager_set_selection_color (GdkColor color)
{
gedit_debug (DEBUG_PREFS);
gedit_prefs_manager_set_color (GPM_SELECTION_COLOR,
color);
}
gboolean
gedit_prefs_manager_selection_color_can_set (void)
{
gedit_debug (DEBUG_PREFS);
return gedit_prefs_manager_key_is_writable (GPM_SELECTION_COLOR);
}
/* Create backup copy */
DEFINE_BOOL_PREF (create_backup_copy,
GPM_CREATE_BACKUP_COPY,
......
......@@ -30,7 +30,6 @@
#ifndef __GEDIT_PREFS_MANAGER_H__
#define __GEDIT_PREFS_MANAGER_H__
#include <gdk/gdkcolor.h>
#include <gtk/gtkenums.h>
#include <glib/gslist.h>
#include <gtksourceview/gtksourceview.h>
......@@ -46,13 +45,6 @@
#define GPM_EDITOR_FONT GPM_FONT_DIR "/editor_font"
#define GPM_SYSTEM_FONT "/desktop/gnome/interface/monospace_font_name"
#define GPM_COLORS_DIR GPM_PREFS_DIR "/editor/colors"
#define GPM_USE_DEFAULT_COLORS GPM_COLORS_DIR "/use_default_colors"
#define GPM_BACKGROUND_COLOR GPM_COLORS_DIR "/background_color"
#define GPM_TEXT_COLOR GPM_COLORS_DIR "/text_color"
#define GPM_SELECTED_TEXT_COLOR GPM_COLORS_DIR "/selected_text_color"
#define GPM_SELECTION_COLOR GPM_COLORS_DIR "/selection_color"
#define GPM_SAVE_DIR GPM_PREFS_DIR "/editor/save"
#define GPM_CREATE_BACKUP_COPY GPM_SAVE_DIR "/create_backup_copy"
#define GPM_BACKUP_COPY_EXTENSION GPM_SAVE_DIR "/backup_copy_extension"
......@@ -156,12 +148,6 @@
#define GPM_DEFAULT_EDITOR_FONT (const gchar*) "Monospace 12"
#define GPM_DEFAULT_SYSTEM_FONT (const gchar*) "Monospace 10"
#define GPM_DEFAULT_USE_DEFAULT_COLORS 1 /* TRUE */
#define GPM_DEFAULT_BACKGROUND_COLOR (const gchar*) "#ffffffffffff"
#define GPM_DEFAULT_TEXT_COLOR (const gchar*) "#000000000000"
#define GPM_DEFAULT_SELECTED_TEXT_COLOR (const gchar*) "#ffffffffffff"
#define GPM_DEFAULT_SELECTION_COLOR (const gchar*) "#000000009c9c"
#define GPM_DEFAULT_CREATE_BACKUP_COPY 1 /* TRUE */
#define GPM_DEFAULT_BACKUP_COPY_EXTENSION (const gchar*) "~"
......@@ -249,31 +235,6 @@ gboolean gedit_prefs_manager_editor_font_can_set (void);
/* System font */
gchar *gedit_prefs_manager_get_system_font (void);
/* Use default colors */
gboolean gedit_prefs_manager_get_use_default_colors (void);
void gedit_prefs_manager_set_use_default_colors (gboolean udc);
gboolean gedit_prefs_manager_use_default_colors_can_set (void);
/* Background color */
GdkColor gedit_prefs_manager_get_background_color (void);
void gedit_prefs_manager_set_background_color (GdkColor color);
gboolean gedit_prefs_manager_background_color_can_set (void);
/* Text color */
GdkColor gedit_prefs_manager_get_text_color (void);
void gedit_prefs_manager_set_text_color (GdkColor color);
gboolean gedit_prefs_manager_text_color_can_set (void);
/* Selection color */
GdkColor gedit_prefs_manager_get_selection_color (void);
void gedit_prefs_manager_set_selection_color (GdkColor color);
gboolean gedit_prefs_manager_selection_color_can_set (void);
/* Selected text color */
GdkColor gedit_prefs_manager_get_selected_text_color (void);
void gedit_prefs_manager_set_selected_text_color (GdkColor color);
gboolean gedit_prefs_manager_selected_text_color_can_set(void);
/* Create backup copy */
gboolean gedit_prefs_manager_get_create_backup_copy (void);
void gedit_prefs_manager_set_create_backup_copy (gboolean cbc);
......
......@@ -242,26 +242,6 @@ gedit_view_init (GeditView *view)
gedit_view_set_font (view, TRUE, NULL);
}
if (!gedit_prefs_manager_get_use_default_colors ())
{
GdkColor background;
GdkColor text;
GdkColor selection;
GdkColor sel_text;
background = gedit_prefs_manager_get_background_color ();
text = gedit_prefs_manager_get_text_color ();
selection = gedit_prefs_manager_get_selection_color ();
sel_text = gedit_prefs_manager_get_selected_text_color ();
gedit_view_set_colors (view,
FALSE,
&background,
&text,
&selection,
&sel_text);
}
g_object_set (G_OBJECT (view),
"wrap_mode", gedit_prefs_manager_get_wrap_mode (),
"show_line_numbers", gedit_prefs_manager_get_display_line_numbers (),
......@@ -536,143 +516,6 @@ gedit_view_scroll_to_cursor (GeditView *view)
0.0);
}
/* assign a unique name */
static G_CONST_RETURN gchar *
get_widget_name (GtkWidget *w)
{
const gchar *name;
name = gtk_widget_get_name (w);
g_return_val_if_fail (name != NULL, NULL);
if (strcmp (name, g_type_name (GTK_WIDGET_TYPE (w))) == 0)
{
static guint d = 0;
gchar *n;
n = g_strdup_printf ("%s_%u_%u", name, d, (guint) g_random_int);
d++;
gtk_widget_set_name (w, n);
g_free (n);
name = gtk_widget_get_name (w);
}
return name;
}
/* There is no clean way to set the cursor-color, so we are stuck
* with the following hack: set the name of each widget and parse
* a gtkrc string.
*/
static void
modify_cursor_color (GtkWidget *textview,
GdkColor *color)
{
static const char cursor_color_rc[] =
"style \"svs-cc\"\n"
"{\n"
"GtkSourceView::cursor-color=\"#%04x%04x%04x\"\n"
"}\n"
"widget \"*.%s\" style : application \"svs-cc\"\n";
const gchar *name;
gchar *rc_temp;
gedit_debug (DEBUG_VIEW);
name = get_widget_name (textview);
g_return_if_fail (name != NULL);
if (color != NULL)
{
rc_temp = g_strdup_printf (cursor_color_rc,
color->red,
color->green,
color->blue,
name);
}
else
{
GtkRcStyle *rc_style;