Revision: 503 Author: ntrel Date: 2006-06-29 09:55:29 -0700 (Thu, 29 Jun 2006) ViewCVS: http://svn.sourceforge.net/geany/?rev=503&view=rev
Log Message: ----------- Apply fonts in Preferences when they are set and only if they have changed. Rename utils_set_font to utils_set_editor_font. Remove an old comment in document_open_file.
Modified Paths: -------------- trunk/ChangeLog trunk/src/callbacks.c trunk/src/document.c trunk/src/prefs.c trunk/src/utils.c trunk/src/utils.h trunk/src/win32.c Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-06-29 14:00:09 UTC (rev 502) +++ trunk/ChangeLog 2006-06-29 16:55:29 UTC (rev 503) @@ -1,3 +1,11 @@ +2006-06-29 Nick Treleaven nick.treleaven@btinternet.com + + * src/utils.c, src/utils.h, src/win32.c, src/callbacks.c, + src/document.c, src/prefs.c: + Apply fonts in Preferences when they are set and only if they have + changed. Rename utils_set_font to utils_set_editor_font. + + 2006-06-29 Enrico Tröger enrico.troeger@uvena.de
* src/geany.h, src/build.c, src/callbacks.c, src/keyfile.c,
Modified: trunk/src/callbacks.c =================================================================== --- trunk/src/callbacks.c 2006-06-29 14:00:09 UTC (rev 502) +++ trunk/src/callbacks.c 2006-06-29 16:55:29 UTC (rev 503) @@ -932,11 +932,12 @@ on_font_apply_button_clicked (GtkButton *button, gpointer user_data) { - g_free(app->editor_font); - app->editor_font = g_strdup( - gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(app->open_fontsel))); + gchar *fontname;
- utils_set_font(); + fontname = gtk_font_selection_dialog_get_font_name( + GTK_FONT_SELECTION_DIALOG(app->open_fontsel)); + utils_set_editor_font(fontname); + g_free(fontname); }
Modified: trunk/src/document.c =================================================================== --- trunk/src/document.c 2006-06-29 14:00:09 UTC (rev 502) +++ trunk/src/document.c 2006-06-29 16:55:29 UTC (rev 503) @@ -546,8 +546,6 @@ utils_update_recent_menu(); }
- // currently status messages are overridden by update sci SCN_UPDATEUI message - // processing gtk messages first causes a segfault on closing & reloading utils.c if (reload) msgwin_status_add(_("File %s reloaded."), utf8_filename); else
Modified: trunk/src/prefs.c =================================================================== --- trunk/src/prefs.c 2006-06-29 14:00:09 UTC (rev 502) +++ trunk/src/prefs.c 2006-06-29 16:55:29 UTC (rev 503) @@ -450,20 +450,7 @@ utils_widget_show_hide(lookup_widget(app->window, "toolbutton25"), app->pref_main_show_goto); utils_widget_show_hide(lookup_widget(app->window, "separatortoolitem5"), app->pref_main_show_goto); utils_treeviews_showhide(); - for (i = 0; i < GEANY_MAX_OPEN_FILES; i++) - { - if (doc_list[i].is_valid && GTK_IS_WIDGET(doc_list[i].tag_tree)) - gtk_widget_modify_font(doc_list[i].tag_tree, pango_font_description_from_string(app->tagbar_font)); - } - if (GTK_IS_WIDGET(app->default_tag_tree)) - gtk_widget_modify_font(app->default_tag_tree, pango_font_description_from_string(app->tagbar_font)); - gtk_widget_modify_font(lookup_widget(app->window, "entry1"), pango_font_description_from_string(app->tagbar_font)); - gtk_widget_modify_font(msgwindow.tree_compiler, pango_font_description_from_string(app->msgwin_font)); - gtk_widget_modify_font(msgwindow.tree_msg, pango_font_description_from_string(app->msgwin_font)); - gtk_widget_modify_font(msgwindow.tree_status, pango_font_description_from_string(app->msgwin_font));
- utils_set_font(); - // re-colorize all open documents, if tab width or long line settings have changed /* if ((app->pref_editor_tab_width != old_tab_width) || (! utils_strcmp(app->long_line_color, old_long_line_color)) || @@ -539,32 +526,55 @@
void on_prefs_font_choosed(GtkFontButton *widget, gpointer user_data) { + const gchar *fontbtn = gtk_font_button_get_font_name(widget); + gint i; + switch (GPOINTER_TO_INT(user_data)) { case 1: { + if (strcmp(fontbtn, app->tagbar_font) == 0) break; g_free(app->tagbar_font); - app->tagbar_font = g_strdup(gtk_font_button_get_font_name(widget)); + app->tagbar_font = g_strdup(fontbtn); + for (i = 0; i < GEANY_MAX_OPEN_FILES; i++) + { + if (doc_list[i].is_valid && GTK_IS_WIDGET(doc_list[i].tag_tree)) + gtk_widget_modify_font(doc_list[i].tag_tree, + pango_font_description_from_string(app->tagbar_font)); + } + if (GTK_IS_WIDGET(app->default_tag_tree)) + gtk_widget_modify_font(app->default_tag_tree, + pango_font_description_from_string(app->tagbar_font)); + gtk_widget_modify_font(lookup_widget(app->window, "entry1"), + pango_font_description_from_string(app->tagbar_font)); break; } case 2: { + if (strcmp(fontbtn, app->msgwin_font) == 0) break; g_free(app->msgwin_font); - app->msgwin_font = g_strdup(gtk_font_button_get_font_name(widget)); + app->msgwin_font = g_strdup(fontbtn); + gtk_widget_modify_font(msgwindow.tree_compiler, + pango_font_description_from_string(app->msgwin_font)); + gtk_widget_modify_font(msgwindow.tree_msg, + pango_font_description_from_string(app->msgwin_font)); + gtk_widget_modify_font(msgwindow.tree_status, + pango_font_description_from_string(app->msgwin_font)); break; } case 3: { - g_free(app->editor_font); - app->editor_font = g_strdup(gtk_font_button_get_font_name(widget)); + utils_set_editor_font(fontbtn); break; } #ifdef HAVE_VTE case 4: { // VTE settings + if (strcmp(fontbtn, vc->font) == 0) break; g_free(vc->font); vc->font = g_strdup(gtk_font_button_get_font_name(widget)); + vte_apply_user_settings(); break; } #endif
Modified: trunk/src/utils.c =================================================================== --- trunk/src/utils.c 2006-06-29 14:00:09 UTC (rev 502) +++ trunk/src/utils.c 2006-06-29 16:55:29 UTC (rev 503) @@ -355,12 +355,20 @@
-void utils_set_font(void) +void utils_set_editor_font(const gchar *font_name) { gint i, size; gchar *fname; PangoFontDescription *font_desc;
+ g_return_if_fail(font_name != NULL); + // do nothing if font has not changed + if (app->editor_font != NULL) + if (strcmp(font_name, app->editor_font) == 0) return; + + g_free(app->editor_font); + app->editor_font = g_strdup(font_name); + font_desc = pango_font_description_from_string(app->editor_font);
fname = g_strdup_printf("!%s", pango_font_description_get_family(font_desc));
Modified: trunk/src/utils.h =================================================================== --- trunk/src/utils.h 2006-06-29 14:00:09 UTC (rev 502) +++ trunk/src/utils.h 2006-06-29 16:55:29 UTC (rev 503) @@ -57,7 +57,7 @@ /* This sets the window title according to the current filename. */ void utils_set_window_title(gint index);
-void utils_set_font(void); +void utils_set_editor_font(const gchar *font_name);
const GList *utils_get_tag_list(gint idx, guint tag_types);
Modified: trunk/src/win32.c =================================================================== --- trunk/src/win32.c 2006-06-29 14:00:09 UTC (rev 502) +++ trunk/src/win32.c 2006-06-29 16:55:29 UTC (rev 503) @@ -290,9 +290,10 @@ } else { - g_free(app->editor_font); - app->editor_font = g_strdup_printf("%s %d", lf.lfFaceName, (cf.iPointSize / 10)); - utils_set_font(); + gchar *editorfont = g_strdup_printf("%s %d", lf.lfFaceName, + (cf.iPointSize / 10)); + utils_set_editor_font(editorfont); + g_free(editorfont); } }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.