[gnome-latex: 73/205] Show/hide edit toolbar
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-latex: 73/205] Show/hide edit toolbar
- Date: Fri, 14 Dec 2018 10:53:01 +0000 (UTC)
commit 83d7a248e37f44f0360efe97c689c0715a5beb90
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date: Sun Sep 20 00:22:15 2009 +0200
Show/hide edit toolbar
src/callbacks.c | 19 ++++++++++++++++++-
src/callbacks.h | 1 +
src/main.c | 5 ++++-
src/main.h | 2 ++
src/prefs.c | 14 ++++++++++++++
src/ui.c | 12 ++++++++++--
src/ui.xml | 1 +
7 files changed, 50 insertions(+), 4 deletions(-)
---
diff --git a/src/callbacks.c b/src/callbacks.c
index 9bac8d3..6966064 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -853,13 +853,30 @@ cb_show_symbol_tables (GtkToggleAction *toggle_action, gpointer user_data)
if (latexila.symbols == NULL || latexila.symbols->vbox == NULL)
return;
- latexila.prefs->show_side_pane = gtk_toggle_action_get_active (toggle_action);
+ latexila.prefs->show_side_pane =
+ gtk_toggle_action_get_active (toggle_action);
+
if (latexila.prefs->show_side_pane)
gtk_widget_show_all (latexila.symbols->vbox);
else
gtk_widget_hide (latexila.symbols->vbox);
}
+void
+cb_show_edit_toolbar (GtkToggleAction *toggle_action, gpointer user_data)
+{
+ if (latexila.edit_toolbar == NULL)
+ return;
+
+ latexila.prefs->show_edit_toolbar =
+ gtk_toggle_action_get_active (toggle_action);
+
+ if (latexila.prefs->show_edit_toolbar)
+ gtk_widget_show_all (latexila.edit_toolbar);
+ else
+ gtk_widget_hide (latexila.edit_toolbar);
+}
+
void
open_new_document (const gchar *filename, const gchar *uri)
{
diff --git a/src/callbacks.h b/src/callbacks.h
index c86b99e..a3f44dc 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -66,6 +66,7 @@ void cb_font_set (GtkFontButton *font_button, 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);
void open_new_document (const gchar *filename, const gchar *uri);
diff --git a/src/main.c b/src/main.c
index d947e5d..1932f47 100644
--- a/src/main.c
+++ b/src/main.c
@@ -38,7 +38,7 @@ static gboolean option_version (const gchar *option_name, const gchar *value,
gpointer data, GError **error);
latexila_t latexila = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL};
+ NULL, NULL, NULL, NULL, NULL, NULL};
static gboolean
option_version (const gchar *option_name, const gchar *value, gpointer data,
@@ -282,6 +282,9 @@ main (int argc, char *argv[])
if (! latexila.prefs->show_side_pane)
gtk_widget_hide (latexila.symbols->vbox);
+ if (! latexila.prefs->show_edit_toolbar)
+ gtk_widget_hide (latexila.edit_toolbar);
+
/* open documents given in arguments */
for (int i = 1 ; i < argc ; i++)
{
diff --git a/src/main.h b/src/main.h
index 1cf4513..6b919ff 100644
--- a/src/main.h
+++ b/src/main.h
@@ -66,6 +66,7 @@ typedef struct
{
gboolean show_line_numbers;
gboolean show_side_pane;
+ gboolean show_edit_toolbar;
gint window_width;
gint window_height;
gboolean window_maximised;
@@ -94,6 +95,7 @@ typedef struct
GtkPaned *main_hpaned;
GtkPaned *vpaned;
GtkPaned *log_hpaned;
+ GtkWidget *edit_toolbar;
} latexila_t;
// a lot of things are accessible by the "latexila" variable everywhere in the
diff --git a/src/prefs.c b/src/prefs.c
index 18fd32b..5eb7e80 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -35,6 +35,7 @@ static gchar * get_rc_file (void);
// there is an underscore in the end of each variable name
static gboolean show_line_numbers_ = FALSE;
static gboolean show_side_pane_ = TRUE;
+static gboolean show_edit_toolbar_ = TRUE;
static gint window_width_ = 800;
static gint window_height_ = 600;
static gboolean window_maximised_ = FALSE;
@@ -91,6 +92,16 @@ load_preferences (preferences_t *prefs)
error = NULL;
}
+ prefs->show_edit_toolbar = g_key_file_get_boolean (key_file, PROGRAM_NAME,
+ "show_edit_toolbar", &error);
+ if (error != NULL)
+ {
+ print_warning ("%s", error->message);
+ prefs->show_edit_toolbar = show_edit_toolbar_;
+ g_error_free (error);
+ error = NULL;
+ }
+
prefs->window_width = g_key_file_get_integer (key_file, PROGRAM_NAME,
"window_width", &error);
if (error != NULL)
@@ -195,6 +206,8 @@ save_preferences (preferences_t *prefs)
prefs->show_line_numbers);
g_key_file_set_boolean (key_file, PROGRAM_NAME, "show_side_pane",
prefs->show_side_pane);
+ g_key_file_set_boolean (key_file, PROGRAM_NAME, "show_edit_toolbar",
+ prefs->show_edit_toolbar);
g_key_file_set_string (key_file, PROGRAM_NAME, "command_view",
prefs->command_view);
g_key_file_set_string (key_file, PROGRAM_NAME, "font", prefs->font_str);
@@ -272,6 +285,7 @@ load_default_preferences (preferences_t *prefs)
{
prefs->show_line_numbers = show_line_numbers_;
prefs->show_side_pane = show_side_pane_;
+ prefs->show_edit_toolbar = show_edit_toolbar_;
prefs->window_width = window_width_;
prefs->window_height = window_height_;
prefs->window_maximised = window_maximised_;
diff --git a/src/ui.c b/src/ui.c
index 6554956..adb5db0 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -253,8 +253,9 @@ static GtkActionEntry latex_entries[] = {
// {name, stock_id, label, accelerator, tooltip, callback}
static GtkToggleActionEntry toggle_entries[] = {
{"ViewSymbols", NULL, N_("Symbol tables"), NULL,
- N_("Show or hide the symbol tables in the current window"),
- G_CALLBACK (cb_show_symbol_tables)}
+ N_("Show or hide the symbol tables"), G_CALLBACK (cb_show_symbol_tables)},
+ {"ViewEditToolbar", NULL, N_("Edit Toolbar"), NULL,
+ N_("Show or hide the edit toolbar"), G_CALLBACK (cb_show_edit_toolbar)},
};
static guint n_stock_icons = G_N_ELEMENTS (stock_icons);
@@ -358,6 +359,7 @@ init_ui (GtkWidget *box)
GtkWidget *edit_toolbar = gtk_ui_manager_get_widget (ui_manager,
"/EditToolbar");
+ latexila.edit_toolbar = edit_toolbar;
gtk_toolbar_set_style (GTK_TOOLBAR (edit_toolbar), GTK_TOOLBAR_ICONS);
gtk_box_pack_start (GTK_BOX (box), edit_toolbar, FALSE, FALSE, 0);
@@ -368,8 +370,14 @@ init_ui (GtkWidget *box)
// get actions
latexila.undo = gtk_action_group_get_action (action_group, "EditUndo");
latexila.redo = gtk_action_group_get_action (action_group, "EditRedo");
+
GtkToggleAction *show_symbol_tables = GTK_TOGGLE_ACTION (
gtk_action_group_get_action (action_group, "ViewSymbols"));
gtk_toggle_action_set_active (show_symbol_tables,
latexila.prefs->show_side_pane);
+
+ GtkToggleAction *show_edit_toolbar = GTK_TOGGLE_ACTION (
+ gtk_action_group_get_action (action_group, "ViewEditToolbar"));
+ gtk_toggle_action_set_active (show_edit_toolbar,
+ latexila.prefs->show_edit_toolbar);
}
diff --git a/src/ui.xml b/src/ui.xml
index 3e6951e..366df09 100644
--- a/src/ui.xml
+++ b/src/ui.xml
@@ -51,6 +51,7 @@ In the code, GtkUIManager is used to construct them.
<menu action="View">
<menuitem action="ViewSymbols" />
+ <menuitem action="ViewEditToolbar" />
<separator />
<menuitem action="ViewZoomIn" />
<menuitem action="ViewZoomOut" />
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]