Commit c4df9fa0 authored by Paolo Maggi's avatar Paolo Maggi Committed by Paolo Maggi

First step toward the new preference dialog

2007-07-20  Paolo Maggi  <paolo@gnome.org>

	First step toward the new preference dialog
	
	* gedit/dialogs/Makefile.am: compile new files
	
	* gedit/dialogs/gedit-preferences-dialog.c: set the new "Font & 
Colors" 
	page
	* gedit/dialogs/gedit-preferences-dialog.glade: new "Font & 
Colors" 
	page
	* gedit/dialogs/gedit-style-scheme-dialog.[ch]: new files
	* gedit/dialogs/gedit-style-scheme-dialog.glade: new file

	* gedit/dialogs/gedit-style-scheme-generator.[ch]: new file
	* gedit/gedit-document.c (gedit_document_init): check the 
default style
	is not NULL before using it
	* gedit/gedit-source-style-manager.c (add_gedit_styles_path): 
new 
	function to add the gedit styles dir to the search path of the 
style
	schemes manager
	(gedit_get_source_style_manager): call the add_gedit_styles_path 
	function
	(_gedit_source_style_manager_scheme_is_gedit_user_scheme): new 
function


svn path=/trunk/; revision=5732
parent 5ae8949c
2007-07-20 Paolo Maggi <paolo@gnome.org>
First step toward the new preference dialog
* gedit/dialogs/Makefile.am: compile new files
* gedit/dialogs/gedit-preferences-dialog.c: set the new "Font & Colors"
page
* gedit/dialogs/gedit-preferences-dialog.glade: new "Font & Colors"
page
* gedit/dialogs/gedit-style-scheme-dialog.[ch]: new files
* gedit/dialogs/gedit-style-scheme-dialog.glade: new file
* gedit/dialogs/gedit-style-scheme-generator.[ch]: new file
* gedit/gedit-document.c (gedit_document_init): check the default style
is not NULL before using it
* gedit/gedit-source-style-manager.c (add_gedit_styles_path): new
function to add the gedit styles dir to the search path of the style
schemes manager
(gedit_get_source_style_manager): call the add_gedit_styles_path
function
(_gedit_source_style_manager_scheme_is_gedit_user_scheme): new function
2007-07-19 Jesse van den Kieboom <jesse@icecrew.nl>
* plugins/snippets/snippets/Importer.py:
......
......@@ -444,48 +444,6 @@ gedit-prefs-manager
<!-- ##### MACRO GPM_WINDOW_DIR ##### -->
<para>
</para>
<!-- ##### MACRO GPM_WINDOW_STATE ##### -->
<para>
</para>
<!-- ##### MACRO GPM_WINDOW_WIDTH ##### -->
<para>
</para>
<!-- ##### MACRO GPM_WINDOW_HEIGHT ##### -->
<para>
</para>
<!-- ##### MACRO GPM_SIDE_PANEL_SIZE ##### -->
<para>
</para>
<!-- ##### MACRO GPM_BOTTOM_PANEL_SIZE ##### -->
<para>
</para>
<!-- ##### MACRO GPM_ENCODINGS_DIR ##### -->
<para>
......@@ -787,76 +745,6 @@ gedit-prefs-manager
<!-- ##### MACRO GPM_DEFAULT_WINDOW_STATE ##### -->
<para>
</para>
<!-- ##### MACRO GPM_DEFAULT_WINDOW_WIDTH ##### -->
<para>
</para>
<!-- ##### MACRO GPM_DEFAULT_WINDOW_HEIGHT ##### -->
<para>
</para>
<!-- ##### MACRO GPM_DEFAULT_WINDOW_STATE_STR ##### -->
<para>
</para>
<!-- ##### MACRO GPM_DEFAULT_WINDOW_WIDTH_STR ##### -->
<para>
</para>
<!-- ##### MACRO GPM_DEFAULT_WINDOW_HEIGHT_STR ##### -->
<para>
</para>
<!-- ##### MACRO GPM_DEFAULT_SIDE_PANEL_SIZE ##### -->
<para>
</para>
<!-- ##### MACRO GPM_DEFAULT_BOTTOM_PANEL_SIZE ##### -->
<para>
</para>
<!-- ##### MACRO GPM_DEFAULT_SIDE_PANEL_SIZE_STR ##### -->
<para>
</para>
<!-- ##### MACRO GPM_DEFAULT_BOTTOM_PANEL_SIZE_STR ##### -->
<para>
</para>
<!-- ##### MACRO GPM_DEFAULT_HIGHLIGHT_CURRENT_LINE ##### -->
<para>
......
......@@ -133,6 +133,102 @@ gedit-recent
@obj:
<!-- ##### MACRO GPM_BOTTOM_PANEL_SIZE ##### -->
<para>
</para>
<!-- ##### MACRO GPM_DEFAULT_BOTTOM_PANEL_SIZE ##### -->
<para>
</para>
<!-- ##### MACRO GPM_DEFAULT_BOTTOM_PANEL_SIZE_STR ##### -->
<para>
</para>
<!-- ##### MACRO GPM_DEFAULT_SIDE_PANEL_SIZE ##### -->
<para>
</para>
<!-- ##### MACRO GPM_DEFAULT_SIDE_PANEL_SIZE_STR ##### -->
<para>
</para>
<!-- ##### MACRO GPM_DEFAULT_WINDOW_HEIGHT ##### -->
<para>
</para>
<!-- ##### MACRO GPM_DEFAULT_WINDOW_HEIGHT_STR ##### -->
<para>
</para>
<!-- ##### MACRO GPM_DEFAULT_WINDOW_STATE ##### -->
<para>
</para>
<!-- ##### MACRO GPM_DEFAULT_WINDOW_STATE_STR ##### -->
<para>
</para>
<!-- ##### MACRO GPM_DEFAULT_WINDOW_WIDTH ##### -->
<para>
</para>
<!-- ##### MACRO GPM_DEFAULT_WINDOW_WIDTH_STR ##### -->
<para>
</para>
<!-- ##### MACRO GPM_SIDE_PANEL_SIZE ##### -->
<para>
</para>
<!-- ##### MACRO GPM_WINDOW_DIR ##### -->
<para>
</para>
<!-- ##### MACRO GPM_WINDOW_HEIGHT ##### -->
<para>
</para>
<!-- ##### MACRO GPM_WINDOW_STATE ##### -->
<para>
</para>
<!-- ##### MACRO GPM_WINDOW_WIDTH ##### -->
<para>
</para>
<!-- ##### ARG GeditDocument:has-selection ##### -->
<para>
......
......@@ -25,7 +25,11 @@ libdialogs_la_SOURCES = \
gedit-open-location-dialog.c \
gedit-open-location-dialog.h \
gedit-search-dialog.h \
gedit-search-dialog.c
gedit-search-dialog.c \
gedit-style-scheme-dialog.h \
gedit-style-scheme-dialog.c \
gedit-style-scheme-generator.h \
gedit-style-scheme-generator.c
glade_DATA = \
......@@ -33,7 +37,8 @@ glade_DATA = \
gedit-open-location-dialog.glade \
gedit-page-setup-dialog.glade \
gedit-preferences-dialog.glade \
gedit-search-dialog.glade
gedit-search-dialog.glade \
gedit-style-scheme-dialog.glade
......
This diff is collapsed.
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* gedit-style-scheme-dialog.c
* This file is part of gedit
*
* Copyright (C) 2007 Paolo Borelli
*
* 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, 2001-2003. See the AUTHORS file for a
* list of people on the gedit Team.
* See the ChangeLog files for a list of changes.
*
* $Id: gedit-preferences-dialog.c 5645 2007-06-24 19:42:53Z pborelli $
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <glib/gi18n.h>
#include "gedit-style-scheme-dialog.h"
#include "gedit-utils.h"
#include "gedit-debug.h"
#include "gedit-help.h"
#define GEDIT_STYLE_SCHEME_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
GEDIT_TYPE_STYLE_SCHEME_DIALOG, \
GeditStyleSchemeDialogPrivate))
struct _GeditStyleSchemeDialogPrivate
{
GeditStyleSchemeGenerator *generator;
GtkWidget *main_vbox;
};
G_DEFINE_TYPE(GeditStyleSchemeDialog, gedit_style_scheme_dialog, GTK_TYPE_DIALOG)
static void
gedit_style_scheme_dialog_finalize (GObject *object)
{
GeditStyleSchemeDialog *dlg = GEDIT_STYLE_SCHEME_DIALOG (object);
g_object_unref (dlg->priv->generator);
G_OBJECT_CLASS (gedit_style_scheme_dialog_parent_class)->finalize (object);
}
static void
gedit_style_scheme_dialog_class_init (GeditStyleSchemeDialogClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gedit_style_scheme_dialog_finalize;
g_type_class_add_private (object_class, sizeof(GeditStyleSchemeDialogPrivate));
}
static void
dialog_response_handler (GtkDialog *dlg,
gint res_id)
{
gedit_debug (DEBUG_PREFS);
switch (res_id)
{
case GTK_RESPONSE_HELP:
gedit_help_display (GTK_WINDOW (dlg),
"gedit.xml",
"gedit-prefs"); // FIXME
g_signal_stop_emission_by_name (dlg, "response");
break;
default:
gtk_widget_destroy (GTK_WIDGET(dlg));
}
}
static void
gedit_style_scheme_dialog_init (GeditStyleSchemeDialog *dlg)
{
GtkWidget *error_widget;
gboolean ret;
gedit_debug (DEBUG_PREFS);
dlg->priv = GEDIT_STYLE_SCHEME_DIALOG_GET_PRIVATE (dlg);
gtk_dialog_add_buttons (GTK_DIALOG (dlg),
GTK_STOCK_CLOSE,
GTK_RESPONSE_CLOSE,
GTK_STOCK_HELP,
GTK_RESPONSE_HELP,
NULL);
gtk_window_set_title (GTK_WINDOW (dlg), _("gedit Style Scheme editor"));
gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
g_signal_connect (dlg,
"response",
G_CALLBACK (dialog_response_handler),
NULL);
ret = gedit_utils_get_glade_widgets (GEDIT_GLADEDIR "gedit-style-scheme-dialog.glade",
"contents",
&error_widget,
"contents", &dlg->priv->main_vbox,
NULL);
if (!ret)
{
gtk_widget_show (error_widget);
gtk_box_pack_start_defaults (GTK_BOX (GTK_DIALOG (dlg)->vbox),
error_widget);
return;
}
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
dlg->priv->main_vbox,
FALSE, FALSE, 0);
}
GtkWidget *
gedit_style_scheme_dialog_new (GeditStyleSchemeGenerator *generator)
{
GeditStyleSchemeDialog *dlg;
dlg = GEDIT_STYLE_SCHEME_DIALOG (g_object_new (GEDIT_TYPE_STYLE_SCHEME_DIALOG, NULL));
dlg->priv->generator = g_object_ref (generator);
return GTK_WIDGET (dlg);
}
This diff is collapsed.
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* gedit-style-scheme-dialog.h
* This file is part of gedit
*
* Copyright (C) 2007 Paolo Borelli
*
* 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, 2003. See the AUTHORS file for a
* list of people on the gedit Team.
* See the ChangeLog files for a list of changes.
*
* $Id: gedit-preferences-dialog.h 4429 2005-12-12 17:28:04Z pborelli $
*/
#ifndef __GEDIT_STYLE_SCHEME_DIALOG_H__
#define __GEDIT_STYLE_SCHEME_DIALOG_H__
#include <gtk/gtk.h>
#include "gedit-style-scheme-generator.h"
G_BEGIN_DECLS
/*
* Type checking and casting macros
*/
#define GEDIT_TYPE_STYLE_SCHEME_DIALOG (gedit_style_scheme_dialog_get_type())
#define GEDIT_STYLE_SCHEME_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GEDIT_TYPE_STYLE_SCHEME_DIALOG, GeditStyleSchemeDialog))
#define GEDIT_STYLE_SCHEME_DIALOG_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GEDIT_TYPE_STYLE_SCHEME_DIALOG, GeditStyleSchemeDialog const))
#define GEDIT_STYLE_SCHEME_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GEDIT_TYPE_STYLE_SCHEME_DIALOG, GeditStyleSchemeDialogClass))
#define GEDIT_IS_STYLE_SCHEME_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GEDIT_TYPE_STYLE_SCHEME_DIALOG))
#define GEDIT_IS_STYLE_SCHEME_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_STYLE_SCHEME_DIALOG))
#define GEDIT_STYLE_SCHEME_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GEDIT_TYPE_STYLE_SCHEME_DIALOG, GeditStyleSchemeDialogClass))
/* Private structure type */
typedef struct _GeditStyleSchemeDialogPrivate GeditStyleSchemeDialogPrivate;
/*
* Main object structure
*/
typedef struct _GeditStyleSchemeDialog GeditStyleSchemeDialog;
struct _GeditStyleSchemeDialog
{
GtkDialog dialog;
/*< private > */
GeditStyleSchemeDialogPrivate *priv;
};
/*
* Class definition
*/
typedef struct _GeditStyleSchemeDialogClass GeditStyleSchemeDialogClass;
struct _GeditStyleSchemeDialogClass
{
GtkDialogClass parent_class;
};
/*
* Public methods
*/
GType gedit_style_scheme_dialog_get_type (void) G_GNUC_CONST;
GtkWidget *gedit_style_scheme_dialog_new (GeditStyleSchemeGenerator *generator);
G_END_DECLS
#endif /* __GEDIT_STYLE_SCHEME_DIALOG_H__ */
/*
* gedit-style-scheme-generator.c
* This file is part of gedit
*
* Copyright (C) 2007 - Paolo Maggi
*
* gedit 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.
*
* gedit 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 gedit; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#include "gedit-style-scheme-generator.h"
#include <glib/gi18n.h>
#include <gedit-utils.h>
G_DEFINE_TYPE (GeditStyleSchemeGenerator, gedit_style_scheme_generator, G_TYPE_OBJECT)
#define STYLE_SCHEME_GENERATOR_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GEDIT_TYPE_STYLE_SCHEME_GENERATOR, GeditStyleSchemeGeneratorPrivate))
#define STYLE_TEXT "text"
#define STYLE_SELECTED "selection"
#define STYLE_CURRENT_LINE "current-line"
#define STYLE_SEARCH_MATCH "search-match"
struct _GeditStyleSchemeGeneratorPrivate
{
GtkSourceStyleScheme *original_scheme;
gchar *id;
gchar *name;
gchar *description;
GHashTable *defined_styles;
};
static void
gedit_style_scheme_generator_finalize (GObject *object)
{
GeditStyleSchemeGeneratorPrivate *priv = STYLE_SCHEME_GENERATOR_PRIVATE (object);
if (priv->original_scheme != NULL)
g_object_unref (priv->original_scheme);
g_free (priv->id);
g_free (priv->name);
g_free (priv->description);
g_hash_table_destroy (priv->defined_styles);
G_OBJECT_CLASS (gedit_style_scheme_generator_parent_class)->finalize (object);
}
static void
gedit_style_scheme_generator_class_init (GeditStyleSchemeGeneratorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (GeditStyleSchemeGeneratorPrivate));
object_class->finalize = gedit_style_scheme_generator_finalize;
}
static void
init_defined_styles (GeditStyleSchemeGenerator *generator)
{
gint i = 0;
gchar *basic_styles[] = {STYLE_TEXT, STYLE_SELECTED, STYLE_CURRENT_LINE, STYLE_SEARCH_MATCH, NULL};
g_return_if_fail (generator->priv->original_scheme != NULL);
while (basic_styles[i] != NULL)
{
GtkSourceStyle *style;
style = gtk_source_style_scheme_get_style (generator->priv->original_scheme, basic_styles[i]);
if (style != NULL)
g_hash_table_insert (generator->priv->defined_styles,
g_strdup (basic_styles[i]),
gtk_source_style_copy (style));
++i;
}
}
static void
set_original_scheme (GeditStyleSchemeGenerator *generator,
GtkSourceStyleScheme *scheme)
{
const gchar *cstr;
g_return_if_fail (generator->priv->original_scheme == NULL);
generator->priv->original_scheme = g_object_ref (scheme);
cstr = gtk_source_style_scheme_get_name (scheme);
if (cstr == NULL)
cstr = gtk_source_style_scheme_get_id (scheme);
g_return_if_fail (cstr != NULL);
/* TRANSLATORS: %s is a color scheme name. The resulting string represents
* the name of a color scheme generated by the color scheme in %s.
* So if %s is "Dark", the resulting string should be something like
* "My Dark" */
generator->priv->name = g_strdup_printf (_("My %s"), cstr);
cstr = gtk_source_style_scheme_get_description (scheme);
if (cstr != NULL)
generator->priv->description = g_strdup (cstr);
init_defined_styles (generator);
}
static void
gedit_style_scheme_generator_init (GeditStyleSchemeGenerator *generator)
{
generator->priv = STYLE_SCHEME_GENERATOR_PRIVATE (generator);
generator->priv->defined_styles = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, g_object_unref);
}
GeditStyleSchemeGenerator*
gedit_style_scheme_generator_new (GtkSourceStyleScheme *scheme)
{
GeditStyleSchemeGenerator *generator;
g_return_val_if_fail (GTK_IS_SOURCE_STYLE_SCHEME (scheme), NULL);
generator = g_object_new (GEDIT_TYPE_STYLE_SCHEME_GENERATOR, NULL);
g_return_val_if_fail (generator != NULL, NULL);
set_original_scheme (generator, scheme);
return generator;
}
const gchar *
gedit_style_scheme_generator_get_scheme_name (GeditStyleSchemeGenerator *generator)
{
g_return_val_if_fail (GEDIT_IS_STYLE_SCHEME_GENERATOR (generator), NULL);
g_return_val_if_fail (generator->priv->name != NULL, NULL);
return generator->priv->name;
}
void
gedit_style_scheme_generator_set_scheme_name (GeditStyleSchemeGenerator *generator,
const gchar *name)
{
g_return_if_fail (GEDIT_IS_STYLE_SCHEME_GENERATOR (generator));
g_return_if_fail (name != NULL);
g_free (generator->priv->name);
generator->priv->name = g_strdup (name);
}
const gchar *
gedit_style_scheme_generator_get_scheme_description (GeditStyleSchemeGenerator *generator)
{
g_return_val_if_fail (GEDIT_IS_STYLE_SCHEME_GENERATOR (generator), NULL);
return generator->priv->description;
}
void
gedit_style_scheme_generator_set_scheme_description (GeditStyleSchemeGenerator *generator,
const gchar *description)
{
g_return_if_fail (GEDIT_IS_STYLE_SCHEME_GENERATOR (generator));
g_return_if_fail (description != NULL);
g_free (generator->priv->description);
generator->priv->description = g_strdup (description);
}
static gboolean
get_background_color (GtkSourceStyle *style, GdkColor *color)
{
gboolean bg_set;
gchar *bg_str;
g_object_get (style,
"background", &bg_str,
"background-set", &bg_set,
NULL);
if (!bg_set)
return FALSE;
if (color == NULL)
return TRUE;
if (gdk_color_parse (bg_str, color))
{