-
Notifications
You must be signed in to change notification settings - Fork 2
/
gtk_statusbar.c
89 lines (69 loc) · 2.9 KB
/
gtk_statusbar.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "gtk_statusbar.h"
void status_menuitem_label (GtkMenuItem *menuitem, gpointer data)
{
mainwin_t *app = data;
einst_t *einst = app->einst[app->focused];
if (einst->cid) /* pop previous statusbar entry */
gtk_statusbar_pop (GTK_STATUSBAR (einst->sbar), einst->cid);
gchar *str; /* create string from menu item */
str = g_strdup_printf ("menuitem : %s",
gtk_menu_item_get_label (menuitem));
einst->cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (einst->sbar), str);
gtk_statusbar_push (GTK_STATUSBAR (einst->sbar), einst->cid, str);
g_free (str);
}
void status_pop (GtkWidget *widget, gpointer data)
{
mainwin_t *app = data;
einst_t *einst = app->einst[app->focused];
if (einst->cid)
gtk_statusbar_pop (GTK_STATUSBAR (einst->sbar), einst->cid);
if (widget) {}
}
/** FIXME cid must be associated with einst, the callback on-mark-set is a
* per-buffer signal, so one callback needed per buffer.
*/
void status_set_default (gpointer data)
{
mainwin_t *app = data;
einst_t *einst = app->einst[app->focused];
kinst_t *inst = einst->inst;
extern const gchar *bomstr[];
const gchar *langname;
gchar /**name,*/ *status;
gint lines;
/* Fri Jul 13 2018 18:57:03 CDT moved line/col update here from
* buffer_update_pos () to prevent line number jumping on scrolled-
* window scrolling when bottom of screen reached.
*/
GtkTextIter iter;
GtkTextBuffer *buffer = GTK_TEXT_BUFFER (inst->buf);
GtkTextMark *ins = gtk_text_buffer_get_insert (buffer);
/* get iter at 'insert' mark */
gtk_text_buffer_get_iter_at_mark (buffer, &iter, ins);
/* update line, lines & col */
inst->line = gtk_text_iter_get_line (&iter);
lines = gtk_text_buffer_get_line_count (buffer);
inst->col = gtk_text_iter_get_line_offset (&iter);
/* get syntax language */
if (inst->language)
langname = gtk_source_language_get_name (inst->language);
else
langname = "Plain Text";
/* get displayed name from treemodel */
// name = treeview_getname (data);
status = g_strdup_printf (" Line:%5d / %d Col:%4d | %s | "
"%s | %s | %s | %s",
inst->line + 1, lines, inst->col + 1,
app->overwrite ? "OVR" : "INS",
app->eolnm[app->eol], bomstr[app->bom],
langname,
app->dynwrap ? "Wrap On" : "Wrap Off");
if (einst->cid) /* pop previous statusbar entry */
gtk_statusbar_pop (GTK_STATUSBAR(einst->sbar), einst->cid);
einst->cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (einst->sbar),
status);
gtk_statusbar_push (GTK_STATUSBAR(einst->sbar), einst->cid, status);
g_free (status);
// g_free (name);
}