pidgin  2.13.0
About: Pidgin is a chat program (multi-protocol instant messaging client) which lets you log in to accounts on multiple chat networks simultaneously (old name "gaim").
  Fossies Dox: pidgin-2.13.0.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

gntutils.c File Reference
#include "config.h"
#include "gntinternal.h"
#include "gntbutton.h"
#include "gntcheckbox.h"
#include "gntcombobox.h"
#include "gntentry.h"
#include "gntlabel.h"
#include "gntline.h"
#include "gnttextview.h"
#include "gnttree.h"
#include "gntutils.h"
#include "gntwindow.h"
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
Include dependency graph for gntutils.c:

Go to the source code of this file.

Data Structures

struct  duplicate_fns
struct  BindingView
struct  TriggerButton


#define GNT_LOG_DOMAIN   "Utils"


void gnt_util_get_text_bound (const char *text, int *width, int *height)
int gnt_util_onscreen_width (const char *start, const char *end)
const char * gnt_util_onscreen_width_to_pointer (const char *string, int len, int *w)
char * gnt_util_onscreen_fit_string (const char *string, int maxw)
static void duplicate_values (gpointer key, gpointer value, gpointer data)
GHashTable * g_hash_table_duplicate (GHashTable *src, GHashFunc hash, GEqualFunc equal, GDestroyNotify key_d, GDestroyNotify value_d, GDupFunc key_dup, GDupFunc value_dup)
gboolean gnt_boolean_handled_accumulator (GSignalInvocationHint *ihint, GValue *return_accu, const GValue *handler_return, gpointer dummy)
static void add_binding (gpointer key, gpointer value, gpointer data)
static void add_action (gpointer key, gpointer value, gpointer data)
GntWidgetgnt_widget_bindings_view (GntWidget *widget)
static GntWidgetgnt_widget_from_xmlnode (xmlNode *node, GntWidget **data[], int max)
void gnt_util_parse_widgets (const char *string, int num,...)
static void util_parse_html_to_tv (xmlNode *node, GntTextView *tv, GntTextFormatFlags flag)
gboolean gnt_util_parse_xhtml_to_textview (const char *string, GntTextView *tv)
static void free_trigger_button (TriggerButton *b)
static gboolean key_pressed (GntWidget *widget, const char *text, TriggerButton *trig)
void gnt_util_set_trigger_widget (GntWidget *wid, const char *text, GntWidget *button)

Macro Definition Documentation


#define GNT_LOG_DOMAIN   "Utils"

GNT - The GLib Ncurses Toolkit

GNT is the legal property of its developers, whose names are too numerous to list here. Please refer to the COPYRIGHT file distributed with this source distribution.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA

Definition at line 27 of file gntutils.c.

Function Documentation

◆ add_action()

