interface.h File Reference


Detailed Description

Define the top-most DWI application structure.

Author:
Copyright (c) 2002, 2004 Linas Vepstas <linas@linas.org>

Definition in file interface.h.

#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>

Go to the source code of this file.

Data Structures

struct  DuiInterfacePlugin_s

Defines

#define EstronInterface   DuiInterface

Typedefs

typedef struct DuiAction_s DuiAction
typedef struct DuiDatabase_s DuiDatabase
typedef struct DuiFilter_s DuiFilter
typedef struct DuiInterface_s DuiInterface
typedef struct DuiReport_s DuiReport
typedef struct DuiInterfacePlugin_s DuiInterfacePlugin

Functions

DuiInterface * dui_interface_new (void)
void dui_interface_destroy (DuiInterface *dui)
void dui_interface_set_name (DuiInterface *dui, const gchar *name)
void dui_interface_register_plugin (DuiInterface *, DuiInterfacePlugin *)
void dui_interface_realize (DuiInterface *, gint fatal_if_no_main)
DuiAction * dui_interface_find_action_by_name (DuiInterface *, const gchar *name)
DuiDatabase * dui_interface_find_database_by_name (DuiInterface *, const gchar *name)
DuiReport * dui_interface_find_report_by_name (DuiInterface *, const gchar *name)
void dui_interface_kvp_insert (DuiInterface *, const gchar *key, const gchar *value)
const gchar * dui_interface_kvp_lookup (DuiInterface *, const gchar *key)
void dui_interface_add_action (DuiInterface *, DuiAction *)
void dui_interface_add_database (DuiInterface *, DuiDatabase *)
void dui_interface_add_report (DuiInterface *, DuiReport *)
void dui_interface_add_object (DuiInterface *, const gchar *instance_name, GObject *)
GObject * dui_interface_find_object_by_name (DuiInterface *dui, const gchar *instance_name)
void estron_interface_set_gfile (DuiInterface *est, GFile *gfile)
gchar * estron_interface_get_filename (DuiInterface *est)
gchar * estron_interface_get_fileparent (DuiInterface *est)


Function Documentation

void dui_interface_add_object ( DuiInterface *  ,
const gchar *  instance_name,
GObject *   
)

Bug:
XXX hack alert -- we need to free the memory associated with the instance name when the interface is deleted

Definition at line 199 of file interface.c.

00200 {
00201     if (!dui || !instance_name) return;
00202 
00203     /* We only allow objects; this avoids a check elsewhere */
00204     if (!G_IS_OBJECT(gob))
00205     {
00206         PERR ("The instance \'%s\' is not an object!\n", instance_name);
00207         return;
00208     }
00209 
00212     g_hash_table_insert (dui->gobs, g_strdup(instance_name), gob);
00213 }

DuiAction* dui_interface_find_action_by_name ( DuiInterface *  ,
const gchar *  name 
)

Scan the list of reports in this interface, and return the one with the indicated name

Definition at line 290 of file interface.c.

00291 {
00292     GList *node;
00293 
00294     if (!dui || !name) return NULL;
00295 
00296     for (node=dui->action_handlers; node; node=node->next)
00297     {
00298         DuiAction *act = node->data;
00299         const gchar *actname = dui_action_get_name (act);
00300         if (actname && !strcmp(actname, name))
00301         {
00302             return act;
00303         }
00304     }
00305     return NULL;
00306 }

void dui_interface_kvp_insert ( DuiInterface *  ,
const gchar *  key,
const gchar *  value 
)

Insert a key-value pair into a hash table associated with this interface.

Definition at line 231 of file interface.c.

00233 {
00234     if (!dui || !key || !value) return;
00235 
00236     /* refuse insertion of new system keys */
00237     if (!strncmp (key, "/system/", 8)) return;
00238 
00239     PINFO ("(key=\'%s\' value=\'%s\')", key, value);
00240     g_hash_table_insert (dui->kvp, g_strdup(key), g_strdup(value));
00241 }

const gchar* dui_interface_kvp_lookup ( DuiInterface *  ,
const gchar *  key 
)

Fetch the value assoicated with the key in the hash table

Bug:
another fixed buffer to remove, again Timespec to blame.

Definition at line 244 of file interface.c.

00245 {
00246     if (!dui) return NULL;
00247 
00248     /* intercept pre-defined system keys */
00249     if (!strncmp (key, "/system/", 8))
00250     {
00251         key += 8;
00252         if (!strcmp (key, "datetime"))
00253         {
00256             static gchar date_string [100];
00257             time_t now = time (0);
00258             xxxgnc_secs_to_iso8601_buff (now, date_string);
00259             return date_string;
00260         }
00261         return NULL;
00262     }
00263     return g_hash_table_lookup (dui->kvp, key);
00264 }

void dui_interface_realize ( DuiInterface *  ,
gint  fatal_if_no_main 
)

This call will start making gui calls, and must be called only after glade and gtk have been initialized. The second argument, "fatal_if_no_main", indicates whether or not its a fatal error if no main window was found.

Definition at line 332 of file interface.c.

00333 {
00334     GList *node;
00335 
00336     if (!dui) return;
00337 
00338     for (node=dui->action_handlers; node; node=node->next)
00339     {
00340         DuiAction *act = node->data;
00341         dui_action_set_interface (act, dui);
00342     }
00343     for (node=dui->report_handlers; node; node=node->next)
00344     {
00345         DuiReport *rpt = node->data;
00346         dui_report_set_interface (rpt, dui);
00347     }
00348 
00349     for (node=dui->plugins; node; node=node->next)
00350     {
00351         DuiInterfacePlugin *plg = node->data;
00352         if (plg->realize)
00353         {
00354             (plg->realize) (plg->self, fatal_if_no_main);
00355         }
00356     }
00357 }

gchar* estron_interface_get_filename ( DuiInterface *  est  ) 

get the qualified filepath for the interface GFile

Definition at line 157 of file interface.c.

00158 {
00159     g_return_val_if_fail (est, NULL);
00160     return g_file_get_parse_name ((est->estron_file));
00161 }

gchar* estron_interface_get_fileparent ( DuiInterface *  est  ) 

get the qualified filepath for the directory containing the GFile

Definition at line 150 of file interface.c.

00151 {
00152     g_return_val_if_fail (est, NULL);
00153     return g_file_get_parse_name (g_file_get_parent ((est->estron_file)));
00154 }

void estron_interface_set_gfile ( DuiInterface *  est,
GFile *  gfile 
)

set the GFile to allow remote and local file handling

Definition at line 144 of file interface.c.

00145 {
00146     est->estron_file = gfile;
00147 }


Generated on Tue Apr 29 21:27:53 2008 for estron by  doxygen 1.5.5