summaryrefslogtreecommitdiff
path: root/finch/libgnt
diff options
context:
space:
mode:
Diffstat (limited to 'finch/libgnt')
-rw-r--r--finch/libgnt/configure.ac12
-rw-r--r--finch/libgnt/gntbox.c4
-rw-r--r--finch/libgnt/gntcombobox.c79
-rw-r--r--finch/libgnt/gntentry.c33
-rw-r--r--finch/libgnt/gnttextview.c2
-rw-r--r--finch/libgnt/gnttree.c30
-rw-r--r--finch/libgnt/gnttree.h55
-rw-r--r--finch/libgnt/gntutils.c12
8 files changed, 190 insertions, 37 deletions
diff --git a/finch/libgnt/configure.ac b/finch/libgnt/configure.ac
index e62a8dded9..5775f27f53 100644
--- a/finch/libgnt/configure.ac
+++ b/finch/libgnt/configure.ac
@@ -24,9 +24,9 @@ AC_PREREQ([2.50])
# Make sure to update ../../configure.ac with libgnt version changes.
#
-m4_define([gnt_lt_current], [7])
+m4_define([gnt_lt_current], [8])
m4_define([gnt_major_version], [2])
-m4_define([gnt_minor_version], [7])
+m4_define([gnt_minor_version], [8])
m4_define([gnt_micro_version], [0])
m4_define([gnt_version_suffix], [devel])
m4_define([gnt_version],
@@ -265,6 +265,10 @@ else
for location in $ac_ncurses_includes /usr/include/ncursesw /usr/include
do
f="$location/ncurses.h"
+ orig_CFLAGS="$CFLAGS"
+ orig_CPPFLAGS="$CPPFLAGS"
+ CFLAGS="$CFLAGS -I$location"
+ CPPFLAGS="$CPPFLAGS -I$location"
AC_CHECK_HEADER($f,[
AC_MSG_CHECKING([if $f supports wide characters])
AC_TRY_COMPILE([
@@ -283,9 +287,13 @@ else
fi
found_ncurses_h=yes
+ CFLAGS="$orig_CFLAGS"
+ CPPFLAGS="$orig_CPPFLAGS"
AC_MSG_RESULT([yes])
break
], [
+ CFLAGS="$orig_CFLAGS"
+ CPPFLAGS="$orig_CPPFLAGS"
AC_MSG_RESULT([no])
])
])
diff --git a/finch/libgnt/gntbox.c b/finch/libgnt/gntbox.c
index fffff69bc8..4abeab7a77 100644
--- a/finch/libgnt/gntbox.c
+++ b/finch/libgnt/gntbox.c
@@ -422,7 +422,9 @@ gnt_box_confirm_size(GntWidget *widget, int width, int height)
gnt_widget_get_size(wid, &w, &h);
- if (wid != last && !child && w > 0 && h > 0 && gnt_widget_confirm_size(wid, w - wchange, h - hchange)) {
+ if (wid != last && !child && w > 0 && h > 0 &&
+ !GNT_WIDGET_IS_FLAG_SET(wid, GNT_WIDGET_INVISIBLE) &&
+ gnt_widget_confirm_size(wid, w - wchange, h - hchange)) {
child = wid;
break;
}
diff --git a/finch/libgnt/gntcombobox.c b/finch/libgnt/gntcombobox.c
index e1b4faf482..aed14eaa1e 100644
--- a/finch/libgnt/gntcombobox.c
+++ b/finch/libgnt/gntcombobox.c
@@ -25,6 +25,7 @@
#include "gntcombobox.h"
#include "gnttree.h"
#include "gntmarshal.h"
+#include "gntstyle.h"
#include "gntutils.h"
#include <string.h>
@@ -149,12 +150,11 @@ static gboolean
gnt_combo_box_key_pressed(GntWidget *widget, const char *text)
{
GntComboBox *box = GNT_COMBO_BOX(widget);
- if (GNT_WIDGET_IS_FLAG_SET(box->dropdown->parent, GNT_WIDGET_MAPPED))
- {
- if (text[1] == 0)
- {
- switch (text[0])
- {
+ gboolean showing = !!GNT_WIDGET_IS_FLAG_SET(box->dropdown->parent, GNT_WIDGET_MAPPED);
+
+ if (showing) {
+ if (text[1] == 0) {
+ switch (text[0]) {
case '\r':
case '\t':
case '\n':
@@ -165,20 +165,42 @@ gnt_combo_box_key_pressed(GntWidget *widget, const char *text)
return TRUE;
}
}
- if (gnt_widget_key_pressed(box->dropdown, text))
- return TRUE;
}
- else
+
+ if (gnt_widget_key_pressed(box->dropdown, text)) {
+ if (!showing)
+ popup_dropdown(box);
+ return TRUE;
+ }
+
{
- if (text[0] == 27)
- {
- if (strcmp(text, GNT_KEY_UP) == 0 ||
- strcmp(text, GNT_KEY_DOWN) == 0)
- {
- popup_dropdown(box);
- return TRUE;
- }
- }
+#define SEARCH_IN_RANGE(start, end) do { \
+ GntTreeRow *row; \
+ for (row = start; row != end; \
+ row = gnt_tree_row_get_next(tree, row)) { \
+ gpointer key = gnt_tree_row_get_key(tree, row); \
+ GList *list = gnt_tree_get_row_text_list(tree, key); \
+ gboolean found = FALSE; \
+ found = (list->data && g_ascii_strncasecmp(text, list->data, len) == 0); \
+ g_list_foreach(list, (GFunc)g_free, NULL); \
+ g_list_free(list); \
+ if (found) { \
+ if (!showing) \
+ popup_dropdown(box); \
+ gnt_tree_set_selected(tree, key); \
+ return TRUE; \
+ } \
+ } \
+} while (0)
+
+ int len = strlen(text);
+ GntTree *tree = GNT_TREE(box->dropdown);
+ GntTreeRow *current = tree->current;
+
+ SEARCH_IN_RANGE(gnt_tree_row_get_next(tree, current), NULL);
+ SEARCH_IN_RANGE(tree->top, current);
+
+#undef SEARCH_IN_RANGE
}
return FALSE;
@@ -229,9 +251,20 @@ gnt_combo_box_size_changed(GntWidget *widget, int oldw, int oldh)
gnt_widget_set_size(box->dropdown, widget->priv.width - 1, box->dropdown->priv.height);
}
+static gboolean
+dropdown_menu(GntBindable *b, GList *null)
+{
+ if (GNT_WIDGET_IS_FLAG_SET(GNT_COMBO_BOX(b)->dropdown->parent, GNT_WIDGET_MAPPED))
+ return FALSE;
+ popup_dropdown(GNT_COMBO_BOX(b));
+ return TRUE;
+}
+
static void
gnt_combo_box_class_init(GntComboBoxClass *klass)
{
+ GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass);
+
parent_class = GNT_WIDGET_CLASS(klass);
parent_class->destroy = gnt_combo_box_destroy;
@@ -245,7 +278,7 @@ gnt_combo_box_class_init(GntComboBoxClass *klass)
widget_lost_focus = parent_class->lost_focus;
parent_class->lost_focus = gnt_combo_box_lost_focus;
- signals[SIG_SELECTION_CHANGED] =
+ signals[SIG_SELECTION_CHANGED] =
g_signal_new("selection-changed",
G_TYPE_FROM_CLASS(klass),
G_SIGNAL_RUN_LAST,
@@ -254,6 +287,12 @@ gnt_combo_box_class_init(GntComboBoxClass *klass)
gnt_closure_marshal_VOID__POINTER_POINTER,
G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
+ gnt_bindable_class_register_action(bindable, "dropdown", dropdown_menu,
+ GNT_KEY_DOWN, NULL);
+ gnt_bindable_register_binding(bindable, "dropdown", GNT_KEY_UP, NULL);
+
+ gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), bindable);
+
GNTDEBUG;
}
@@ -272,7 +311,7 @@ gnt_combo_box_init(GTypeInstance *instance, gpointer class)
GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_NO_SHADOW | GNT_WIDGET_NO_BORDER | GNT_WIDGET_TRANSIENT);
gnt_box_set_pad(GNT_BOX(box), 0);
gnt_box_add_widget(GNT_BOX(box), combo->dropdown);
-
+
widget->priv.minw = 4;
widget->priv.minh = 3;
GNTDEBUG;
diff --git a/finch/libgnt/gntentry.c b/finch/libgnt/gntentry.c
index 97fb32cff9..29db9a61c2 100644
--- a/finch/libgnt/gntentry.c
+++ b/finch/libgnt/gntentry.c
@@ -480,8 +480,7 @@ history_search(GntBindable *bind, GList *null)
{
GntEntry *entry = GNT_ENTRY(bind);
GList *iter;
- const char *current , *pos;
- int len;
+ const char *current;
if (entry->history->prev && entry->search->needle)
current = entry->search->needle;
@@ -491,13 +490,11 @@ history_search(GntBindable *bind, GList *null)
if (!entry->histlength || !entry->history->next || !*current)
return FALSE;
- len = g_utf8_strlen(current, -1);
-
for (iter = entry->history->next; iter; iter = iter->next) {
const char *str = iter->data;
/* A more utf8-friendly version of strstr would have been better, but
* for now, this will have to do. */
- if ((pos = strstr(str, current)))
+ if (strstr(str, current) != NULL)
break;
}
@@ -579,6 +576,28 @@ suggest_prev(GntBindable *bind, GList *null)
}
static gboolean
+suggest_next_page(GntBindable *bind, GList *null)
+{
+ GntEntry *entry = GNT_ENTRY(bind);
+ if (entry->ddown) {
+ gnt_bindable_perform_action_named(GNT_BINDABLE(entry->ddown), "page-down", NULL);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static gboolean
+suggest_prev_page(GntBindable *bind, GList *null)
+{
+ GntEntry *entry = GNT_ENTRY(bind);
+ if (entry->ddown) {
+ gnt_bindable_perform_action_named(GNT_BINDABLE(entry->ddown), "page-up", NULL);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static gboolean
del_to_home(GntBindable *bind, GList *null)
{
GntEntry *entry = GNT_ENTRY(bind);
@@ -986,6 +1005,10 @@ gnt_entry_class_init(GntEntryClass *klass)
GNT_KEY_DOWN, NULL);
gnt_bindable_class_register_action(bindable, "suggest-prev", suggest_prev,
GNT_KEY_UP, NULL);
+ gnt_bindable_class_register_action(bindable, "suggest-next-page", suggest_next_page,
+ GNT_KEY_PGDOWN, NULL);
+ gnt_bindable_class_register_action(bindable, "suggest-prev-page", suggest_prev_page,
+ GNT_KEY_PGUP, NULL);
gnt_bindable_class_register_action(bindable, "history-next", history_next,
GNT_KEY_CTRL_DOWN, NULL);
gnt_bindable_class_register_action(bindable, "history-prev", history_prev,
diff --git a/finch/libgnt/gnttextview.c b/finch/libgnt/gnttextview.c
index 41139a9191..a9024e2d8c 100644
--- a/finch/libgnt/gnttextview.c
+++ b/finch/libgnt/gnttextview.c
@@ -711,7 +711,7 @@ int gnt_text_view_get_lines_below(GntTextView *view)
int gnt_text_view_get_lines_above(GntTextView *view)
{
int above = 0;
- GList *list = view->list;
+ GList *list;
list = g_list_nth(view->list, GNT_WIDGET(view)->priv.height);
if (!list)
return 0;
diff --git a/finch/libgnt/gnttree.c b/finch/libgnt/gnttree.c
index 072f4080d7..1095a0ccab 100644
--- a/finch/libgnt/gnttree.c
+++ b/finch/libgnt/gnttree.c
@@ -1926,3 +1926,33 @@ gpointer gnt_tree_get_parent_key(GntTree *tree, gpointer key)
return (row && row->parent) ? row->parent->key : NULL;
}
+gpointer gnt_tree_row_get_key(GntTree *tree, GntTreeRow *row)
+{
+ g_return_val_if_fail(row && row->tree == tree, NULL);
+ return row->key;
+}
+
+GntTreeRow * gnt_tree_row_get_next(GntTree *tree, GntTreeRow *row)
+{
+ g_return_val_if_fail(row && row->tree == tree, NULL);
+ return row->next;
+}
+
+GntTreeRow * gnt_tree_row_get_prev(GntTree *tree, GntTreeRow *row)
+{
+ g_return_val_if_fail(row && row->tree == tree, NULL);
+ return row->prev;
+}
+
+GntTreeRow * gnt_tree_row_get_child(GntTree *tree, GntTreeRow *row)
+{
+ g_return_val_if_fail(row && row->tree == tree, NULL);
+ return row->child;
+}
+
+GntTreeRow * gnt_tree_row_get_parent(GntTree *tree, GntTreeRow *row)
+{
+ g_return_val_if_fail(row && row->tree == tree, NULL);
+ return row->parent;
+}
+
diff --git a/finch/libgnt/gnttree.h b/finch/libgnt/gnttree.h
index 9e39dad7b4..894d3fb632 100644
--- a/finch/libgnt/gnttree.h
+++ b/finch/libgnt/gnttree.h
@@ -222,6 +222,61 @@ char * gnt_tree_get_selection_text(GntTree *tree);
GList * gnt_tree_get_row_text_list(GntTree *tree, gpointer key);
/**
+ * Get the key of a row.
+ *
+ * @param tree The tree
+ * @param row The GntTreeRow object
+ *
+ * @return The key of the row.
+ * @since 2.8.0 (gnt), 2.7.2 (pidgin)
+ */
+gpointer gnt_tree_row_get_key(GntTree *tree, GntTreeRow *row);
+
+/**
+ * Get the next row.
+ *
+ * @param tree The tree
+ * @param row The GntTreeRow object
+ *
+ * @return The next row.
+ * @since 2.8.0 (gnt), 2.7.2 (pidgin)
+ */
+GntTreeRow * gnt_tree_row_get_next(GntTree *tree, GntTreeRow *row);
+
+/**
+ * Get the previous row.
+ *
+ * @param tree The tree
+ * @param row The GntTreeRow object
+ *
+ * @return The previous row.
+ * @since 2.8.0 (gnt), 2.7.2 (pidgin)
+ */
+GntTreeRow * gnt_tree_row_get_prev(GntTree *tree, GntTreeRow *row);
+
+/**
+ * Get the child row.
+ *
+ * @param tree The tree
+ * @param row The GntTreeRow object
+ *
+ * @return The child row.
+ * @since 2.8.0 (gnt), 2.7.2 (pidgin)
+ */
+GntTreeRow * gnt_tree_row_get_child(GntTree *tree, GntTreeRow *row);
+
+/**
+ * Get the parent row.
+ *
+ * @param tree The tree
+ * @param row The GntTreeRow object
+ *
+ * @return The parent row.
+ * @since 2.8.0 (gnt), 2.7.2 (pidgin)
+ */
+GntTreeRow * gnt_tree_row_get_parent(GntTree *tree, GntTreeRow *row);
+
+/**
* Get a list of text of the current row.
*
* @param tree The tree
diff --git a/finch/libgnt/gntutils.c b/finch/libgnt/gntutils.c
index 452e8253ca..1e41c363c9 100644
--- a/finch/libgnt/gntutils.c
+++ b/finch/libgnt/gntutils.c
@@ -385,7 +385,6 @@ util_parse_html_to_tv(xmlNode *node, GntTextView *tv, GntTextFormatFlags flag)
const char *name;
char *content;
xmlNode *ch;
- gboolean processed = FALSE;
char *url = NULL;
gboolean insert_nl_s = FALSE, insert_nl_e = FALSE;
@@ -426,17 +425,14 @@ util_parse_html_to_tv(xmlNode *node, GntTextView *tv, GntTextFormatFlags flag)
for (ch = node->children; ch; ch = ch->next) {
if (ch->type == XML_ELEMENT_NODE) {
- processed = TRUE;
util_parse_html_to_tv(ch, tv, flag);
+ } else if (ch->type == XML_TEXT_NODE) {
+ content = (char*)xmlNodeGetContent(ch);
+ gnt_text_view_append_text_with_flags(tv, content, flag);
+ xmlFree(content);
}
}
- if (!processed) {
- content = (char*)xmlNodeGetContent(node);
- gnt_text_view_append_text_with_flags(tv, content, flag);
- xmlFree(content);
- }
-
if (url) {
char *href = g_strdup_printf(" (%s)", url);
gnt_text_view_append_text_with_flags(tv, href, flag);