Main Page   File List   Globals   Related Pages  

gui_dict.c File Reference

the dictionary widget and related functions. More...

#include <gtk/gtk.h>
#include "dict.h"
#include "gui_top_window.h"

Go to the source code of this file.

Functions

int dict_clistcmp (int n, const char *key, GtkCList *c)
 Compairs the key with the specified word in the dictionary. More...

int mybsearch (int n, int(*cmp)(int, gpointer, gpointer), const gpointer key, gpointer data)
 Binary search using a custom compare function. More...

void dict_inpch (GtkEntry *e, GtkObject *w)
 Callback to handle the change in the dictionary's quick search input box. More...

GtkWidget * dict_new ()
 Create a dictionoarry widget. More...

void dict_add_words (GtkWidget *dict, int wnum, char ***words)
 Adds a dictionary to a CList widget of a dictionary. More...

void dict_add_word (GtkWidget *dict, char **word)
 Adds a word in a dictionary widget. More...

GtkWidget * dict_new_from_file (const char *fn, const char *sep)
 Create a new dictionary widget from a file. More...

void gui_dict_open2_cb (GtkWidget *opencb)
 adds the selected dictionary to the notebook gets the file name selected using Dictionary->Open... More...

void gui_dict_open_cb ()
 The callback called when Dictionary->Open... More...

void gui_dict_close_cb ()
 Closes the current page in the notebook. More...


Detailed Description

the dictionary widget and related functions.

Definition in file gui_dict.c.


Function Documentation

void dict_add_word GtkWidget *    dict,
char **    word
 

Adds a word in a dictionary widget.

This is only a wrapper script to dict_add_words().

Parameters:
dict  the dictionary widget.
word  the word pair.
See also:
dict_add_words()

Definition at line 173 of file gui_dict.c.

References dict_add_words().

void dict_add_words GtkWidget *    dict,
int    wnum,
char ***    words
 

Adds a dictionary to a CList widget of a dictionary.

Adds the list of word pairs to the given widget. It updates the widget properties: dict_wnum (the number of words), dict_words (list to word pairs). It gets the CList from the dict_clist property of the widget.

Parameters:
dict  the dictionary widget which contains the properties and the CList widget containing the dictionary.
wnum  the number of words to add.
words  the list to word pairs to add.
See also:
dict_new()

Definition at line 149 of file gui_dict.c.

Referenced by dict_add_word(), and dict_new_from_file().

int dict_clistcmp int    n,
const char *    key,
GtkCList *    c
 

Compairs the key with the specified word in the dictionary.

Parameters:
n  the index of the word in the dictionary.
key  the specified key.
c  the CList which holds the words of the dictionary.
Returns:
  • -1 if the key is before the word of the dictionary.
  • 0 if the key and the word of the dictionary are the same.
  • 1 if the key is after the word of the dictionary.
See also:
mybsearch()

Definition at line 22 of file gui_dict.c.

Referenced by dict_inpch().

void dict_inpch GtkEntry *    e,
GtkObject *    w
 

Callback to handle the change in the dictionary's quick search input box.

The function gets the text from the entry and searches it in the clist of the given dictionary widget with mybsearch(), then selects the corresponding word in the CList and positions the adjustment to make that word visible.

Parameters:
e  the entry containing the word
w  the dictionary widget containing dictionary properties.
See also:
mybsearch() , dict_clistcmp()

Definition at line 78 of file gui_dict.c.

References dict_clistcmp(), and mybsearch().

Referenced by dict_new().

GtkWidget* dict_new  
 

Create a dictionoarry widget.

Returns:
the newly created widget.

Definition at line 100 of file gui_dict.c.

References dict_inpch().

Referenced by dict_new_from_file().

GtkWidget* dict_new_from_file const char *    fn,
const char *    sep
 

Create a new dictionary widget from a file.

Parameters:
fn  file name.
sep  separator used in the file.
Returns:
the new dictionary widget
See also:
dict_new() , dict_get_words() for dictionary file description , dict_add_words()

Definition at line 188 of file gui_dict.c.

References dict_add_words(), dict_get_words(), and dict_new().

Referenced by gui_dict_open2_cb(), and top_window_new().

void gui_dict_close_cb  
 

Closes the current page in the notebook.

See also:
notebook

Definition at line 255 of file gui_dict.c.

void gui_dict_open2_cb GtkWidget *    opencb
 

adds the selected dictionary to the notebook gets the file name selected using Dictionary->Open...

creates the new dictionary widget and puts it in the notebook widget.

Parameters:
opencb  the file selection window containing the file name.
See also:
dict_new_from_file() , notebook

Definition at line 210 of file gui_dict.c.

References dict_new_from_file().

Referenced by gui_dict_open_cb().

void gui_dict_open_cb  
 

The callback called when Dictionary->Open...

is selected. It creates a modal file selection dialog and connects a signal to its OK button to gui_dict_open2_cb() to handle the user request.

See also:
gui_dict_open2_cb()

Definition at line 228 of file gui_dict.c.

References gui_dict_open2_cb().

int mybsearch int    n,
int(*    cmp)(int, gpointer, gpointer),
const gpointer    key,
gpointer    data
 

Binary search using a custom compare function.

This function searches for the first element in a virtual list provided by a compare function where the key is greater or equal to the corresponding element in the list.

Parameters:
n  the number of elements in the virtual list.
cmp  a pointer to a compare function. Its three arguments are the index in the virtual list, the key and the data specified by the function caller. The compare function must return
  • -1 if the key is before the word of the dictionary.
  • 0 if the key and the word of the dictionary are the same.
  • 1 if the key is after the word of the dictionary.
Parameters:
key  the key (this will be passed to the compare function)
data  user data (this will be passed to the compare function)
Returns:
the index of the position of key in the virtual list.
See also:
dict_clistcmp() for an example of a compare function.

Definition at line 47 of file gui_dict.c.

Referenced by dict_inpch().


Generated on Tue Jun 25 12:02:42 2002 for LearnWords by doxygen1.2.15