Move GeanyDocument GUI elements and saved_encoding to private
Document struct which inherits from GeanyDocument. This is to hide implementation fields from the plugin API, so that we can change them if necessary. Add DOCUMENT() macro to convert a GeanyDocument* to a Document*. Also move UNDO_*, FileEncoding to documentprivate.h. Move undo_action struct to document.c. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2631 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
e6b428a9a4
commit
37e0d1f3f1
15
ChangeLog
15
ChangeLog
@ -1,3 +1,18 @@
|
||||
2008-06-02 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
||||
|
||||
* src/documentprivate.h, src/prefs.c, src/plugindata.h,
|
||||
src/treeviews.c, src/callbacks.c, src/notebook.c, src/document.c,
|
||||
src/document.h, src/editor.c, src/symbols.c, src/Makefile.am,
|
||||
src/ui_utils.c:
|
||||
Move GeanyDocument GUI elements and saved_encoding to private
|
||||
Document struct which inherits from GeanyDocument. This is to hide
|
||||
implementation fields from the plugin API, so that we can change
|
||||
them if necessary.
|
||||
Add DOCUMENT() macro to convert a GeanyDocument* to a Document*.
|
||||
Also move UNDO_*, FileEncoding to documentprivate.h.
|
||||
Move undo_action struct to document.c.
|
||||
|
||||
|
||||
2008-05-30 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
||||
|
||||
* src/plugindata.h:
|
||||
|
@ -2,7 +2,8 @@
|
||||
# $Id$
|
||||
|
||||
|
||||
EXTRA_DIST = images.c gb.c win32.c win32.h plugindata.h
|
||||
EXTRA_DIST = images.c gb.c win32.c win32.h plugindata.h \
|
||||
documentprivate.h
|
||||
|
||||
bin_PROGRAMS = geany
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
|
||||
#include "keyfile.h"
|
||||
#include "document.h"
|
||||
#include "documentprivate.h"
|
||||
#include "filetypes.h"
|
||||
#include "sciwrappers.h"
|
||||
#include "editor.h"
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#include "document.h"
|
||||
#include "documentprivate.h"
|
||||
#include "filetypes.h"
|
||||
#include "support.h"
|
||||
#include "sciwrappers.h"
|
||||
@ -79,6 +80,17 @@ GeanyFilePrefs file_prefs;
|
||||
|
||||
GPtrArray *documents_array;
|
||||
|
||||
|
||||
/* an undo action, also used for redo actions */
|
||||
typedef struct
|
||||
{
|
||||
GTrashStack *next; /* pointer to the next stack element(required for the GTrashStack) */
|
||||
guint type; /* to identify the action */
|
||||
gpointer *data; /* the old value (before the change), in case of a redo action
|
||||
* it contains the new value */
|
||||
} undo_action;
|
||||
|
||||
|
||||
/* Whether to colourise the document straight after styling settings are changed.
|
||||
* (e.g. when filetype is set or typenames are updated) */
|
||||
static gboolean delay_colourise = FALSE;
|
||||
@ -312,30 +324,33 @@ void document_apply_update_prefs(gint idx)
|
||||
* The flag is_valid is set to TRUE in document_create(). */
|
||||
static void init_doc_struct(GeanyDocument *new_doc)
|
||||
{
|
||||
memset(new_doc, 0, sizeof(GeanyDocument));
|
||||
Document *full_doc = DOCUMENT(new_doc);
|
||||
|
||||
memset(full_doc, 0, sizeof(Document));
|
||||
|
||||
new_doc->is_valid = FALSE;
|
||||
new_doc->has_tags = FALSE;
|
||||
new_doc->auto_indent = (editor_prefs.indent_mode != INDENT_NONE);
|
||||
new_doc->line_wrapping = editor_prefs.line_wrapping;
|
||||
new_doc->readonly = FALSE;
|
||||
new_doc->tag_store = NULL;
|
||||
new_doc->tag_tree = NULL;
|
||||
new_doc->file_name = NULL;
|
||||
new_doc->file_type = NULL;
|
||||
new_doc->tm_file = NULL;
|
||||
new_doc->encoding = NULL;
|
||||
new_doc->has_bom = FALSE;
|
||||
new_doc->saved_encoding.encoding = NULL;
|
||||
new_doc->saved_encoding.has_bom = FALSE;
|
||||
new_doc->sci = NULL;
|
||||
new_doc->undo_actions = NULL;
|
||||
new_doc->redo_actions = NULL;
|
||||
new_doc->scroll_percent = -1.0F;
|
||||
new_doc->line_breaking = FALSE;
|
||||
new_doc->mtime = 0;
|
||||
new_doc->changed = FALSE;
|
||||
new_doc->last_check = time(NULL);
|
||||
|
||||
full_doc->tag_store = NULL;
|
||||
full_doc->tag_tree = NULL;
|
||||
full_doc->saved_encoding.encoding = NULL;
|
||||
full_doc->saved_encoding.has_bom = FALSE;
|
||||
full_doc->undo_actions = NULL;
|
||||
full_doc->redo_actions = NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -447,7 +462,7 @@ static gint document_create(const gchar *utf8_filename)
|
||||
new_idx = document_get_new_idx();
|
||||
if (new_idx == -1) /* expand the array, no free places */
|
||||
{
|
||||
GeanyDocument *new_doc = g_new0(GeanyDocument, 1);
|
||||
Document *new_doc = g_new0(Document, 1);
|
||||
|
||||
new_idx = documents_array->len;
|
||||
g_ptr_array_add(documents_array, new_doc);
|
||||
@ -476,7 +491,7 @@ static gint document_create(const gchar *utf8_filename)
|
||||
GtkTreeSelection *sel;
|
||||
|
||||
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv.tree_openfiles));
|
||||
gtk_tree_selection_select_iter(sel, &this->iter);
|
||||
gtk_tree_selection_select_iter(sel, &DOCUMENT(this)->iter);
|
||||
}
|
||||
|
||||
ui_document_buttons_update();
|
||||
@ -500,6 +515,8 @@ gboolean document_remove(guint page_num)
|
||||
|
||||
if (DOC_IDX_VALID(idx))
|
||||
{
|
||||
Document *fdoc = DOCUMENT(documents[idx]);
|
||||
|
||||
if (documents[idx]->changed && ! dialogs_show_unsaved_file(idx))
|
||||
{
|
||||
return FALSE;
|
||||
@ -513,7 +530,7 @@ gboolean document_remove(guint page_num)
|
||||
navqueue_remove_file(documents[idx]->file_name);
|
||||
msgwin_status_add(_("File %s closed."), DOC_FILENAME(idx));
|
||||
g_free(documents[idx]->encoding);
|
||||
g_free(documents[idx]->saved_encoding.encoding);
|
||||
g_free(fdoc->saved_encoding.encoding);
|
||||
g_free(documents[idx]->file_name);
|
||||
tm_workspace_remove_object(documents[idx]->tm_file, TRUE, TRUE);
|
||||
|
||||
@ -549,9 +566,11 @@ gboolean document_remove(guint page_num)
|
||||
/* used to keep a record of the unchanged document state encoding */
|
||||
static void store_saved_encoding(gint idx)
|
||||
{
|
||||
g_free(documents[idx]->saved_encoding.encoding);
|
||||
documents[idx]->saved_encoding.encoding = g_strdup(documents[idx]->encoding);
|
||||
documents[idx]->saved_encoding.has_bom = documents[idx]->has_bom;
|
||||
Document *fdoc = DOCUMENT(documents[idx]);
|
||||
|
||||
g_free(fdoc->saved_encoding.encoding);
|
||||
fdoc->saved_encoding.encoding = g_strdup(documents[idx]->encoding);
|
||||
fdoc->saved_encoding.has_bom = documents[idx]->has_bom;
|
||||
}
|
||||
|
||||
|
||||
@ -1501,8 +1520,11 @@ gboolean document_save_file(gint idx, gboolean force)
|
||||
document_set_filetype(idx, documents[idx]->file_type);
|
||||
|
||||
tm_workspace_update(TM_WORK_OBJECT(app->tm_workspace), TRUE, TRUE, FALSE);
|
||||
gtk_label_set_text(GTK_LABEL(documents[idx]->tab_label), base_name);
|
||||
gtk_label_set_text(GTK_LABEL(documents[idx]->tabmenu_label), base_name);
|
||||
{
|
||||
Document *fdoc = DOCUMENT(documents[idx]);
|
||||
gtk_label_set_text(GTK_LABEL(fdoc->tab_label), base_name);
|
||||
gtk_label_set_text(GTK_LABEL(fdoc->tabmenu_label), base_name);
|
||||
}
|
||||
msgwin_status_add(_("File %s saved."), documents[idx]->file_name);
|
||||
ui_update_statusbar(idx, -1);
|
||||
g_free(base_name);
|
||||
@ -2149,11 +2171,12 @@ void document_set_encoding(gint idx, const gchar *new_encoding)
|
||||
/* Clears the Undo and Redo buffer (to be called when reloading or closing the document) */
|
||||
void document_undo_clear(gint idx)
|
||||
{
|
||||
Document *fdoc = DOCUMENT(documents[idx]);
|
||||
undo_action *a;
|
||||
|
||||
while (g_trash_stack_height(&documents[idx]->undo_actions) > 0)
|
||||
while (g_trash_stack_height(&fdoc->undo_actions) > 0)
|
||||
{
|
||||
a = g_trash_stack_pop(&documents[idx]->undo_actions);
|
||||
a = g_trash_stack_pop(&fdoc->undo_actions);
|
||||
if (a != NULL)
|
||||
{
|
||||
switch (a->type)
|
||||
@ -2165,11 +2188,11 @@ void document_undo_clear(gint idx)
|
||||
g_free(a);
|
||||
}
|
||||
}
|
||||
documents[idx]->undo_actions = NULL;
|
||||
fdoc->undo_actions = NULL;
|
||||
|
||||
while (g_trash_stack_height(&documents[idx]->redo_actions) > 0)
|
||||
while (g_trash_stack_height(&fdoc->redo_actions) > 0)
|
||||
{
|
||||
a = g_trash_stack_pop(&documents[idx]->redo_actions);
|
||||
a = g_trash_stack_pop(&fdoc->redo_actions);
|
||||
if (a != NULL)
|
||||
{
|
||||
switch (a->type)
|
||||
@ -2181,7 +2204,7 @@ void document_undo_clear(gint idx)
|
||||
g_free(a);
|
||||
}
|
||||
}
|
||||
documents[idx]->redo_actions = NULL;
|
||||
fdoc->redo_actions = NULL;
|
||||
|
||||
documents[idx]->changed = FALSE;
|
||||
if (! main_status.quitting) document_set_text_changed(idx);
|
||||
@ -2193,6 +2216,7 @@ void document_undo_clear(gint idx)
|
||||
|
||||
void document_undo_add(gint idx, guint type, gpointer data)
|
||||
{
|
||||
Document *fdoc = DOCUMENT(documents[idx]);
|
||||
undo_action *action;
|
||||
|
||||
if (! DOC_IDX_VALID(idx)) return;
|
||||
@ -2201,7 +2225,7 @@ void document_undo_add(gint idx, guint type, gpointer data)
|
||||
action->type = type;
|
||||
action->data = data;
|
||||
|
||||
g_trash_stack_push(&documents[idx]->undo_actions, action);
|
||||
g_trash_stack_push(&fdoc->undo_actions, action);
|
||||
|
||||
documents[idx]->changed = TRUE;
|
||||
document_set_text_changed(idx);
|
||||
@ -2214,9 +2238,11 @@ void document_undo_add(gint idx, guint type, gpointer data)
|
||||
|
||||
gboolean document_can_undo(gint idx)
|
||||
{
|
||||
Document *fdoc = DOCUMENT(documents[idx]);
|
||||
|
||||
if (! DOC_IDX_VALID(idx)) return FALSE;
|
||||
|
||||
if (g_trash_stack_height(&documents[idx]->undo_actions) > 0 || sci_can_undo(documents[idx]->sci))
|
||||
if (g_trash_stack_height(&fdoc->undo_actions) > 0 || sci_can_undo(documents[idx]->sci))
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
@ -2225,21 +2251,24 @@ gboolean document_can_undo(gint idx)
|
||||
|
||||
static void update_changed_state(gint idx)
|
||||
{
|
||||
Document *fdoc = DOCUMENT(documents[idx]);
|
||||
|
||||
documents[idx]->changed =
|
||||
(sci_is_modified(documents[idx]->sci) ||
|
||||
documents[idx]->has_bom != documents[idx]->saved_encoding.has_bom ||
|
||||
! utils_str_equal(documents[idx]->encoding, documents[idx]->saved_encoding.encoding));
|
||||
documents[idx]->has_bom != fdoc->saved_encoding.has_bom ||
|
||||
! utils_str_equal(documents[idx]->encoding, fdoc->saved_encoding.encoding));
|
||||
document_set_text_changed(idx);
|
||||
}
|
||||
|
||||
|
||||
void document_undo(gint idx)
|
||||
{
|
||||
Document *fdoc = DOCUMENT(documents[idx]);
|
||||
undo_action *action;
|
||||
|
||||
if (! DOC_IDX_VALID(idx)) return;
|
||||
|
||||
action = g_trash_stack_pop(&documents[idx]->undo_actions);
|
||||
action = g_trash_stack_pop(&fdoc->undo_actions);
|
||||
|
||||
if (action == NULL)
|
||||
{
|
||||
@ -2294,9 +2323,11 @@ void document_undo(gint idx)
|
||||
|
||||
gboolean document_can_redo(gint idx)
|
||||
{
|
||||
Document *fdoc = DOCUMENT(documents[idx]);
|
||||
|
||||
if (! DOC_IDX_VALID(idx)) return FALSE;
|
||||
|
||||
if (g_trash_stack_height(&documents[idx]->redo_actions) > 0 || sci_can_redo(documents[idx]->sci))
|
||||
if (g_trash_stack_height(&fdoc->redo_actions) > 0 || sci_can_redo(documents[idx]->sci))
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
@ -2305,11 +2336,12 @@ gboolean document_can_redo(gint idx)
|
||||
|
||||
void document_redo(gint idx)
|
||||
{
|
||||
Document *fdoc = DOCUMENT(documents[idx]);
|
||||
undo_action *action;
|
||||
|
||||
if (! DOC_IDX_VALID(idx)) return;
|
||||
|
||||
action = g_trash_stack_pop(&documents[idx]->redo_actions);
|
||||
action = g_trash_stack_pop(&fdoc->redo_actions);
|
||||
|
||||
if (action == NULL)
|
||||
{
|
||||
@ -2363,6 +2395,7 @@ void document_redo(gint idx)
|
||||
|
||||
static void document_redo_add(gint idx, guint type, gpointer data)
|
||||
{
|
||||
Document *fdoc = DOCUMENT(documents[idx]);
|
||||
undo_action *action;
|
||||
|
||||
if (! DOC_IDX_VALID(idx)) return;
|
||||
@ -2371,7 +2404,7 @@ static void document_redo_add(gint idx, guint type, gpointer data)
|
||||
action->type = type;
|
||||
action->data = data;
|
||||
|
||||
g_trash_stack_push(&documents[idx]->redo_actions, action);
|
||||
g_trash_stack_push(&fdoc->redo_actions, action);
|
||||
|
||||
documents[idx]->changed = TRUE;
|
||||
document_set_text_changed(idx);
|
||||
|
@ -61,13 +61,6 @@ GeanyFilePrefs;
|
||||
extern GeanyFilePrefs file_prefs;
|
||||
|
||||
|
||||
typedef struct FileEncoding
|
||||
{
|
||||
gchar *encoding;
|
||||
gboolean has_bom;
|
||||
} FileEncoding;
|
||||
|
||||
|
||||
/**
|
||||
* Structure for representing an open tab with all its properties.
|
||||
**/
|
||||
@ -94,16 +87,6 @@ typedef struct GeanyDocument
|
||||
TMWorkObject *tm_file;
|
||||
/** The Scintilla object for this %document. */
|
||||
ScintillaObject *sci;
|
||||
/** GtkLabel shown in the notebook header. */
|
||||
GtkWidget *tab_label;
|
||||
/** GtkLabel shown in the notebook right-click menu. */
|
||||
GtkWidget *tabmenu_label;
|
||||
/** GtkTreeView object for this %document within the Open Files treeview of the sidebar. */
|
||||
GtkWidget *tag_tree;
|
||||
/** GtkTreeStore object for this %document within the Open Files treeview of the sidebar. */
|
||||
GtkTreeStore *tag_store;
|
||||
/** Iter for this %document within the Open Files treeview of the sidebar. */
|
||||
GtkTreeIter iter;
|
||||
/** Whether this %document is read-only. */
|
||||
gboolean readonly;
|
||||
/** Whether this %document has been changed since it was last saved. */
|
||||
@ -118,16 +101,11 @@ typedef struct GeanyDocument
|
||||
time_t last_check;
|
||||
/** Modification time of this %document on disk. */
|
||||
time_t mtime;
|
||||
/** Internally used by the Undo/Redo management code. */
|
||||
GTrashStack *undo_actions;
|
||||
/** Internally used by the Undo/Redo management code. */
|
||||
GTrashStack *redo_actions;
|
||||
/** Internally used. */
|
||||
FileEncoding saved_encoding;
|
||||
/** %Document-specific tab setting. */
|
||||
/** %Document-specific indentation setting. */
|
||||
gboolean use_tabs;
|
||||
gboolean line_breaking; /**< Whether to split long lines as you type. */
|
||||
} GeanyDocument;
|
||||
}
|
||||
GeanyDocument;
|
||||
|
||||
|
||||
/** Dynamic array of GeanyDocument pointers holding information about the notebook tabs. */
|
||||
@ -229,28 +207,9 @@ void document_set_encoding(gint idx, const gchar *new_encoding);
|
||||
|
||||
|
||||
/* own Undo / Redo implementation to be able to undo / redo changes
|
||||
* to the encoding or the Unicode BOM (which are Scintilla independet).
|
||||
* to the encoding or the Unicode BOM (which are Scintilla independent).
|
||||
* All Scintilla events are stored in the undo / redo buffer and are passed through. */
|
||||
|
||||
/* available UNDO actions, UNDO_SCINTILLA is a pseudo action to trigger Scintilla's
|
||||
* undo management */
|
||||
enum
|
||||
{
|
||||
UNDO_SCINTILLA = 0,
|
||||
UNDO_ENCODING,
|
||||
UNDO_BOM,
|
||||
UNDO_ACTIONS_MAX
|
||||
};
|
||||
|
||||
/* an undo action, also used for redo actions */
|
||||
typedef struct
|
||||
{
|
||||
GTrashStack *next; /* pointer to the next stack element(required for the GTrashStack) */
|
||||
guint type; /* to identify the action */
|
||||
gpointer *data; /* the old value (before the change), in case of a redo action
|
||||
* it contains the new value */
|
||||
} undo_action;
|
||||
|
||||
gboolean document_can_undo(gint idx);
|
||||
|
||||
gboolean document_can_redo(gint idx);
|
||||
@ -261,6 +220,7 @@ void document_redo(gint idx);
|
||||
|
||||
void document_undo_add(gint idx, guint type, gpointer data);
|
||||
|
||||
|
||||
GdkColor *document_get_status_color(gint idx);
|
||||
|
||||
void document_delay_colourise(void);
|
||||
|
70
src/documentprivate.h
Normal file
70
src/documentprivate.h
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* document-private.h
|
||||
*
|
||||
* Copyright 2008 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GEANY_DOCUMENT_PRIVATE_H
|
||||
#define GEANY_DOCUMENT_PRIVATE_H
|
||||
|
||||
/* available UNDO actions, UNDO_SCINTILLA is a pseudo action to trigger Scintilla's
|
||||
* undo management */
|
||||
enum
|
||||
{
|
||||
UNDO_SCINTILLA = 0,
|
||||
UNDO_ENCODING,
|
||||
UNDO_BOM,
|
||||
UNDO_ACTIONS_MAX
|
||||
};
|
||||
|
||||
|
||||
typedef struct FileEncoding
|
||||
{
|
||||
gchar *encoding;
|
||||
gboolean has_bom;
|
||||
} FileEncoding;
|
||||
|
||||
|
||||
#define DOCUMENT(doc_ptr) ((Document*)doc_ptr)
|
||||
|
||||
/* This type 'inherits' from GeanyDocument so Document* can be cast to GeanyDocument*. */
|
||||
typedef struct Document
|
||||
{
|
||||
struct GeanyDocument public; /* must come first */
|
||||
|
||||
/* GtkLabel shown in the notebook header. */
|
||||
GtkWidget *tab_label;
|
||||
/* GtkLabel shown in the notebook right-click menu. */
|
||||
GtkWidget *tabmenu_label;
|
||||
/* GtkTreeView object for this %document within the Symbols treeview of the sidebar. */
|
||||
GtkWidget *tag_tree;
|
||||
/* GtkTreeStore object for this %document within the Symbols treeview of the sidebar. */
|
||||
GtkTreeStore *tag_store;
|
||||
/* Iter for this %document within the Open Files treeview of the sidebar. */
|
||||
GtkTreeIter iter;
|
||||
/* Used by the Undo/Redo management code. */
|
||||
GTrashStack *undo_actions;
|
||||
/* Used by the Undo/Redo management code. */
|
||||
GTrashStack *redo_actions;
|
||||
/* Used so Undo/Redo works for encoding changes. */
|
||||
FileEncoding saved_encoding;
|
||||
}
|
||||
Document;
|
||||
|
||||
#endif
|
@ -39,6 +39,7 @@
|
||||
#include "support.h"
|
||||
#include "editor.h"
|
||||
#include "document.h"
|
||||
#include "documentprivate.h"
|
||||
#include "filetypes.h"
|
||||
#include "sciwrappers.h"
|
||||
#include "ui_utils.h"
|
||||
@ -170,7 +171,8 @@ static void on_margin_click(ScintillaObject *sci, SCNotification *nt)
|
||||
}
|
||||
|
||||
|
||||
/* Note: Any GUI updates that don't affect scintilla should be done in on_painted(). */
|
||||
/* Called before Scintilla repaints.
|
||||
* Note: Any GUI updates that don't affect scintilla should be done in on_painted(). */
|
||||
static void on_update_ui(gint idx, G_GNUC_UNUSED SCNotification *nt)
|
||||
{
|
||||
ScintillaObject *sci = documents[idx]->sci;
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "geany.h"
|
||||
#include "notebook.h"
|
||||
#include "document.h"
|
||||
#include "documentprivate.h"
|
||||
#include "ui_utils.h"
|
||||
#include "treeviews.h"
|
||||
#include "support.h"
|
||||
@ -320,6 +321,7 @@ gint notebook_new_tab(gint doc_idx)
|
||||
gint tabnum;
|
||||
gchar *title;
|
||||
GeanyDocument *this = documents[doc_idx];
|
||||
Document *fdoc = DOCUMENT(this);
|
||||
GtkWidget *page;
|
||||
|
||||
g_return_val_if_fail(doc_idx >= 0 && this != NULL, -1);
|
||||
@ -327,7 +329,7 @@ gint notebook_new_tab(gint doc_idx)
|
||||
page = GTK_WIDGET(this->sci);
|
||||
title = g_path_get_basename(DOC_FILENAME(doc_idx));
|
||||
|
||||
this->tab_label = gtk_label_new(title);
|
||||
fdoc->tab_label = gtk_label_new(title);
|
||||
|
||||
ebox = gtk_event_box_new();
|
||||
GTK_WIDGET_SET_FLAGS(ebox, GTK_NO_WINDOW);
|
||||
@ -335,7 +337,7 @@ gint notebook_new_tab(gint doc_idx)
|
||||
G_CALLBACK(notebook_tab_label_cb), page);
|
||||
|
||||
hbox = gtk_hbox_new(FALSE, 2);
|
||||
gtk_container_add(GTK_CONTAINER(ebox), this->tab_label);
|
||||
gtk_container_add(GTK_CONTAINER(ebox), fdoc->tab_label);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), ebox, FALSE, FALSE, 0);
|
||||
|
||||
if (file_prefs.show_tab_cross)
|
||||
@ -372,15 +374,15 @@ gint notebook_new_tab(gint doc_idx)
|
||||
|
||||
gtk_widget_show_all(hbox);
|
||||
|
||||
this->tabmenu_label = gtk_label_new(title);
|
||||
gtk_misc_set_alignment(GTK_MISC(this->tabmenu_label), 0.0, 0);
|
||||
fdoc->tabmenu_label = gtk_label_new(title);
|
||||
gtk_misc_set_alignment(GTK_MISC(fdoc->tabmenu_label), 0.0, 0);
|
||||
|
||||
if (file_prefs.tab_order_ltr)
|
||||
tabnum = gtk_notebook_append_page_menu(GTK_NOTEBOOK(main_widgets.notebook), page,
|
||||
hbox, this->tabmenu_label);
|
||||
hbox, fdoc->tabmenu_label);
|
||||
else
|
||||
tabnum = gtk_notebook_insert_page_menu(GTK_NOTEBOOK(main_widgets.notebook), page,
|
||||
hbox, this->tabmenu_label, 0);
|
||||
hbox, fdoc->tabmenu_label, 0);
|
||||
|
||||
tab_count_changed();
|
||||
|
||||
|
@ -36,12 +36,12 @@
|
||||
|
||||
/* The API version should be incremented whenever any plugin data types below are
|
||||
* modified or appended to. */
|
||||
static const gint api_version = 66;
|
||||
static const gint api_version = 67;
|
||||
|
||||
/* The ABI version should be incremented whenever existing fields in the plugin
|
||||
* data types below have to be changed or reordered. It should stay the same if fields
|
||||
* are only appended, as this doesn't affect existing fields. */
|
||||
static const gint abi_version = 35;
|
||||
static const gint abi_version = 36;
|
||||
|
||||
/** Check the plugin can be loaded by Geany.
|
||||
* This performs runtime checks that try to ensure:
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "msgwindow.h"
|
||||
#include "sciwrappers.h"
|
||||
#include "document.h"
|
||||
#include "documentprivate.h"
|
||||
#include "keyfile.h"
|
||||
#include "keybindings.h"
|
||||
#include "interface.h"
|
||||
@ -1043,8 +1044,10 @@ void on_prefs_font_choosed(GtkFontButton *widget, gpointer user_data)
|
||||
interface_prefs.tagbar_font = g_strdup(fontbtn);
|
||||
for (i = 0; i < documents_array->len; i++)
|
||||
{
|
||||
if (documents[i]->is_valid && GTK_IS_WIDGET(documents[i]->tag_tree))
|
||||
ui_widget_modify_font_from_string(documents[i]->tag_tree,
|
||||
Document *fdoc = DOCUMENT(documents[i]);
|
||||
|
||||
if (documents[i]->is_valid && GTK_IS_WIDGET(fdoc->tag_tree))
|
||||
ui_widget_modify_font_from_string(fdoc->tag_tree,
|
||||
interface_prefs.tagbar_font);
|
||||
}
|
||||
if (GTK_IS_WIDGET(tv.default_tag_tree))
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "filetypes.h"
|
||||
#include "encodings.h"
|
||||
#include "document.h"
|
||||
#include "documentprivate.h"
|
||||
#include "support.h"
|
||||
#include "msgwindow.h"
|
||||
#include "treeviews.h"
|
||||
@ -561,7 +562,8 @@ tag_list_add_groups(GtkTreeStore *tree_store, ...)
|
||||
static void init_tag_list(gint idx)
|
||||
{
|
||||
filetype_id ft_id = documents[idx]->file_type->id;
|
||||
GtkTreeStore *tag_store = documents[idx]->tag_store;
|
||||
Document *fdoc = DOCUMENT(documents[idx]);
|
||||
GtkTreeStore *tag_store = fdoc->tag_store;
|
||||
|
||||
init_tag_iters();
|
||||
|
||||
@ -839,6 +841,7 @@ gboolean symbols_recreate_tag_list(gint idx, gint sort_mode)
|
||||
GtkTreeIter iter;
|
||||
static gint prev_sort_mode = SYMBOLS_SORT_BY_NAME;
|
||||
filetype_id ft_id = FILETYPE_ID(documents[idx]->file_type);
|
||||
Document *fdoc = DOCUMENT(documents[idx]);
|
||||
|
||||
g_return_val_if_fail(DOC_IDX_VALID(idx), FALSE);
|
||||
|
||||
@ -852,11 +855,11 @@ gboolean symbols_recreate_tag_list(gint idx, gint sort_mode)
|
||||
return FALSE;
|
||||
|
||||
/* Make sure the model stays with us after the tree view unrefs it */
|
||||
g_object_ref(GTK_TREE_MODEL(documents[idx]->tag_store));
|
||||
g_object_ref(GTK_TREE_MODEL(fdoc->tag_store));
|
||||
/* Detach model from view */
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(documents[idx]->tag_tree), NULL);
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(fdoc->tag_tree), NULL);
|
||||
/* Clear all contents */
|
||||
gtk_tree_store_clear(documents[idx]->tag_store);
|
||||
gtk_tree_store_clear(fdoc->tag_store);
|
||||
|
||||
init_tag_list(idx);
|
||||
for (tmp = (GList*)tags; tmp; tmp = g_list_next(tmp))
|
||||
@ -939,10 +942,10 @@ gboolean symbols_recreate_tag_list(gint idx, gint sort_mode)
|
||||
|
||||
if (parent)
|
||||
{
|
||||
gtk_tree_model_get(GTK_TREE_MODEL(documents[idx]->tag_store), parent,
|
||||
gtk_tree_model_get(GTK_TREE_MODEL(fdoc->tag_store), parent,
|
||||
SYMBOLS_COLUMN_ICON, &icon, -1);
|
||||
gtk_tree_store_append(documents[idx]->tag_store, &iter, parent);
|
||||
gtk_tree_store_set(documents[idx]->tag_store, &iter,
|
||||
gtk_tree_store_append(fdoc->tag_store, &iter, parent);
|
||||
gtk_tree_store_set(fdoc->tag_store, &iter,
|
||||
SYMBOLS_COLUMN_ICON, icon,
|
||||
SYMBOLS_COLUMN_NAME, buf,
|
||||
SYMBOLS_COLUMN_LINE, symbol->line, -1);
|
||||
@ -951,12 +954,12 @@ gboolean symbols_recreate_tag_list(gint idx, gint sort_mode)
|
||||
g_object_unref(icon);
|
||||
}
|
||||
}
|
||||
hide_empty_rows(documents[idx]->tag_store);
|
||||
hide_empty_rows(fdoc->tag_store);
|
||||
/* Re-attach model to view */
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(documents[idx]->tag_tree),
|
||||
GTK_TREE_MODEL(documents[idx]->tag_store));
|
||||
g_object_unref(GTK_TREE_MODEL(documents[idx]->tag_store));
|
||||
gtk_tree_view_expand_all(GTK_TREE_VIEW(documents[idx]->tag_tree));
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(fdoc->tag_tree),
|
||||
GTK_TREE_MODEL(fdoc->tag_store));
|
||||
g_object_unref(GTK_TREE_MODEL(fdoc->tag_store));
|
||||
gtk_tree_view_expand_all(GTK_TREE_VIEW(fdoc->tag_tree));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "callbacks.h"
|
||||
#include "treeviews.h"
|
||||
#include "document.h"
|
||||
#include "documentprivate.h"
|
||||
#include "filetypes.h"
|
||||
#include "utils.h"
|
||||
#include "ui_utils.h"
|
||||
@ -152,6 +153,8 @@ on_default_tag_tree_button_press_event(GtkWidget *widget, GdkEventButton *event,
|
||||
/* update = rescan the tags for document[idx].filename */
|
||||
void treeviews_update_tag_list(gint idx, gboolean update)
|
||||
{
|
||||
Document *fdoc = DOCUMENT(documents[idx]);
|
||||
|
||||
if (gtk_bin_get_child(GTK_BIN(tag_window)))
|
||||
gtk_container_remove(GTK_CONTAINER(tag_window), gtk_bin_get_child(GTK_BIN(tag_window)));
|
||||
|
||||
@ -183,14 +186,14 @@ void treeviews_update_tag_list(gint idx, gboolean update)
|
||||
|
||||
if (update)
|
||||
{ /* updating the tag list in the left tag window */
|
||||
if (documents[idx]->tag_tree == NULL)
|
||||
if (fdoc->tag_tree == NULL)
|
||||
{
|
||||
documents[idx]->tag_store = gtk_tree_store_new(
|
||||
fdoc->tag_store = gtk_tree_store_new(
|
||||
SYMBOLS_N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT);
|
||||
documents[idx]->tag_tree = gtk_tree_view_new();
|
||||
prepare_taglist(documents[idx]->tag_tree, documents[idx]->tag_store);
|
||||
gtk_widget_show(documents[idx]->tag_tree);
|
||||
g_object_ref((gpointer)documents[idx]->tag_tree); /* to hold it after removing */
|
||||
fdoc->tag_tree = gtk_tree_view_new();
|
||||
prepare_taglist(fdoc->tag_tree, fdoc->tag_store);
|
||||
gtk_widget_show(fdoc->tag_tree);
|
||||
g_object_ref((gpointer)fdoc->tag_tree); /* to hold it after removing */
|
||||
}
|
||||
|
||||
documents[idx]->has_tags = symbols_recreate_tag_list(idx, SYMBOLS_SORT_USE_PREVIOUS);
|
||||
@ -198,7 +201,7 @@ void treeviews_update_tag_list(gint idx, gboolean update)
|
||||
|
||||
if (documents[idx]->has_tags)
|
||||
{
|
||||
gtk_container_add(GTK_CONTAINER(tag_window), documents[idx]->tag_tree);
|
||||
gtk_container_add(GTK_CONTAINER(tag_window), fdoc->tag_tree);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -298,7 +301,8 @@ static void prepare_openfiles(void)
|
||||
* This is called recursively in treeviews_openfiles_update_all(). */
|
||||
void treeviews_openfiles_add(gint idx)
|
||||
{
|
||||
GtkTreeIter *iter = &documents[idx]->iter;
|
||||
Document *fdoc = DOCUMENT(documents[idx]);
|
||||
GtkTreeIter *iter = &fdoc->iter;
|
||||
|
||||
gtk_list_store_append(store_openfiles, iter);
|
||||
treeviews_openfiles_update(idx);
|
||||
@ -307,6 +311,7 @@ void treeviews_openfiles_add(gint idx)
|
||||
|
||||
void treeviews_openfiles_update(gint idx)
|
||||
{
|
||||
Document *fdoc = DOCUMENT(documents[idx]);
|
||||
gchar *basename;
|
||||
GdkColor *color = document_get_status_color(idx);
|
||||
|
||||
@ -314,7 +319,7 @@ void treeviews_openfiles_update(gint idx)
|
||||
basename = DOC_FILENAME(idx);
|
||||
else
|
||||
basename = g_path_get_basename(DOC_FILENAME(idx));
|
||||
gtk_list_store_set(store_openfiles, &documents[idx]->iter,
|
||||
gtk_list_store_set(store_openfiles, &fdoc->iter,
|
||||
#if GTK_CHECK_VERSION(2, 12, 0)
|
||||
0, basename, 1, idx, 2, color, 3, DOC_FILENAME(idx), -1);
|
||||
#else
|
||||
@ -343,19 +348,20 @@ void treeviews_openfiles_update_all()
|
||||
|
||||
void treeviews_remove_document(gint idx)
|
||||
{
|
||||
GtkTreeIter *iter = &documents[idx]->iter;
|
||||
Document *fdoc = DOCUMENT(documents[idx]);
|
||||
GtkTreeIter *iter = &fdoc->iter;
|
||||
|
||||
gtk_list_store_remove(store_openfiles, iter);
|
||||
|
||||
if (GTK_IS_WIDGET(documents[idx]->tag_tree))
|
||||
if (GTK_IS_WIDGET(fdoc->tag_tree))
|
||||
{
|
||||
gtk_widget_destroy(documents[idx]->tag_tree);
|
||||
if (GTK_IS_TREE_VIEW(documents[idx]->tag_tree))
|
||||
gtk_widget_destroy(fdoc->tag_tree);
|
||||
if (GTK_IS_TREE_VIEW(fdoc->tag_tree))
|
||||
{
|
||||
/* Because it was ref'd in treeviews_update_tag_list, it needs unref'ing */
|
||||
g_object_unref((gpointer)documents[idx]->tag_tree);
|
||||
g_object_unref((gpointer)fdoc->tag_tree);
|
||||
}
|
||||
documents[idx]->tag_tree = NULL;
|
||||
fdoc->tag_tree = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "prefs.h"
|
||||
#include "sciwrappers.h"
|
||||
#include "document.h"
|
||||
#include "documentprivate.h"
|
||||
#include "filetypes.h"
|
||||
#include "support.h"
|
||||
#include "msgwindow.h"
|
||||
@ -1200,12 +1201,13 @@ void ui_combo_box_add_to_history(GtkComboBox *combo, const gchar *text)
|
||||
void ui_update_tab_status(gint idx)
|
||||
{
|
||||
GdkColor *color = document_get_status_color(idx);
|
||||
Document *fdoc = DOCUMENT(documents[idx]);
|
||||
|
||||
/* NULL color will reset to default */
|
||||
gtk_widget_modify_fg(documents[idx]->tab_label, GTK_STATE_NORMAL, color);
|
||||
gtk_widget_modify_fg(documents[idx]->tab_label, GTK_STATE_ACTIVE, color);
|
||||
gtk_widget_modify_fg(documents[idx]->tabmenu_label, GTK_STATE_NORMAL, color);
|
||||
gtk_widget_modify_fg(documents[idx]->tabmenu_label, GTK_STATE_ACTIVE, color);
|
||||
gtk_widget_modify_fg(fdoc->tab_label, GTK_STATE_NORMAL, color);
|
||||
gtk_widget_modify_fg(fdoc->tab_label, GTK_STATE_ACTIVE, color);
|
||||
gtk_widget_modify_fg(fdoc->tabmenu_label, GTK_STATE_NORMAL, color);
|
||||
gtk_widget_modify_fg(fdoc->tabmenu_label, GTK_STATE_ACTIVE, color);
|
||||
|
||||
treeviews_openfiles_update(idx);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user