[anjuta-extras] scintilla: bgo #348850 - doesn't respect theme colours
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta-extras] scintilla: bgo #348850 - doesn't respect theme colours
- Date: Thu, 8 Mar 2012 21:42:42 +0000 (UTC)
commit 2045f2ebe8ae12e1eb5f8459753376059bd7700b
Author: SÃbastien Granjoux <seb sfo free fr>
Date: Thu Mar 8 22:41:40 2012 +0100
scintilla: bgo #348850 - doesn't respect theme colours
plugins/scintilla/aneditor-priv.h | 25 ++--
plugins/scintilla/aneditor.cxx | 24 ++++
plugins/scintilla/style-editor.c | 264 +++++++++++++++++++++++--------------
plugins/scintilla/text_editor.c | 1 +
4 files changed, 200 insertions(+), 114 deletions(-)
---
diff --git a/plugins/scintilla/aneditor-priv.h b/plugins/scintilla/aneditor-priv.h
index 1c6e567..3913b82 100644
--- a/plugins/scintilla/aneditor-priv.h
+++ b/plugins/scintilla/aneditor-priv.h
@@ -135,7 +135,7 @@ typedef struct _CallTipNode {
int rootlen;
int start_pos; // start position in editor
int call_tip_start_pos; // start position in calltip
-
+
} CallTipNode, *CallTipNode_ptr;
// Related to Utf8_16::encodingType but with additional values at end
@@ -173,7 +173,7 @@ protected:
bool indentOpening;
bool indentClosing;
*/
-
+
bool indentMaintain;
bool indentAutomatic;
/*
@@ -188,7 +188,7 @@ protected:
WordList preprocCondMiddle; ///< List of preprocessor conditional middle keywords (in C: else elif)
WordList preprocCondEnd; ///< List of preprocessor conditional end keywords (in C: endif)
*/
-
+
Window wEditor;
SciFnDirect fnEditor;
@@ -231,15 +231,15 @@ protected:
SString autoCompleteFillUpCharacters;
SString wordCharacters;
int startCalltipWord;
-
+
GQueue *call_tip_node_queue;
CallTipNode call_tip_node;
-
+
GCompletion *autocompletion;
-
+
// needed for calltips caret moving
int lastPos;
-
+
bool margin;
int marginWidth;
enum { marginWidthDefault = 20};
@@ -256,7 +256,7 @@ protected:
bool clearBeforeExecute;
bool allowMenuActions;
bool isDirty;
-
+
bool calltipShown;
//bool debugTipOn;
static AnEditorID focusedID;
@@ -290,7 +290,7 @@ protected:
void IndentationIncrease();
void IndentationDecrease();
-
+
void ClearDocument();
void CountLineEnds(int &linesCR, int &linesLF, int &linesCRLF);
CharacterRange GetSelection();
@@ -321,7 +321,7 @@ protected:
bool CanBeCommented(bool box_stream);
bool StartBoxComment();
bool StartStreamComment();
- // SString GetMode(SString language);
+ // SString GetMode(SString language);
// bool InsertCustomIndent();
// unsigned int GetLinePartsInStyle(int line, int style1, int style2,
@@ -337,7 +337,7 @@ protected:
void CharAdded(char ch);
void FoldChanged(int line, int levelNow, int levelPrev);
void FoldChanged(int position);
- void Expand(int &line, bool doExpand, bool force=false,
+ void Expand(int &line, bool doExpand, bool force=false,
int visLevels=0, int level=-1);
bool MarginClick(int position,int modifiers);
//void HandleDwellStart(int mousePos);
@@ -358,6 +358,7 @@ protected:
void AssignKey(int key, int mods, int cmd);
StyleAndWords GetStyleAndWords(const char *base);
+ void SetGtkStyle(Window &win, int style);
void SetOneStyle(Window &win, int style, const char *s);
void SetStyleFor(Window &win, const char *language);
SString ExtensionFileName();
@@ -396,7 +397,7 @@ protected:
void SetReadOnly(bool readonly);
void SetFoldSymbols(SString fold_symbols);
bool iswordcharforsel(char ch);
-
+
public:
AnEditor(PropSetFile* p);
diff --git a/plugins/scintilla/aneditor.cxx b/plugins/scintilla/aneditor.cxx
index 1c81b20..5e0f8aa 100644
--- a/plugins/scintilla/aneditor.cxx
+++ b/plugins/scintilla/aneditor.cxx
@@ -2354,6 +2354,28 @@ static long ColourOfProperty(PropSetFile *props, const char *key, ColourDesired
return colourDefault.AsLong();
}
+void AnEditor::SetGtkStyle(Window &win, int style) {
+ GtkWidgetPath *path;
+ GtkStyleContext *context;
+ GdkRGBA fore;
+ GdkRGBA back;
+ const PangoFontDescription *desc;
+
+ /* Get theme style information for view widget */
+ path = gtk_widget_path_new ();
+ gtk_widget_path_append_type (path, GTK_TYPE_WIDGET);
+ context = gtk_style_context_new ();
+ gtk_style_context_set_path (context, path);
+ gtk_widget_path_free (path);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_VIEW);
+ gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &fore);
+ gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &back);
+ g_object_unref (context);
+
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETFORE, style, (gint)(fore.red * 255) | ((gint)(fore.green * 255) << 8) | ((gint)(fore.blue *255) << 16));
+ Platform::SendScintilla(win.GetID(), SCI_STYLESETBACK, style, (gint)(back.red * 255) | ((gint)(back.green * 255) << 8) | ((gint)(back.blue *255) << 16));
+}
+
void AnEditor::SetOneStyle(Window &win, int style, const char *s) {
char *val = StringDup(s);
char *opt = val;
@@ -2751,6 +2773,8 @@ void AnEditor::ReadProperties(const char *fileForExt, char **typedef_hl) {
SendEditor(SCI_STYLERESETDEFAULT, 0, 0);
+ SetGtkStyle(wEditor, STYLE_DEFAULT);
+
sprintf(key, "style.%s.%0d", "*", STYLE_DEFAULT);
sval = props->GetNewExpand(key, "");
SetOneStyle(wEditor, STYLE_DEFAULT, sval.c_str());
diff --git a/plugins/scintilla/style-editor.c b/plugins/scintilla/style-editor.c
index f2d28c9..57b0b9f 100644
--- a/plugins/scintilla/style-editor.c
+++ b/plugins/scintilla/style-editor.c
@@ -99,8 +99,9 @@ struct _StyleEditorPriv
GtkWidget *selection_fore_color;
GtkWidget *selection_back_color;
GtkWidget *calltip_back_color;
-
+
/* Data */
+ StyleData gtk_style;
StyleData *default_style;
StyleData *current_style;
@@ -114,7 +115,7 @@ style_data_get_string (StyleData * sdata)
gchar *tmp, *str;
g_return_val_if_fail (sdata != NULL, NULL);
-
+
str = NULL;
if ((sdata->font) && strlen (sdata->font) && sdata->font_use_default == FALSE)
{
@@ -261,13 +262,13 @@ style_data_set_font (StyleData * sdata, const gchar *font)
{
PangoFontDescription *desc;
const gchar *font_family;
-
+
g_return_if_fail (sdata);
-
+
desc = pango_font_description_from_string (font);
font_family = pango_font_description_get_family(desc);
string_assign (&sdata->font, font_family);
-
+
/* Change to lower case */
if (sdata->font)
{
@@ -285,9 +286,9 @@ static void
style_data_set_font_size_from_pango (StyleData * sdata, const gchar *font)
{
PangoFontDescription *desc;
-
+
g_return_if_fail (sdata);
-
+
desc = pango_font_description_from_string (font);
sdata->size = pango_font_description_get_size (desc) / PANGO_SCALE;
pango_font_description_free (desc);
@@ -296,14 +297,14 @@ style_data_set_font_size_from_pango (StyleData * sdata, const gchar *font)
static void
style_data_set_fore (StyleData * sdata, const gchar *fore)
{
- g_return_if_fail (sdata);
+ g_return_if_fail (sdata);
string_assign (&sdata->fore, fore);
}
static void
style_data_set_back (StyleData * sdata, const gchar *back)
{
- g_return_if_fail (sdata);
+ g_return_if_fail (sdata);
string_assign (&sdata->back, back);
}
@@ -319,7 +320,7 @@ style_data_new (void)
{
StyleData *sdata;
sdata = g_new0 (StyleData, 1);
-
+
sdata->font = g_strdup ("");
sdata->size = 12;
sdata->font_use_default = TRUE;
@@ -332,6 +333,25 @@ style_data_new (void)
}
static void
+style_data_copy (StyleData *sdata, const StyleData *src)
+{
+ string_assign (&sdata->item, src->item);
+ string_assign (&sdata->font, src->font);
+ sdata->size = src->size;
+ sdata->bold = src->bold;
+ sdata->italics = src->italics;
+ sdata->underlined = src->underlined;
+ sdata->eolfilled = src->eolfilled;
+ string_assign (&sdata->fore, src->fore);
+ string_assign (&sdata->back, src->back);
+
+ sdata->font_use_default = src->font_use_default;
+ sdata->attrib_use_default = src->attrib_use_default;
+ sdata->fore_use_default = src->fore_use_default;
+ sdata->back_use_default = src->back_use_default;
+}
+
+static void
style_data_destroy (StyleData * sdata)
{
if (!sdata)
@@ -347,15 +367,10 @@ style_data_destroy (StyleData * sdata)
g_free (sdata);
}
-static StyleData *
-style_data_new_parse (gchar * style_string)
+void
+style_data_parse (StyleData *style_data, gchar * style_string)
{
gchar *val, *opt;
- StyleData *style_data;
-
- style_data = style_data_new ();
- if (!style_data)
- return NULL;
val = (style_string != NULL)? g_strdup (style_string) : NULL;
opt = val;
@@ -440,11 +455,51 @@ style_data_new_parse (gchar * style_string)
}
static void
+sync_from_gtk (StyleEditor *se)
+{
+ GtkWidgetPath *path;
+ GtkStyleContext *context;
+ GdkRGBA fore;
+ GdkRGBA back;
+ const PangoFontDescription *desc;
+
+ /* Get theme style information for view widget */
+ path = gtk_widget_path_new ();
+ gtk_widget_path_append_type (path, GTK_TYPE_WIDGET);
+ context = gtk_style_context_new ();
+ gtk_style_context_set_path (context, path);
+ gtk_widget_path_free (path);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_VIEW);
+ gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &fore);
+ gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &back);
+ desc = gtk_style_context_get_font (context, GTK_STATE_FLAG_NORMAL);
+
+ se->priv->gtk_style.item = NULL;
+ if (se->priv->gtk_style.font != NULL) g_free (se->priv->gtk_style.font);
+ se->priv->gtk_style.font = g_strdup (pango_font_description_get_family(desc));
+ se->priv->gtk_style.size = pango_font_description_get_size (desc) / PANGO_SCALE;
+ se->priv->gtk_style.bold = pango_font_description_get_weight (desc) >= PANGO_WEIGHT_BOLD;
+ se->priv->gtk_style.italics = pango_font_description_get_style (desc) != PANGO_STYLE_NORMAL;
+ se->priv->gtk_style.underlined = FALSE;
+ se->priv->gtk_style.eolfilled = FALSE;
+ if (se->priv->gtk_style.fore != NULL) g_free (se->priv->gtk_style.fore);
+ se->priv->gtk_style.fore = anjuta_util_string_from_color ((gint)(fore.red * 65535), (gint)(fore.green * 65535), (gint)(fore.blue *65535));
+ if (se->priv->gtk_style.back != NULL) g_free (se->priv->gtk_style.back);
+ se->priv->gtk_style.back = anjuta_util_string_from_color ((gint)(back.red * 65535), (gint)(back.green * 65535), (gint)(back.blue *65535));
+ g_object_unref (context);
+
+ se->priv->gtk_style.font_use_default = TRUE;
+ se->priv->gtk_style.attrib_use_default = TRUE;
+ se->priv->gtk_style.fore_use_default = TRUE;
+ se->priv->gtk_style.back_use_default = TRUE;
+}
+
+static void
sync_from_props (StyleEditor *se)
{
gint i;
gchar *str;
-
+
g_return_if_fail (se);
/* Never hurts to use g_object_*_data as temp hash buffer */
for (i = 0;; i += 2)
@@ -454,7 +509,10 @@ sync_from_props (StyleEditor *se)
if (hilite_style[i] == NULL)
break;
str = sci_prop_get_expanded (se->props, hilite_style[i + 1]);
- sdata = style_data_new_parse (str);
+ sdata = style_data_new ();
+ /* Copy GTK style in the first style */
+ if (i == 0) style_data_copy (sdata, &se->priv->gtk_style);
+ style_data_parse (sdata, str);
/* DEBUG_PRINT ("Parsing %s => %s", hilite_style[i + 1], str); */
if (str)
g_free (str);
@@ -473,7 +531,7 @@ sync_from_props (StyleEditor *se)
if(str)
{
GdkColor color;
-
+
gdk_color_parse (str, &color);
gtk_color_button_set_color (GTK_COLOR_BUTTON (se->priv->caret_fore_color),
&color);
@@ -482,7 +540,7 @@ sync_from_props (StyleEditor *se)
else
{
GdkColor color;
-
+
gdk_color_parse ("#000000", &color);
gtk_color_button_set_color (GTK_COLOR_BUTTON (se->priv->caret_fore_color),
&color);
@@ -492,7 +550,7 @@ sync_from_props (StyleEditor *se)
if(str)
{
GdkColor color;
-
+
gdk_color_parse (str, &color);
gtk_color_button_set_color (GTK_COLOR_BUTTON (se->priv->calltip_back_color),
&color);
@@ -501,17 +559,17 @@ sync_from_props (StyleEditor *se)
else
{
GdkColor color;
-
+
gdk_color_parse ("#E6D6B6", &color);
gtk_color_button_set_color (GTK_COLOR_BUTTON (se->priv->calltip_back_color),
&color);
}
-
+
str = sci_prop_get (se->props, SELECTION_FORE_COLOR);
if(str)
{
GdkColor color;
-
+
gdk_color_parse (str, &color);
gtk_color_button_set_color (GTK_COLOR_BUTTON (se->priv->selection_fore_color),
&color);
@@ -520,17 +578,17 @@ sync_from_props (StyleEditor *se)
else
{
GdkColor color;
-
+
gdk_color_parse ("#FFFFFF", &color);
gtk_color_button_set_color (GTK_COLOR_BUTTON (se->priv->selection_fore_color),
&color);
}
-
+
str = sci_prop_get (se->props, SELECTION_BACK_COLOR);
if(str)
{
GdkColor color;
-
+
gdk_color_parse (str, &color);
gtk_color_button_set_color (GTK_COLOR_BUTTON (se->priv->selection_back_color),
&color);
@@ -539,7 +597,7 @@ sync_from_props (StyleEditor *se)
else
{
GdkColor color;
-
+
gdk_color_parse ("#000000", &color);
gtk_color_button_set_color (GTK_COLOR_BUTTON (se->priv->selection_back_color),
&color);
@@ -561,7 +619,7 @@ set_one_color (PropsID props, gchar *key, GtkWidget *picker)
g_free (str);
}
}
-
+
static void
sync_to_props (StyleEditor *se)
{
@@ -569,7 +627,7 @@ sync_to_props (StyleEditor *se)
gchar *str;
g_return_if_fail (se);
-
+
/* Transfer to props */
for (i = 0;; i += 2)
{
@@ -587,16 +645,16 @@ sync_to_props (StyleEditor *se)
g_free (str);
}
}
- set_one_color (se->props, CARET_FORE_COLOR,
+ set_one_color (se->props, CARET_FORE_COLOR,
se->priv->caret_fore_color);
-
- set_one_color (se->props, CALLTIP_BACK_COLOR,
+
+ set_one_color (se->props, CALLTIP_BACK_COLOR,
se->priv->calltip_back_color);
-
- set_one_color (se->props, SELECTION_FORE_COLOR,
+
+ set_one_color (se->props, SELECTION_FORE_COLOR,
se->priv->selection_fore_color);
-
- set_one_color (se->props, SELECTION_BACK_COLOR,
+
+ set_one_color (se->props, SELECTION_BACK_COLOR,
se->priv->selection_back_color);
}
@@ -607,12 +665,13 @@ on_hilite_style_item_changed (StyleEditor *se)
gchar *style_item;
StyleData *used_style;
StyleData *current_style;
+ StyleData *default_style;
PangoFontDescription *desc;
gchar *font_name;
GdkColor color;
-
-
+
+
/* Find current style */
style_item = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (se->priv->hilite_item_combobox));
if (style_item != NULL)
@@ -625,59 +684,63 @@ on_hilite_style_item_changed (StyleEditor *se)
/* Disable current style to avoid changed notification */
se->priv->current_style = NULL;
-
+
+ /* Default style is Gtk for first style or first style for other one */
+ default_style = current_style == se->priv->default_style ? &se->priv->gtk_style : se->priv->default_style;
+
/* Get font */
used_style = ((current_style->font_use_default) ||
- (current_style->font == NULL) ||
- (*(current_style->font) == '\0')) ? se->priv->default_style : current_style;
+ (current_style->font == NULL) ||
+ (*(current_style->font) == '\0')) ? default_style : current_style;
desc = pango_font_description_from_string (used_style->font);
pango_font_description_set_size (desc, used_style->size * PANGO_SCALE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(se->priv->font_use_default_check), se->priv->default_style == used_style);
- gtk_widget_set_sensitive (se->priv->font_use_default_check, current_style != se->priv->default_style);
- gtk_widget_set_sensitive (se->priv->font_picker, current_style == used_style);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(se->priv->font_use_default_check), used_style != current_style);
+ gtk_widget_set_sensitive (se->priv->font_use_default_check, TRUE);
+ gtk_widget_set_sensitive (se->priv->font_picker, used_style == current_style);
/* Get attribute */
used_style = current_style->attrib_use_default ?
- se->priv->default_style : current_style;
+ default_style : current_style;
if (used_style->bold) pango_font_description_set_weight (desc, PANGO_WEIGHT_BOLD);
if (used_style->italics) pango_font_description_set_style (desc, PANGO_STYLE_ITALIC);
font_name = pango_font_description_to_string (desc);
+ pango_font_description_free (desc);
gtk_font_button_set_font_name (GTK_FONT_BUTTON (se->priv->font_picker), font_name);
g_free (font_name);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(se->priv->font_attrib_use_default_check), se->priv->default_style == used_style);
- gtk_widget_set_sensitive (se->priv->font_attrib_use_default_check, current_style != se->priv->default_style);
-
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(se->priv->font_attrib_use_default_check), used_style != current_style);
+ gtk_widget_set_sensitive (se->priv->font_attrib_use_default_check, TRUE);
+
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(se->priv->font_bold_check), used_style->bold);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(se->priv->font_italics_check), used_style->italics);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(se->priv->font_underlined_check), used_style->underlined);
- gtk_widget_set_sensitive (se->priv->font_bold_check, current_style == used_style);
- gtk_widget_set_sensitive (se->priv->font_italics_check, current_style == used_style);
- gtk_widget_set_sensitive (se->priv->font_underlined_check, current_style == used_style);
+ gtk_widget_set_sensitive (se->priv->font_bold_check, used_style == current_style);
+ gtk_widget_set_sensitive (se->priv->font_italics_check, used_style == current_style);
+ gtk_widget_set_sensitive (se->priv->font_underlined_check, used_style == current_style);
/* Get foreground color */
used_style = current_style->fore_use_default ?
- se->priv->default_style : current_style;
+ default_style : current_style;
gdk_color_parse (used_style->fore, &color);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(se->priv->fore_color_use_default_check), se->priv->default_style == used_style);
- gtk_widget_set_sensitive (se->priv->fore_color_use_default_check, current_style != se->priv->default_style);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(se->priv->fore_color_use_default_check), used_style != current_style);
+ gtk_widget_set_sensitive (se->priv->fore_color_use_default_check, TRUE);
gtk_color_button_set_color (GTK_COLOR_BUTTON (se->priv->fore_colorpicker), &color);
- gtk_widget_set_sensitive (se->priv->fore_colorpicker, current_style == used_style);
+ gtk_widget_set_sensitive (se->priv->fore_colorpicker, used_style == current_style);
/* Get background color */
used_style = current_style->back_use_default ?
- se->priv->default_style : current_style;
+ default_style : current_style;
gdk_color_parse (used_style->back, &color);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(se->priv->back_color_use_default_check), se->priv->default_style == used_style);
- gtk_widget_set_sensitive (se->priv->back_color_use_default_check, current_style != se->priv->default_style);
-
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(se->priv->back_color_use_default_check), used_style != current_style);
+ gtk_widget_set_sensitive (se->priv->back_color_use_default_check, TRUE);
+
gtk_color_button_set_color (GTK_COLOR_BUTTON (se->priv->back_colorpicker), &color);
- gtk_widget_set_sensitive (se->priv->back_colorpicker, current_style == used_style);
+ gtk_widget_set_sensitive (se->priv->back_colorpicker, used_style == current_style);
/* Set current style after setting all entries */
se->priv->current_style = current_style;
@@ -691,7 +754,7 @@ on_font_changed (StyleEditor *se)
const gchar *font;
if (se->priv->current_style == NULL) return;
-
+
font = gtk_font_button_get_font_name (GTK_FONT_BUTTON (se->priv->font_picker));
if (font)
{
@@ -708,13 +771,13 @@ on_font_changed (StyleEditor *se)
style_data_set_font_size_from_pango (se->priv->current_style, font);
se->priv->current_style->bold = bold;
se->priv->current_style->italics = italic;
-
+
underline = se->priv->current_style->attrib_use_default ? se->priv->default_style->underlined :se->priv->current_style->underlined;
se->priv->current_style->attrib_use_default = ((bold == se->priv->default_style->bold) &&
(italic == se->priv->default_style->italics) &&
(underline == se->priv->default_style->underlined) &&
(se->priv->current_style != se->priv->default_style));
-
+
/* Changing bold and italic attribute could need a change in font */
on_hilite_style_item_changed (se);
@@ -734,7 +797,7 @@ on_hilite_style_entry_changed (StyleEditor *se)
g_return_if_fail (se);
if (se->priv->current_style == NULL) return;
-
+
font = gtk_font_button_get_font_name (GTK_FONT_BUTTON
(se->priv->font_picker));
if (font)
@@ -748,7 +811,7 @@ on_hilite_style_entry_changed (StyleEditor *se)
se->priv->default_style->font);
se->priv->current_style->size = se->priv->default_style->size;
}
-
+
se->priv->current_style->bold =
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(se->priv->font_bold_check));
@@ -775,28 +838,18 @@ on_hilite_style_entry_changed (StyleEditor *se)
style_data_set_back (se->priv->current_style, str);
g_free (str);
- if (se->priv->current_style == se->priv->default_style)
- {
- se->priv->current_style->font_use_default = FALSE;
- se->priv->current_style->attrib_use_default = FALSE;
- se->priv->current_style->fore_use_default = FALSE;
- se->priv->current_style->back_use_default = FALSE;
- }
- else
- {
- se->priv->current_style->font_use_default =
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (se->priv->font_use_default_check));
- se->priv->current_style->attrib_use_default =
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (se->priv->font_attrib_use_default_check));
- se->priv->current_style->fore_use_default =
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (se->priv->fore_color_use_default_check));
- se->priv->current_style->back_use_default =
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (se->priv->back_color_use_default_check));
- }
+ se->priv->current_style->font_use_default =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (se->priv->font_use_default_check));
+ se->priv->current_style->attrib_use_default =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (se->priv->font_attrib_use_default_check));
+ se->priv->current_style->fore_use_default =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (se->priv->fore_color_use_default_check));
+ se->priv->current_style->back_use_default =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (se->priv->back_color_use_default_check));
/* Changing bold and italic attribute could need a change in font */
on_hilite_style_item_changed (se);
@@ -810,7 +863,7 @@ save_props (StyleEditor *se)
{
gint i;
gchar *str;
-
+
g_return_if_fail (se);
for (i = 0;; i += 2)
@@ -840,9 +893,9 @@ restore_props (StyleEditor *se)
{
gint i;
GList *str;
-
+
g_return_if_fail (se);
-
+
/* Transfer to props */
str = g_list_first (se->priv->saved_props);
for (i = 0;; i += 2)
@@ -879,7 +932,7 @@ apply_styles (StyleEditor *se)
{
FILE *ofile;
gchar *filename;
-
+
filename = anjuta_util_get_user_config_file_path ("scintilla","editor-style.properties",NULL);
ofile = fopen (filename, "w");
if (!ofile) {
@@ -906,7 +959,7 @@ static void
on_response (GtkWidget *dialog, gint res, StyleEditor *se)
{
g_return_if_fail (se);
-
+
switch (res)
{
case GTK_RESPONSE_OK:
@@ -940,7 +993,7 @@ create_style_editor_gui (StyleEditor * se)
g_return_if_fail (se);
g_return_if_fail (se->priv->dialog == NULL);
-
+
if (!gtk_builder_add_from_file (bxml, GLADE_FILE, &error))
{
g_warning ("Couldn't load builder file: %s", error->message);
@@ -964,7 +1017,7 @@ create_style_editor_gui (StyleEditor * se)
se->priv->calltip_back_color = GTK_WIDGET (gtk_builder_get_object (bxml, "calltip"));
se->priv->selection_fore_color = GTK_WIDGET (gtk_builder_get_object (bxml, "selection_fore"));
se->priv->selection_back_color = GTK_WIDGET (gtk_builder_get_object (bxml, "selection_back"));
-
+
/* Fill combo box with modules */
store = gtk_list_store_new(1, G_TYPE_STRING);
gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (se->priv->hilite_item_combobox), 0);
@@ -972,7 +1025,7 @@ create_style_editor_gui (StyleEditor * se)
for (i = 0;; i += 2)
{
GtkTreeIter iter;
-
+
if (hilite_style[i] == NULL)
break;
gtk_list_store_append (store, &iter);
@@ -981,11 +1034,11 @@ create_style_editor_gui (StyleEditor * se)
gtk_combo_box_set_model (GTK_COMBO_BOX(se->priv->hilite_item_combobox), GTK_TREE_MODEL(store));
g_object_unref (store);
gtk_combo_box_set_active (GTK_COMBO_BOX (se->priv->hilite_item_combobox), 0);
-
+
pref_dialog = anjuta_preferences_get_dialog (se->prefs);
gtk_window_set_transient_for (GTK_WINDOW (se->priv->dialog),
GTK_WINDOW (pref_dialog));
-
+
g_signal_connect_swapped (se->priv->hilite_item_combobox, "changed", G_CALLBACK (on_hilite_style_item_changed),
se);
g_signal_connect_swapped (G_OBJECT (se->priv->font_use_default_check),
@@ -1045,6 +1098,12 @@ style_editor_new (AnjutaPlugin *plugin, AnjutaPreferences *prefs, GSettings *set
void style_editor_destroy (StyleEditor *se)
{
g_return_if_fail (se);
+
+ g_free (se->priv->gtk_style.item);
+ g_free (se->priv->gtk_style.font);
+ g_free (se->priv->gtk_style.fore);
+ g_free (se->priv->gtk_style.back);
+
if (se->priv->dialog)
gtk_widget_destroy (se->priv->dialog);
free_saved_props (se);
@@ -1060,6 +1119,7 @@ void style_editor_show (StyleEditor *se)
if (se->priv->dialog)
return;
create_style_editor_gui (se);
+ sync_from_gtk (se);
sync_from_props (se);
save_props (se);
on_hilite_style_item_changed (se);
@@ -1079,7 +1139,7 @@ style_editor_save (StyleEditor *se, FILE *fp)
{
gint i;
gchar *str;
-
+
for (i = 0;; i += 2)
{
if (hilite_style[i] == NULL)
@@ -1106,14 +1166,14 @@ style_editor_save (StyleEditor *se, FILE *fp)
fprintf (fp, "%s=%s\n", CALLTIP_BACK_COLOR, str);
g_free (str);
}
-
+
str = sci_prop_get (se->props, SELECTION_FORE_COLOR);
if(str)
{
fprintf (fp, "%s=%s\n", SELECTION_FORE_COLOR, str);
g_free (str);
}
-
+
str = sci_prop_get (se->props, SELECTION_BACK_COLOR);
if(str)
{
diff --git a/plugins/scintilla/text_editor.c b/plugins/scintilla/text_editor.c
index eb24ae7..2d55377 100644
--- a/plugins/scintilla/text_editor.c
+++ b/plugins/scintilla/text_editor.c
@@ -678,6 +678,7 @@ text_editor_new (AnjutaPlugin *plugin, const gchar *uri, const gchar *name)
g_signal_connect_swapped (G_OBJECT (shell), "value-added", G_CALLBACK (on_shell_value_changed), te);
g_signal_connect_swapped (G_OBJECT (shell), "value-removed", G_CALLBACK (on_shell_value_changed), te);
g_signal_connect_swapped (G_OBJECT (plugin), "style-changed", G_CALLBACK(on_style_changed), te);
+ g_signal_connect_swapped (G_OBJECT (te), "style-updated", G_CALLBACK(on_style_changed), te);
g_signal_connect_swapped (G_OBJECT(te->msgman_settings), "changed", G_CALLBACK (on_indicators_changed), te);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]