-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgtk_statusbar.c
109 lines (89 loc) · 3.8 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include "gtk_statusbar.h"
void status_save_filename (kwinst *app, gchar *filename)
{ /* filename parameter not used in this implementation */
gchar *status;
/* if (filename)
status = g_strdup_printf ("Saving %s...", filename);
else */
status = g_strdup_printf ("Saving %s...", app->filename);
status_update_str (app, status);
g_free (status);
if (filename) {}
}
void status_update_str (kwinst *app, gchar *s)
{
if (app->cid) /* pop previous statusbar entry */
gtk_statusbar_pop (GTK_STATUSBAR (app->statusbar), app->cid);
gchar *str;
if (s && *s)
str = g_strdup (s);
// str = g_strdup_printf ("Operation : %s", s);
else
str = g_strdup_printf ("Error : statusbar update failed 'NULL'");
app->cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (app->statusbar), str);
gtk_statusbar_push (GTK_STATUSBAR (app->statusbar), app->cid, str);
g_free (str);
}
void status_menuitem_label (GtkMenuItem *menuitem, kwinst *app)
{
if (app->cid) /* pop previous statusbar entry */
gtk_statusbar_pop (GTK_STATUSBAR (app->statusbar), app->cid);
gchar *str; /* create string from menu item */
str = g_strdup_printf ("menuitem : %s",
gtk_menu_item_get_label (menuitem));
// gtk_menu_item_get_label (GTK_MENU_ITEM (widget)));
app->cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (app->statusbar), str);
gtk_statusbar_push (GTK_STATUSBAR (app->statusbar), app->cid, str);
g_free (str);
}
void status_pop (GtkWidget *widget, kwinst *app)
{
if (app->cid)
gtk_statusbar_pop (GTK_STATUSBAR (app->statusbar), app->cid);
if (widget) {}
}
void status_set_default (kwinst *app)
{
extern const gchar *bomstr[];
gchar *status;
/* 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 (app->buffer);
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 */
app->line = gtk_text_iter_get_line (&iter);
app->lines = gtk_text_buffer_get_line_count (buffer);
app->col = gtk_text_iter_get_line_offset (&iter);
#ifdef HAVESOURCEVIEW
if (app->langname) {
status = g_strdup_printf (" line:%5d / %d col:%4d | %s | %s | %s | %s",
app->line + 1, app->lines, app->col + 1,
app->overwrite ? "OVR" : "INS",
app->eolnm[app->eol], bomstr[app->bom],
app->langname);
}
else {
status = g_strdup_printf (" line:%5d / %d col:%4d | %s | %s | %s",
app->line + 1, app->lines, app->col + 1,
app->overwrite ? "OVR" : "INS",
app->eolnm[app->eol], bomstr[app->bom]);
}
#else
status = g_strdup_printf (" line:%5d / %d col:%4d | %s | %s | %s",
app->line + 1, app->lines, app->col + 1,
app->overwrite ? "OVR" : "INS",
app->eolnm[app->eol], bomstr[app->bom]);
#endif
if (app->cid) /* pop previous statusbar entry */
gtk_statusbar_pop (GTK_STATUSBAR (app->statusbar), app->cid);
else
app->cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (app->statusbar),
status);
gtk_statusbar_push (GTK_STATUSBAR (app->statusbar), app->cid, status);
g_free (status);
}