Commit e7a619ca authored by Morten Welinder's avatar Morten Welinder

GUI: Style links in the function selector too.

parent 9be7b912
2013-04-24 Morten Welinder <terra@gnome.org>
* dialog-function-select.c (dialog_function_select_init): Style
links.
2013-04-22 Morten Welinder <terra@gnome.org> 2013-04-22 Morten Welinder <terra@gnome.org>
* dialog-recent.c (cb_response): Destroy dialog before reading. * dialog-recent.c (cb_response): Destroy dialog before reading.
......
...@@ -565,7 +565,7 @@ dialog_function_select_cat_row_separator (GtkTreeModel *model, ...@@ -565,7 +565,7 @@ dialog_function_select_cat_row_separator (GtkTreeModel *model,
/*************************************************************************/ /*************************************************************************/
static GtkTextTag * static GtkTextTag *
make_link (GtkTextBuffer *description, const char *name, make_link (GtkTextBuffer *description, GtkWidget *target, const char *name,
GCallback cb, gpointer user) GCallback cb, gpointer user)
{ {
GtkTextTag *link = GtkTextTag *link =
...@@ -573,12 +573,21 @@ make_link (GtkTextBuffer *description, const char *name, ...@@ -573,12 +573,21 @@ make_link (GtkTextBuffer *description, const char *name,
(gtk_text_buffer_get_tag_table (description), name); (gtk_text_buffer_get_tag_table (description), name);
if (!link) { if (!link) {
GdkColor *link_color = NULL;
char *link_color_text;
gtk_widget_style_get (target, "link-color", &link_color, NULL);
link_color_text = gdk_color_to_string (link_color);
gdk_color_free (link_color);
link = gtk_text_buffer_create_tag link = gtk_text_buffer_create_tag
(description, name, (description, name,
"underline", PANGO_UNDERLINE_SINGLE, "underline", PANGO_UNDERLINE_SINGLE,
"foreground", "#0000ff", "foreground", link_color_text,
NULL); NULL);
g_free (link_color_text);
if (cb) if (cb)
g_signal_connect (link, "event", cb, user); g_signal_connect (link, "event", cb, user);
} }
...@@ -694,7 +703,9 @@ make_expr_example (Sheet *sheet, const char *text, gboolean localized) ...@@ -694,7 +703,9 @@ make_expr_example (Sheet *sheet, const char *text, gboolean localized)
} }
static void static void
describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *sheet) describe_new_style (GtkTextBuffer *description,
GtkWidget *target,
GnmFunc const *func, Sheet *sheet)
{ {
GnmFuncHelp const *help; GnmFuncHelp const *help;
GtkTextIter ti; GtkTextIter ti;
...@@ -784,7 +795,8 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *shee ...@@ -784,7 +795,8 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *shee
const char *text = help->text; /* Not translated */ const char *text = help->text; /* Not translated */
const char *pre = _("See also: "); const char *pre = _("See also: ");
GtkTextTag *link = GtkTextTag *link =
make_link (description, "LINK", NULL, NULL); make_link (description, target, "LINK",
NULL, NULL);
FINISH_ARGS; FINISH_ARGS;
ADD_TEXT ("\n"); ADD_TEXT ("\n");
...@@ -824,9 +836,8 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *shee ...@@ -824,9 +836,8 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *shee
tagname = g_strdup_printf ("EXTLINK-%s", func->name); tagname = g_strdup_printf ("EXTLINK-%s", func->name);
link = make_link link = make_link
(description, tagname, (description, target, tagname,
G_CALLBACK (cb_link_event), G_CALLBACK (cb_link_event), NULL);
NULL);
g_object_set_data_full (G_OBJECT (link), g_object_set_data_full (G_OBJECT (link),
"uri", uri, "uri", uri,
...@@ -1014,7 +1025,7 @@ cb_dialog_function_select_fun_selection_changed (GtkTreeSelection *selection, ...@@ -1014,7 +1025,7 @@ cb_dialog_function_select_fun_selection_changed (GtkTreeSelection *selection,
GtkTextMark *mark; GtkTextMark *mark;
gboolean active = FALSE; gboolean active = FALSE;
description = gtk_text_view_get_buffer (state->description_view); description = gtk_text_view_get_buffer (state->description_view);
mark = gtk_text_buffer_get_mark (description, "start-mark"); mark = gtk_text_buffer_get_mark (description, "start-mark");
gtk_text_view_scroll_to_mark (state->description_view, mark, gtk_text_view_scroll_to_mark (state->description_view, mark,
...@@ -1031,7 +1042,9 @@ cb_dialog_function_select_fun_selection_changed (GtkTreeSelection *selection, ...@@ -1031,7 +1042,9 @@ cb_dialog_function_select_fun_selection_changed (GtkTreeSelection *selection,
if (func->help == NULL) if (func->help == NULL)
gtk_text_buffer_set_text (description, "?", -1); gtk_text_buffer_set_text (description, "?", -1);
else else
describe_new_style (description, func, state->sheet); describe_new_style (description,
GTK_WIDGET (state->description_view),
func, state->sheet);
active = TRUE; active = TRUE;
} }
gtk_widget_set_sensitive (state->ok_button, active); gtk_widget_set_sensitive (state->ok_button, active);
...@@ -1223,7 +1236,7 @@ dialog_function_select_init (FunctionSelectState *state) ...@@ -1223,7 +1236,7 @@ dialog_function_select_init (FunctionSelectState *state)
gtk_tree_model_filter_set_visible_column gtk_tree_model_filter_set_visible_column
(GTK_TREE_MODEL_FILTER (state->model_filter), FUNCTION_VISIBLE); (GTK_TREE_MODEL_FILTER (state->model_filter), FUNCTION_VISIBLE);
state->treeview= GTK_TREE_VIEW state->treeview = GTK_TREE_VIEW
(go_gtk_builder_get_widget (state->gui, "function-list")); (go_gtk_builder_get_widget (state->gui, "function-list"));
gtk_tree_view_set_model (state->treeview, gtk_tree_view_set_model (state->treeview,
state->model_filter); state->model_filter);
...@@ -1295,6 +1308,9 @@ dialog_function_select_init (FunctionSelectState *state) ...@@ -1295,6 +1308,9 @@ dialog_function_select_init (FunctionSelectState *state)
state->description_view = GTK_TEXT_VIEW (go_gtk_builder_get_widget state->description_view = GTK_TEXT_VIEW (go_gtk_builder_get_widget
(state->gui, "description")); (state->gui, "description"));
gtk_style_context_add_class
(gtk_widget_get_style_context (GTK_WIDGET (state->description_view)),
"function-help");
description = gtk_text_view_get_buffer (state->description_view); description = gtk_text_view_get_buffer (state->description_view);
gtk_text_buffer_get_start_iter (description, &where); gtk_text_buffer_get_start_iter (description, &where);
gtk_text_buffer_create_mark (description, "start-mark", &where, TRUE); gtk_text_buffer_create_mark (description, "start-mark", &where, TRUE);
......
...@@ -208,8 +208,13 @@ GnmNotebookButton:active { ...@@ -208,8 +208,13 @@ GnmNotebookButton:active {
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* Functions' arguments link-like appearance in pseudo-tooltips. */ /* Functions' arguments link-like appearance in pseudo-tooltips. */
GtkTextView.function-help { GtkTextView.pseudo-tooltip.function-help {
-GtkWidget-link-color: red; -GtkWidget-link-color: #4040ff;
}
/* Ditto in the function selector. */
GtkDialog GtkTextView.function-help {
-GtkWidget-link-color: #4040ff;
} }
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment