Fix indent (use 4 spaces) and add modelines
svn path=/trunk/; revision=54695
This commit is contained in:
parent
1a279aca25
commit
bf95d60829
|
@ -52,36 +52,36 @@ static void text_page_set_text(GtkWidget *page, const char *absolute_path);
|
|||
*/
|
||||
GtkWidget * text_page_new(const char *absolute_path)
|
||||
{
|
||||
GtkWidget *page_vb, *txt_scrollw, *txt;
|
||||
GtkWidget *page_vb, *txt_scrollw, *txt;
|
||||
|
||||
page_vb =ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(page_vb), 1);
|
||||
txt_scrollw = scrolled_window_new(NULL, NULL);
|
||||
page_vb =ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(page_vb), 1);
|
||||
txt_scrollw = scrolled_window_new(NULL, NULL);
|
||||
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(txt_scrollw),
|
||||
GTK_SHADOW_IN);
|
||||
gtk_box_pack_start(GTK_BOX(page_vb), txt_scrollw, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(page_vb), txt_scrollw, TRUE, TRUE, 0);
|
||||
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scrollw),
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
txt = gtk_text_view_new();
|
||||
gtk_text_view_set_editable(GTK_TEXT_VIEW(txt), FALSE);
|
||||
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(txt), GTK_WRAP_WORD);
|
||||
gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(txt), FALSE);
|
||||
/* XXX: there seems to be no way to add a small border *around* the whole text,
|
||||
* so the text will be "bump" against the edges.
|
||||
* the following is only working for left and right edges,
|
||||
* there is no such thing for top and bottom :-( */
|
||||
/* gtk_text_view_set_left_margin(GTK_TEXT_VIEW(txt), 3); */
|
||||
/* gtk_text_view_set_right_margin(GTK_TEXT_VIEW(txt), 3); */
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scrollw),
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
txt = gtk_text_view_new();
|
||||
gtk_text_view_set_editable(GTK_TEXT_VIEW(txt), FALSE);
|
||||
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(txt), GTK_WRAP_WORD);
|
||||
gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(txt), FALSE);
|
||||
/* XXX: there seems to be no way to add a small border *around* the whole text,
|
||||
* so the text will be "bump" against the edges.
|
||||
* the following is only working for left and right edges,
|
||||
* there is no such thing for top and bottom :-( */
|
||||
/* gtk_text_view_set_left_margin(GTK_TEXT_VIEW(txt), 3); */
|
||||
/* gtk_text_view_set_right_margin(GTK_TEXT_VIEW(txt), 3); */
|
||||
|
||||
g_object_set_data(G_OBJECT(page_vb), TEXT_KEY, txt);
|
||||
g_object_set_data(G_OBJECT(page_vb), TEXT_KEY, txt);
|
||||
|
||||
text_page_set_text(page_vb, absolute_path);
|
||||
gtk_container_add(GTK_CONTAINER(txt_scrollw), txt);
|
||||
gtk_widget_show(txt_scrollw);
|
||||
gtk_widget_show(txt);
|
||||
text_page_set_text(page_vb, absolute_path);
|
||||
gtk_container_add(GTK_CONTAINER(txt_scrollw), txt);
|
||||
gtk_widget_show(txt_scrollw);
|
||||
gtk_widget_show(txt);
|
||||
|
||||
return page_vb;
|
||||
return page_vb;
|
||||
}
|
||||
|
||||
|
||||
|
@ -112,23 +112,23 @@ static void text_page_insert(GtkWidget *page, const char *buffer, int nchars)
|
|||
*/
|
||||
static void text_page_set_text(GtkWidget *page, const char *absolute_path)
|
||||
{
|
||||
FILE *text_file;
|
||||
char line[4096+1]; /* XXX - size? */
|
||||
FILE *text_file;
|
||||
char line[4096+1]; /* XXX - size? */
|
||||
|
||||
text_file = ws_fopen(absolute_path, "r");
|
||||
if (text_file != NULL) {
|
||||
while (fgets(line, sizeof line, text_file) != NULL) {
|
||||
text_page_insert(page, line, (int) strlen(line));
|
||||
text_file = ws_fopen(absolute_path, "r");
|
||||
if (text_file != NULL) {
|
||||
while (fgets(line, sizeof line, text_file) != NULL) {
|
||||
text_page_insert(page, line, (int) strlen(line));
|
||||
}
|
||||
if(ferror(text_file)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Error reading file \"%s\": %s",
|
||||
absolute_path, g_strerror(errno));
|
||||
}
|
||||
fclose(text_file);
|
||||
} else {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not open file \"%s\": %s",
|
||||
absolute_path, g_strerror(errno));
|
||||
}
|
||||
if(ferror(text_file)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Error reading file \"%s\": %s",
|
||||
absolute_path, g_strerror(errno));
|
||||
}
|
||||
fclose(text_file);
|
||||
} else {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not open file \"%s\": %s",
|
||||
absolute_path, g_strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,9 +137,9 @@ static void text_page_set_text(GtkWidget *page, const char *absolute_path)
|
|||
*/
|
||||
static void text_page_clear(GtkWidget *page)
|
||||
{
|
||||
GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(g_object_get_data(G_OBJECT(page), TEXT_KEY)));
|
||||
GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(g_object_get_data(G_OBJECT(page), TEXT_KEY)));
|
||||
|
||||
gtk_text_buffer_set_text(buf, "", 0);
|
||||
gtk_text_buffer_set_text(buf, "", 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -148,6 +148,19 @@ static void text_page_clear(GtkWidget *page)
|
|||
*/
|
||||
void text_page_redraw(GtkWidget *page, const char *absolute_path)
|
||||
{
|
||||
text_page_clear(page);
|
||||
text_page_set_text(page, absolute_path);
|
||||
text_page_clear(page);
|
||||
text_page_set_text(page, absolute_path);
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines
|
||||
*
|
||||
* Local Variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
||||
|
|
|
@ -44,3 +44,16 @@ extern GtkWidget * text_page_new(const char *absolute_path);
|
|||
extern void text_page_redraw(GtkWidget *page, const char *absolute_path);
|
||||
|
||||
#endif /* __TEXT_PAGE_H__ */
|
||||
|
||||
/*
|
||||
* Editor modelines
|
||||
*
|
||||
* Local Variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue