[gnome-latex: 87/205] symbols: add a space after the symbol
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-latex: 87/205] symbols: add a space after the symbol
- Date: Fri, 14 Dec 2018 10:54:12 +0000 (UTC)
commit 8479c338ab42eae0f9ee08d36d5566e8b9d8b511
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date: Wed Oct 7 22:09:03 2009 +0200
symbols: add a space after the symbol
TODO | 2 +-
src/callbacks.c | 74 -------------------------------------------------------
src/callbacks.h | 2 --
src/symbols.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/symbols.h | 2 ++
5 files changed, 79 insertions(+), 77 deletions(-)
---
diff --git a/TODO b/TODO
index 46bae48..fd13974 100644
--- a/TODO
+++ b/TODO
@@ -15,7 +15,7 @@ Fri Oct 2, 2009 to Fri Oct 9, 2009
[-] symbol tables
- mathematical sets (N, Z, Q, R, C) in misc math
- - add a space after the symbols
+ x add a space after the symbols
- set the focus on the text after inserting a symbol
[x] bugs correction
diff --git a/src/callbacks.c b/src/callbacks.c
index 69f8960..57e48a7 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -722,80 +722,6 @@ cb_recent_item_activated (GtkRecentAction *action, gpointer user_data)
open_new_document (filename, uri);
}
-void
-cb_category_symbols_selected (GtkIconView *icon_view, gpointer user_data)
-{
- GList *selected_items = gtk_icon_view_get_selected_items (icon_view);
- GtkTreePath *path = g_list_nth_data (selected_items, 0);
- GtkTreeModel *model = gtk_icon_view_get_model (icon_view);
- GtkTreeIter iter;
-
- if (path != NULL && gtk_tree_model_get_iter (model, &iter, path))
- {
- gint num;
- gtk_tree_model_get (model, &iter, COLUMN_CAT_NUM, &num, -1);
-
- // change the model
- gtk_icon_view_set_model (latexila.symbols->icon_view,
- GTK_TREE_MODEL (latexila.symbols->list_stores[num]));
-
- // TODO scroll to the start
- /* this doesn't work...
- GtkTreePath *first_path = gtk_icon_view_get_path_at_pos (
- latexila.symbols->icon_view, 0, 0);
- if (first_path != NULL)
- {
- gtk_icon_view_scroll_to_path (latexila.symbols->icon_view, first_path,
- TRUE, 0.0, 0.0);
- }
- */
- }
-
- // free the GList
- g_list_foreach (selected_items, (GFunc) gtk_tree_path_free, NULL);
- g_list_free (selected_items);
-}
-
-void
-cb_symbol_selected (GtkIconView *icon_view, gpointer user_data)
-{
- if (latexila.active_doc == NULL)
- {
- gtk_icon_view_unselect_all (icon_view);
- return;
- }
-
- GList *selected_items = gtk_icon_view_get_selected_items (icon_view);
- // unselect the symbol, so the user can insert several times the same symbol
- gtk_icon_view_unselect_all (icon_view);
- GtkTreePath *path = g_list_nth_data (selected_items, 0);
- GtkTreeModel *model = gtk_icon_view_get_model (icon_view);
- GtkTreeIter iter;
-
- if (path != NULL && gtk_tree_model_get_iter (model, &iter, path))
- {
- gchar *latex_command;
- gtk_tree_model_get (model, &iter,
- COLUMN_SYMBOL_COMMAND, &latex_command,
- -1);
-
- // insert the symbol in the current document
- GtkTextBuffer *buffer =
- GTK_TEXT_BUFFER (latexila.active_doc->source_buffer);
- gtk_text_buffer_begin_user_action (buffer);
- gtk_text_buffer_insert_at_cursor (
- GTK_TEXT_BUFFER (latexila.active_doc->source_buffer),
- latex_command, -1);
- gtk_text_buffer_end_user_action (buffer);
-
- g_free (latex_command);
- }
-
- // free the GList
- g_list_foreach (selected_items, (GFunc) gtk_tree_path_free, NULL);
- g_list_free (selected_items);
-}
-
void
cb_show_symbol_tables (GtkToggleAction *toggle_action, gpointer user_data)
{
diff --git a/src/callbacks.h b/src/callbacks.h
index c97f5c2..0368501 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -59,8 +59,6 @@ void cb_page_reordered (GtkNotebook *notebook, GtkWidget *child, guint page_num,
gboolean cb_delete_event (GtkWidget *widget, GdkEvent *event,
gpointer user_data);
void cb_recent_item_activated (GtkRecentAction *action, gpointer user_data);
-void cb_category_symbols_selected (GtkIconView *icon_view, gpointer user_data);
-void cb_symbol_selected (GtkIconView *icon_view, gpointer user_data);
void cb_show_symbol_tables (GtkToggleAction *toggle_action, gpointer user_data);
void cb_show_edit_toolbar (GtkToggleAction *toggle_action, gpointer user_data);
diff --git a/src/symbols.c b/src/symbols.c
index 0edfd79..9498d17 100644
--- a/src/symbols.c
+++ b/src/symbols.c
@@ -872,3 +872,79 @@ init_symbols (void)
gtk_container_add (GTK_CONTAINER (scrollbar), symbol_view);
gtk_box_pack_start (GTK_BOX (latexila.symbols->vbox), scrollbar, TRUE, TRUE, 0);
}
+
+void
+cb_category_symbols_selected (GtkIconView *icon_view, gpointer user_data)
+{
+ GList *selected_items = gtk_icon_view_get_selected_items (icon_view);
+ GtkTreePath *path = g_list_nth_data (selected_items, 0);
+ GtkTreeModel *model = gtk_icon_view_get_model (icon_view);
+ GtkTreeIter iter;
+
+ if (path != NULL && gtk_tree_model_get_iter (model, &iter, path))
+ {
+ gint num;
+ gtk_tree_model_get (model, &iter, COLUMN_CAT_NUM, &num, -1);
+
+ // change the model
+ gtk_icon_view_set_model (latexila.symbols->icon_view,
+ GTK_TREE_MODEL (latexila.symbols->list_stores[num]));
+
+ // TODO scroll to the start
+ /* this doesn't work...
+ GtkTreePath *first_path = gtk_icon_view_get_path_at_pos (
+ latexila.symbols->icon_view, 0, 0);
+ if (first_path != NULL)
+ {
+ gtk_icon_view_scroll_to_path (latexila.symbols->icon_view, first_path,
+ TRUE, 0.0, 0.0);
+ }
+ */
+ }
+
+ // free the GList
+ g_list_foreach (selected_items, (GFunc) gtk_tree_path_free, NULL);
+ g_list_free (selected_items);
+}
+
+void
+cb_symbol_selected (GtkIconView *icon_view, gpointer user_data)
+{
+ if (latexila.active_doc == NULL)
+ {
+ gtk_icon_view_unselect_all (icon_view);
+ return;
+ }
+
+ GList *selected_items = gtk_icon_view_get_selected_items (icon_view);
+ // unselect the symbol, so the user can insert several times the same symbol
+ gtk_icon_view_unselect_all (icon_view);
+ GtkTreePath *path = g_list_nth_data (selected_items, 0);
+ GtkTreeModel *model = gtk_icon_view_get_model (icon_view);
+ GtkTreeIter iter;
+
+ if (path != NULL && gtk_tree_model_get_iter (model, &iter, path))
+ {
+ gchar *latex_command;
+ gtk_tree_model_get (model, &iter,
+ COLUMN_SYMBOL_COMMAND, &latex_command,
+ -1);
+
+ // insert the symbol in the current document
+ GtkTextBuffer *buffer =
+ GTK_TEXT_BUFFER (latexila.active_doc->source_buffer);
+ gtk_text_buffer_begin_user_action (buffer);
+ gtk_text_buffer_insert_at_cursor (
+ GTK_TEXT_BUFFER (latexila.active_doc->source_buffer),
+ latex_command, -1);
+ gtk_text_buffer_insert_at_cursor (
+ GTK_TEXT_BUFFER (latexila.active_doc->source_buffer), " ", -1);
+ gtk_text_buffer_end_user_action (buffer);
+
+ g_free (latex_command);
+ }
+
+ // free the GList
+ g_list_foreach (selected_items, (GFunc) gtk_tree_path_free, NULL);
+ g_list_free (selected_items);
+}
diff --git a/src/symbols.h b/src/symbols.h
index aa8ad1b..a8a0c2f 100644
--- a/src/symbols.h
+++ b/src/symbols.h
@@ -2,5 +2,7 @@
#define SYMBOLS_H
void init_symbols (void);
+void cb_category_symbols_selected (GtkIconView *icon_view, gpointer user_data);
+void cb_symbol_selected (GtkIconView *icon_view, gpointer user_data);
#endif /* SYMBOLS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]