Mercurial > pidgin
changeset 16124:ab3f93232a2d
Add a utility function to assist scrolling in a textview.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 15 Apr 2007 05:42:14 +0000 |
parents | bc280c341679 |
children | 5f204f55af09 |
files | finch/gntconv.c finch/gntdebug.c finch/libgnt/gnttextview.c finch/libgnt/gnttextview.h |
diffstat | 4 files changed, 26 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/finch/gntconv.c Sun Apr 15 05:28:29 2007 +0000 +++ b/finch/gntconv.c Sun Apr 15 05:42:14 2007 +0000 @@ -159,23 +159,6 @@ gnt_entry_clear(GNT_ENTRY(ggconv->entry)); return TRUE; } - else if (key[0] == 27) - { - if (strcmp(key, GNT_KEY_DOWN) == 0) - gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 1); - else if (strcmp(key, GNT_KEY_UP) == 0) - gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), -1); - else if (strcmp(key, GNT_KEY_PGDOWN) == 0) - gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), ggconv->tv->priv.height - 2); - else if (strcmp(key, GNT_KEY_PGUP) == 0) - gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), -(ggconv->tv->priv.height - 2)); - else - return FALSE; - return TRUE; - } - else - { - } return FALSE; } @@ -332,6 +315,7 @@ gnt_entry_set_word_suggest(GNT_ENTRY(ggc->entry), TRUE); gnt_entry_set_always_suggest(GNT_ENTRY(ggc->entry), FALSE); + gnt_text_view_attach_scroll_widget(GNT_TEXT_VIEW(ggc->tv), ggc->entry); g_signal_connect_after(G_OBJECT(ggc->entry), "key_pressed", G_CALLBACK(entry_key_pressed), ggc); g_signal_connect(G_OBJECT(ggc->window), "destroy", G_CALLBACK(closing_window), ggc);
--- a/finch/gntdebug.c Sun Apr 15 05:28:29 2007 +0000 +++ b/finch/gntdebug.c Sun Apr 15 05:42:14 2007 +0000 @@ -46,26 +46,6 @@ gboolean timestamps; } debug; -static gboolean -debug_window_kpress_cb(GntWidget *wid, const char *key, GntTextView *view) -{ - if (key[0] == 27) - { - if (strcmp(key, GNT_KEY_DOWN) == 0) - gnt_text_view_scroll(view, 1); - else if (strcmp(key, GNT_KEY_UP) == 0) - gnt_text_view_scroll(view, -1); - else if (strcmp(key, GNT_KEY_PGDOWN) == 0) - gnt_text_view_scroll(view, wid->priv.height - 2); - else if (strcmp(key, GNT_KEY_PGUP) == 0) - gnt_text_view_scroll(view, -(wid->priv.height - 2)); - else - return FALSE; - return TRUE; - } - return FALSE; -} - static void finch_debug_print(PurpleDebugLevel level, const char *category, const char *args) @@ -265,7 +245,7 @@ gnt_widget_set_name(debug.window, "debug-window"); g_signal_connect(G_OBJECT(debug.window), "destroy", G_CALLBACK(reset_debug_win), NULL); - g_signal_connect(G_OBJECT(debug.window), "key_pressed", G_CALLBACK(debug_window_kpress_cb), debug.tview); + gnt_text_view_attach_scroll_widget(GNT_TEXT_VIEW(debug.tview), debug.window); } gnt_widget_show(debug.window);
--- a/finch/libgnt/gnttextview.c Sun Apr 15 05:28:29 2007 +0000 +++ b/finch/libgnt/gnttextview.c Sun Apr 15 05:42:14 2007 +0000 @@ -739,3 +739,25 @@ return count; } +static gboolean +scroll_tv(GntWidget *wid, const char *key, GntTextView *tv) +{ + if (strcmp(key, GNT_KEY_PGUP) == 0) { + gnt_text_view_scroll(tv, -(GNT_WIDGET(tv)->priv.height - 2)); + } else if (strcmp(key, GNT_KEY_PGDOWN) == 0) { + gnt_text_view_scroll(tv, GNT_WIDGET(tv)->priv.height - 2); + } else if (strcmp(key, GNT_KEY_DOWN) == 0) { + gnt_text_view_scroll(tv, 1); + } else if (strcmp(key, GNT_KEY_UP) == 0) { + gnt_text_view_scroll(tv, -1); + } else { + return FALSE; + } + return TRUE; +} + +void gnt_text_view_attach_scroll_widget(GntTextView *view, GntWidget *widget) +{ + g_signal_connect(G_OBJECT(widget), "key_pressed", G_CALLBACK(scroll_tv), view); +} +
--- a/finch/libgnt/gnttextview.h Sun Apr 15 05:28:29 2007 +0000 +++ b/finch/libgnt/gnttextview.h Sun Apr 15 05:42:14 2007 +0000 @@ -81,6 +81,8 @@ /* If text is NULL, then the tag is removed. */ int gnt_text_view_tag_change(GntTextView *view, const char *name, const char *text, gboolean all); +void gnt_text_view_attach_scroll_widget(GntTextView *view, GntWidget *widget); + G_END_DECLS #endif /* GNT_TEXT_VIEW_H */