static void add_action ( gpointer  key,
gpointer  value,
gpointer  data 

Definition at line 210 of file gntutils.c.

References data, BindingView::hash, and value.

Referenced by gnt_widget_bindings_view().

◆ add_binding()

static void add_binding ( gpointer  key,
gpointer  value,
gpointer  data 

◆ duplicate_values()

static void duplicate_values ( gpointer  key,
gpointer  value,
gpointer  data 

◆ free_trigger_button()

static void free_trigger_button ( TriggerButton b)

Definition at line 479 of file gntutils.c.

References b.

Referenced by gnt_util_set_trigger_widget().

◆ g_hash_table_duplicate()

GHashTable* g_hash_table_duplicate ( GHashTable *  src,
GHashFunc  hash,
GEqualFunc  equal,
GDestroyNotify  key_d,
GDestroyNotify  value_d,
GDupFunc  key_dup,
GDupFunc  value_dup 

Duplicate the contents of a hastable.

srcThe source hashtable.
hashThe hash-function to use.
equalThe hash-equal function to use.
key_dThe key-destroy function to use.
value_dThe value-destroy function to use.
key_dupThe function to use to duplicate the key.
value_dupThe function to use to duplicate the value.
The new hashtable.

Definition at line 164 of file gntutils.c.

References duplicate_values(), hash, duplicate_fns::key_dup, and duplicate_fns::value_dup.

Referenced by duplicate_hashes().

◆ gnt_boolean_handled_accumulator()

gboolean gnt_boolean_handled_accumulator ( GSignalInvocationHint *  ihint,
GValue *  return_accu,
const GValue *  handler_return,
gpointer  dummy 

To be used with g_signal_new. Look in the key_pressed signal-definition in gntwidget.c for usage.


Definition at line 174 of file gntutils.c.

Referenced by gnt_widget_class_init(), and gnt_wm_class_init().

◆ gnt_util_get_text_bound()

void gnt_util_get_text_bound ( const char *  text,
int *  width,
int *  height 

Compute the width and height required to view the text on the screen.

textThe text to be displayed.
widthThe width required is set here, if not NULL.
heightThe height required is set here, if not NULL.

Definition at line 49 of file gntutils.c.

References count, gnt_util_onscreen_width(), max, and text.

Referenced by draw_tooltip_real(), finch_notify_common(), finch_notify_userinfo(), gnt_button_size_request(), and gnt_label_size_request().

◆ gnt_util_onscreen_fit_string()

char* gnt_util_onscreen_fit_string ( const char *  string,
int  maxw 

Inserts newlines in 'string' where necessary so that its onscreen width is no more than 'maxw'.

stringThe string.
maxwThe width that the string should fit into. If maxw is <= 0, then the available maximum width is used.
A newly allocated string that needs to be freed by the caller.

Definition at line 119 of file gntutils.c.

References FALSE, gnt_util_onscreen_width(), gnt_util_onscreen_width_to_pointer(), NULL, str, and strchr.

Referenced by gnt_button_new(), gnt_label_set_property(), and make_sure_text_fits().

◆ gnt_util_onscreen_width()

int gnt_util_onscreen_width ( const char *  start,
const char *  end 

Get the onscreen width of a string, or a substring.

startThe beginning of the string.
endThe end of the string. The width returned is the width upto (but not including) end. If end is NULL, then start is considered as a NULL-terminated string.
The on-screen width of the string.

Definition at line 83 of file gntutils.c.

References NULL.

Referenced by gnt_entry_draw(), gnt_entry_key_pressed(), gnt_text_view_append_text_with_tag(), gnt_tree_adjust_columns(), gnt_util_get_text_bound(), gnt_util_onscreen_fit_string(), gnt_util_onscreen_width_to_pointer(), move_end(), move_forward(), move_forward_word(), redraw_tree(), show_suggest_dropdown(), update_row_text(), and widestringwidth().

◆ gnt_util_onscreen_width_to_pointer()

const char* gnt_util_onscreen_width_to_pointer ( const char *  str,
int  len,
int *  w 

Computes and returns the string after a specific number of onscreen characters.

strThe string.
lenThe length to consider. If non-positive, the entire screenlength is used.
wThe actual width of the string upto the returned offset, if not NULL.
The string after len offset.

Definition at line 97 of file gntutils.c.

References gnt_util_onscreen_width(), NULL, and str.

Referenced by get_title_thingies(), gnt_combo_box_draw(), gnt_text_view_append_text_with_tag(), gnt_util_onscreen_fit_string(), redraw_tree(), and update_row_text().

◆ gnt_util_parse_widgets()

void gnt_util_parse_widgets ( const char *  string,
int  num,

Parse widgets from an XML description. For example,

GntWidget *win, *button;
<vwindow id='0' fill='0' align='2'> \
<label>This is a test</label> \
<button id='1'>OK</button> \
2, &win, &button);
stringThe XML string.
numThe number of widgets to return, followed by 'num' GntWidget **

Definition at line 352 of file gntutils.c.

References data, gnt_widget_from_xmlnode(), dbus-buddyicons-example::node, and NULL.

◆ gnt_util_parse_xhtml_to_textview()

gboolean gnt_util_parse_xhtml_to_textview ( const char *  string,
GntTextView tv 

Parse an XHTML string and add it in a GntTextView with appropriate text flags.

stringThe XHTML string
tvThe GntTextView
TRUE if the string was added to the textview properly, FALSE otherwise.

Definition at line 448 of file gntutils.c.

References FALSE, flag, GNT_TEXT_FLAG_NORMAL, dbus-buddyicons-example::node, NULL, TRUE, tv, and util_parse_html_to_tv().

Referenced by finch_notify_common(), and finch_notify_userinfo().

◆ gnt_util_set_trigger_widget()

void gnt_util_set_trigger_widget ( GntWidget widget,
const char *  key,
GntWidget button 

Make some keypress activate a button when some key is pressed with 'wid' in focus.

widgetThe widget
keyThe key to trigger the button
buttonThe button to trigger
2.0.0 (gnt), 2.1.0 (pidgin)

Definition at line 496 of file gntutils.c.

References TriggerButton::button, free_trigger_button(), key_pressed(), text, and TriggerButton::text.

Referenced by finch_accounts_show_all(), finch_certmgr_show(), finch_plugins_show_all(), finch_pounces_manager_show(), and finch_savedstatus_show_all().

◆ gnt_widget_bindings_view()

GntWidget* gnt_widget_bindings_view ( GntWidget widget)

Get a helpful display about the bindings of a widget.

widgetThe widget to get bindings for.
Returns a GntTree populated with "key" -> "binding" for the widget.

Definition at line 216 of file gntutils.c.

References _GntBindableClass::actions, add_action(), add_binding(), bind, _GntBindableClass::bindings, GNT_BINDABLE, GNT_BINDABLE_CLASS, GNT_BINDABLE_GET_CLASS, GNT_TREE, gnt_tree_adjust_columns(), gnt_tree_new_with_columns(), gnt_tree_set_compare_func(), gnt_widget_destroy(), hash, klass, NULL, tree, BindingView::tree, and widget.

◆ gnt_widget_from_xmlnode()

◆ key_pressed()

static gboolean key_pressed ( GntWidget widget,
const char *  text,
TriggerButton trig 

◆ util_parse_html_to_tv()

static void util_parse_html_to_tv ( xmlNode *  node,
GntTextView tv,
GntTextFormatFlags  flag 
Definition: gntwidget.h:98
void gnt_util_parse_widgets(const char *string, int num,...)
Definition: gntutils.c:352