2021-02-09 10:16:52 +01:00
|
|
|
# TfeTextView API reference
|
2021-02-03 15:04:08 +01:00
|
|
|
|
2022-12-21 14:31:33 +01:00
|
|
|
TfeTextView -- Child object of GtkTextView. It is connected to a certain file.
|
2021-02-03 15:04:08 +01:00
|
|
|
|
|
|
|
## Functions
|
2021-06-30 16:52:33 +02:00
|
|
|
- GFile *[tfe_text_view_get_file ()](../src/tfetextview/#tfe_text_view_get_file)
|
|
|
|
- void [tfe_text_view_open ()](../src/tfetextview/#tfe_text_view_open)
|
|
|
|
- void [tfe_text_view_save ()](../src/tfetextview/#tfe_text_view_save)
|
|
|
|
- void [tfe_text_view_saveas ()](../src/tfetextview/#tfe_text_view_saveas)
|
|
|
|
- GtkWidget *[tfe_text_view_new_with_file ()](../src/tfetextview/#tfe_text_view_new_with_file)
|
|
|
|
- GtkWidget *[tfe_text_view_new ()](../src/tfetextview/#tfe_text_view_new)
|
2021-02-03 15:04:08 +01:00
|
|
|
|
|
|
|
## Signals
|
|
|
|
|
2021-06-30 16:52:33 +02:00
|
|
|
- void [change-file](../src/tfetextview/#change-file)
|
|
|
|
- void [open-response](../src/tfetextview/#open-response)
|
2021-02-03 15:04:08 +01:00
|
|
|
|
|
|
|
## Types and Values
|
|
|
|
|
2021-06-30 16:52:33 +02:00
|
|
|
- [TfeTextView](../src/tfetextview/#tfetextview-1)
|
|
|
|
- [TfeTextViewClass](../src/tfetextview/#tfetextviewclass)
|
|
|
|
- [TfeTextViewOpenResponseType](../src/tfetextview/#enum-tfetextviewopenresponsetype)
|
2021-02-03 15:04:08 +01:00
|
|
|
|
|
|
|
## Object Hierarchy
|
|
|
|
|
|
|
|
~~~
|
|
|
|
GObject
|
|
|
|
+--GInitiallyUnowned
|
|
|
|
+--GtkWidget
|
|
|
|
+--GtkTextView
|
|
|
|
+--TfeTextView
|
|
|
|
~~~
|
|
|
|
|
|
|
|
## Includes
|
|
|
|
|
|
|
|
~~~
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
~~~
|
|
|
|
|
|
|
|
## Description
|
|
|
|
|
2022-12-21 14:31:33 +01:00
|
|
|
TfeTextView holds GFile corresponds to the contents of GtkTextBuffer.
|
|
|
|
It has some file manipulation functions.
|
2021-02-03 15:04:08 +01:00
|
|
|
|
|
|
|
## Functions
|
|
|
|
|
2021-02-06 09:26:57 +01:00
|
|
|
### tfe_text_view_get_file()
|
2021-02-03 15:04:08 +01:00
|
|
|
|
|
|
|
~~~
|
|
|
|
GFile *
|
|
|
|
tfe_text_view_get_file (TfeTextView *tv);
|
|
|
|
~~~
|
|
|
|
|
|
|
|
Returns the copy of the GFile in the TfeTextView.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
|
|
|
- tv: a TfeTextView
|
|
|
|
|
2021-02-06 09:26:57 +01:00
|
|
|
### tfe_text_view_open()
|
2021-02-03 15:04:08 +01:00
|
|
|
|
|
|
|
~~~
|
|
|
|
void
|
|
|
|
tfe_text_view_open (TfeTextView *tv, GtkWidget *win);
|
|
|
|
~~~
|
|
|
|
|
|
|
|
Just shows a GtkFileChooserDialog so that a user can choose a file to read.
|
|
|
|
This function doesn't do any I/O operations.
|
|
|
|
They are done by the signal handler connected to the `response` signal emitted by GtkFileChooserDialog.
|
2022-12-21 14:31:33 +01:00
|
|
|
Therefore the caller can't know the I/O status directly from `tfe_text_view_open`.
|
2021-02-03 15:04:08 +01:00
|
|
|
Instead, the status is informed by `open-response` signal.
|
|
|
|
The caller needs to set a handler to this signal in advance.
|
|
|
|
|
|
|
|
parameters
|
|
|
|
|
|
|
|
- tv: a TfeTextView
|
2021-04-20 15:03:23 +02:00
|
|
|
- win: the top level window
|
2021-02-03 15:04:08 +01:00
|
|
|
|
2021-02-06 09:26:57 +01:00
|
|
|
### tfe_text_view_save()
|
2021-02-03 15:04:08 +01:00
|
|
|
|
|
|
|
~~~
|
|
|
|
void
|
|
|
|
tfe_text_view_save (TfeTextView *tv);
|
|
|
|
~~~
|
|
|
|
|
2022-12-21 14:31:33 +01:00
|
|
|
Saves the contents of the TfeTextView to a file.
|
2021-02-03 15:04:08 +01:00
|
|
|
If `tv` holds a GFile, it is used.
|
2022-12-21 14:31:33 +01:00
|
|
|
Otherwise, this function shows GtkFileChooserDialog so that the user can choose a file to save.
|
2021-02-03 15:04:08 +01:00
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
|
|
|
- tv: a TfeTextView
|
|
|
|
|
2021-02-06 09:26:57 +01:00
|
|
|
### tfe_text_view_saveas()
|
2021-02-03 15:04:08 +01:00
|
|
|
|
|
|
|
~~~
|
|
|
|
void
|
|
|
|
tfe_text_view_saveas (TfeTextView *tv);
|
|
|
|
~~~
|
|
|
|
|
|
|
|
Saves the content of a TfeTextView to a file.
|
2022-12-21 14:31:33 +01:00
|
|
|
This function shows GtkFileChooserDialog so that a user can choose a file to save.
|
2021-02-03 15:04:08 +01:00
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
|
|
|
- tv: a TfeTextView
|
|
|
|
|
2021-02-06 09:26:57 +01:00
|
|
|
### tfe_text_view_new_with_file()
|
2021-02-03 15:04:08 +01:00
|
|
|
|
|
|
|
~~~
|
|
|
|
GtkWidget *
|
|
|
|
tfe_text_view_new_with_file (GFile *file);
|
|
|
|
~~~
|
|
|
|
|
2021-06-18 15:35:20 +02:00
|
|
|
Creates a new TfeTextView and reads the contents of the `file` and set it to the GtkTextBuffer corresponds to the newly created TfeTextView.
|
2021-02-03 15:04:08 +01:00
|
|
|
Then returns the TfeTextView as GtkWidget.
|
2021-06-18 15:35:20 +02:00
|
|
|
If an error happens, it returns `NULL`.
|
2021-02-03 15:04:08 +01:00
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
|
|
|
- file: a GFile
|
|
|
|
|
|
|
|
Returns
|
|
|
|
|
|
|
|
- a new TfeTextView.
|
|
|
|
|
2021-02-06 09:26:57 +01:00
|
|
|
### tfe_text_view_new()
|
2021-02-03 15:04:08 +01:00
|
|
|
|
|
|
|
~~~
|
|
|
|
GtkWidget *
|
|
|
|
tfe_text_view_new (void);
|
|
|
|
~~~
|
|
|
|
|
|
|
|
Creates a new TfeTextView and returns the TfeTextView as GtkWidget.
|
2021-06-18 15:35:20 +02:00
|
|
|
If an error happens, it returns `NULL`.
|
2021-02-03 15:04:08 +01:00
|
|
|
|
|
|
|
Returns
|
|
|
|
|
|
|
|
- a new TfeTextView.
|
|
|
|
|
|
|
|
## Types and Values
|
|
|
|
|
|
|
|
### TfeTextView
|
|
|
|
|
|
|
|
~~~
|
|
|
|
typedef struct _TfeTextView TfeTextView
|
|
|
|
struct _TfeTextView
|
|
|
|
{
|
|
|
|
GtkTextView parent;
|
|
|
|
GFile *file;
|
|
|
|
};
|
|
|
|
~~~
|
|
|
|
|
|
|
|
The members of this structure are not allowed to be accessed by any outer objects.
|
2021-06-18 15:35:20 +02:00
|
|
|
If you want to obtain a copy of the GFile, use `tfe_text_view_get_file`.
|
2021-02-03 15:04:08 +01:00
|
|
|
|
|
|
|
### TfeTextViewClass
|
|
|
|
|
|
|
|
~~~
|
|
|
|
typedef struct {
|
|
|
|
GtkTextViewClass parent_class;
|
|
|
|
} TfeTextViewClass;
|
|
|
|
~~~
|
|
|
|
|
|
|
|
No member is added because TfeTextView is a final type object.
|
|
|
|
|
|
|
|
### enum TfeTextViewOpenResponseType
|
|
|
|
|
|
|
|
Predefined values for the response id given by `open-response` signal.
|
|
|
|
|
|
|
|
Members:
|
|
|
|
|
|
|
|
- TFE_OPEN_RESPONSE_SUCCESS: The file is successfully opened.
|
|
|
|
- TFE_OPEN_RESPONSE_CANCEL: Reading file is canceled by the user.
|
|
|
|
- TFE_OPEN_RESPONSE_ERROR: An error happened during the opening or reading process.
|
|
|
|
|
2022-12-21 14:31:33 +01:00
|
|
|
## Properties
|
|
|
|
|
|
|
|
### wrap-mode
|
|
|
|
|
|
|
|
The property "wrap-mode" belongs to GtkTextView.
|
|
|
|
TfeTextView inherits it and the value is set to GTK\_WRAP\_WORD\_CHAR as a default.
|
|
|
|
|
2021-02-03 15:04:08 +01:00
|
|
|
## Signals
|
|
|
|
|
|
|
|
### change-file
|
|
|
|
|
|
|
|
~~~
|
|
|
|
void
|
|
|
|
user_function (TfeTextView *tv,
|
|
|
|
gpointer user_data)
|
|
|
|
~~~
|
|
|
|
|
|
|
|
Emitted when the GFile in the TfeTextView object is changed.
|
|
|
|
The signal is emitted when:
|
|
|
|
|
2021-04-20 15:03:23 +02:00
|
|
|
- a new file is opened and read
|
|
|
|
- a user choose a file with GtkFileChooserDialog and save the contents.
|
2021-06-18 15:35:20 +02:00
|
|
|
- an error occured during I/O operation, and GFile is removed as a result.
|
2021-02-03 15:04:08 +01:00
|
|
|
|
|
|
|
### open-response
|
|
|
|
|
|
|
|
~~~
|
|
|
|
void
|
|
|
|
user_function (TfeTextView *tv,
|
|
|
|
TfeTextViewOpenResponseType response-id,
|
|
|
|
gpointer user_data)
|
|
|
|
~~~
|
|
|
|
|
2021-06-18 15:35:20 +02:00
|
|
|
Emitted after the user calls `tfe_text_view_open`.
|
2021-02-03 15:04:08 +01:00
|
|
|
This signal informs the status of file opening and reading.
|