[Glade-users] Accessing a specific widget



This is a multi-part message in MIME format.

------=_NextPart_000_0001_01C0933C.99AA9CB0
Content-Type: text/plain;
        charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hi,

Thank you for your help on a previous post. I realize that in order to
access a widget, you need to use the lookup_widget function, I understand
how I am supposed to access it this way when I have a set such as ths:
Window
          |_ CList      - CList = lookup_widget(Window, "CList"); Assuming the
variables have been initialized, this works (Thanks to Andrae Muys)

However, in a new project I have set up it fails. I do not get any errors
but it crashes with a segmentation directly related to the lookup_widget
function. The widget tree looks like this:
winViewLogs
             |_+dock1
             |_+nbviewlogs
                        |_scrolledwindow1
                                         |_cl_bootlog
        No matter where I try the lookup_widget function to get a return poiinter
to any of the above widgets, I keep receiving a segmentation fault. I have
included the code as well, just to make sure if I was missing something. I
was able to isolate it to the lookup_widget function.

Any help would greatly be appreciated.

Thank you.



------=_NextPart_000_0001_01C0933C.99AA9CB0
Content-Type: application/octet-stream;
        name="main.c"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
        filename="main.c"

#ifdef HAVE_CONFIG_H=0A=
#  include <config.h>=0A=
#endif=0A=
#include <gtk/gtk.h>=0A=
#include <gnome.h>=0A=
#include <sys/utsname.h>=0A=
#include "interface.h"=0A=
#include "support.h"=0A=
#define MAX_CHAR_LEN 1024=0A=
=0A=
GtkWidget *winViewLogs;=0A=
GtkWidget *dock1;=0A=
GtkWidget *nbviewlogs;=0A=
GtkWidget *cl_bootlog;=0A=
=0A=
int date_break;=0A=
int supress_blanks;=0A=
char computer [256];    =0A=
struct utsname uts;=0A=
=0A=
struct sys_log {=0A=
        char    log_date[8];=0A=
        char    log_time[9];=0A=
        char    log_daemon[64];=0A=
        char    log_msg[MAX_CHAR_LEN];=0A=
};=0A=
=0A=
char *left(char *string, int pos);=0A=
char *mid(char *string, int begpos, int charlen);=0A=
void gethost(void);=0A=
void create_boot_log_struct(char *string);=0A=
void create_sys_log_struct(char *string);=0A=
void print_sys_log ( struct sys_log *p_log);=0A=
=0A=
char *left(char *string, int pos) {=0A=
        char    temp[MAX_CHAR_LEN];=0A=
=0A=
        strncpy(temp, string, pos);=0A=
        temp[pos]  =3D '\0';=0A=
        return temp;=0A=
}=0A=
=0A=
char *mid(char *string, int begpos, int charlen) {=0A=
        char temp[MAX_CHAR_LEN];=0A=
=0A=
        if (charlen =3D=3D 0) =0A=
                charlen =3D MAX_CHAR_LEN - strlen(string);=0A=
        =0A=
        strncpy(temp, &string[begpos], charlen);=0A=
        temp[charlen] =3D '\0';=0A=
        return temp;=0A=
}                               =0A=
=0A=
void gethost(void) {=0A=
        if (gethostname(computer, 255) !=3D 0 || uname(&uts)  < 0  )=0A=
                exit(1);=0A=
}=0A=
=0A=
void create_boot_log_struct(char *string) {=0A=
        int pos1;=0A=
        int hostlen;=0A=
        struct sys_log pres_sys_log;=0A=
=0A=
        hostlen =3D strlen(computer);=0A=
=0A=
        pos1 =3D  (strstr(mid(string,15,0), ":") -  mid(string,15,0)) - 1;=0A=
=0A=
        strcpy(pres_sys_log.log_date,  left(string,7));=0A=
        strcpy(pres_sys_log.log_time, mid(string, 7, 8));=0A=
    strcpy(pres_sys_log.log_daemon, (mid(string, 17 + hostlen, pos1 - =
4)));   =0A=
        strcpy(pres_sys_log.log_msg, mid(string, pos1 +20, 0));=0A=
=0A=
        print_sys_log(&pres_sys_log);=0A=
}=0A=
                =0A=
void create_sys_log_struct(char *string) {=0A=
        int pos1;=0A=
        int hostlen;=0A=
        struct sys_log pres_sys_log;=0A=
        =0A=
        hostlen =3D strlen(computer);=0A=
=0A=
        strcpy(pres_sys_log.log_date,  left(string,7));=0A=
        strcpy(pres_sys_log.log_time, mid(string, 7, 8));=0A=
=0A=
        if ((strstr(mid(string,15,0), "]:") !=3D NULL))  {=0A=
                pos1 =3D  ((strstr(mid(string,15,0), "[") - 1) -  mid(string,15,0));=0A=
         strcpy(pres_sys_log.log_daemon, (mid(string, 17 + hostlen, pos1 - =
4)));=0A=
        =0A=
                pos1 =3D  ((strstr(mid(string,15,0), "]:") - 1) -  mid(string,15,0)) + =
2;=0A=
        strcpy(pres_sys_log.log_msg, mid(string, pos1 +20, 0));=0A=
    }=0A=
        else {=0A=
                strcpy(pres_sys_log.log_daemon, " ");=0A=
                strcpy(pres_sys_log.log_msg, mid(string, 15, 0));=0A=
        }       =0A=
        print_sys_log(&pres_sys_log);=0A=
}=0A=
=0A=
void print_sys_log ( struct sys_log *p_log) {=0A=
        gchar *text[4];=0A=
                =0A=
cl_bootlog =3D lookup_widget( winViewLogs, "cl_bootlog");=0A=
=0A=
//      gint    row;=0A=
=0A=
=0A=
        =0A=
        text[0] =3D p_log->log_date;=0A=
        text[1] =3D p_log->log_time;=0A=
        text[2] =3D p_log->log_daemon;=0A=
        text[3] =3D p_log->log_msg;=0A=
=0A=
//      row =3D gtk_clist_append ( GTK_CLIST ( cl_bootlog ), text);=0A=
}=0A=
=0A=
=0A=
int=0A=
main (int argc, char *argv[])=0A=
{=0A=
        GtkWidget *winViewLogs;=0A=
        FILE *fp;       =0A=
        char tmpline[MAX_CHAR_LEN];=0A=
=0A=
#ifdef ENABLE_NLS=0A=
  bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);=0A=
  textdomain (PACKAGE);=0A=
#endif=0A=
=0A=
  gnome_init ("winViewLogs", VERSION, argc, argv);=0A=
=0A=
  winViewLogs =3D create_winViewLogs ();=0A=
  gtk_widget_show (winViewLogs);=0A=
=0A=
        if ((fp =3D fopen("/var/log/messages", "r")) =3D=3D NULL) {=0A=
                printf("Can't open %s\n", argv[1]);=0A=
                return(1);=0A=
                }=0A=
                else {=0A=
                   while(fgets(tmpline, MAX_CHAR_LEN, fp) !=3D NULL)=0D{=0A=
                   =0A=
                        create_sys_log_struct(tmpline);=0A=
                        }=0A=
                }=0A=
=0A=
=0A=
=0A=
=0A=
=0A=
  gtk_main ();=0A=
  return 0;=0A=
}=0A=
=0A=

------=_NextPart_000_0001_01C0933C.99AA9CB0--






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]