Ejemplo n.º 1
0
void Server::doRunProcess(BIO_p client)
{
	int childpid = fork();
	if (childpid < 0)
		throw StdException("Error while forking!");

	if (childpid == 0) {
		isChild = true;
		// We have to make sure that parent's BIO will not be shuted
		// down when we (child) will be cleaning up
		itsBIO->setClose(false);

		// Close fd manually, so we are not leaking descriptors
		close(itsBIO->getFD());

		try {
			// Perform handshake to decide whether client is authorized
			BIO_p auth = itsAuth->Authenticate(client);
			Manage(auth);
		} catch (osock::BIO::RemoteDiedException &e) {
			WRN << "Client died (fork)" << std::endl;
		}


		DBG << "Client served (fork)" << std::endl;
	} else {
		// We have to make sure that child's BIO will not be shuted
		// down when we (parent) will be cleaning up
		client->setClose(false);
		// Close fd manually, so we are not leaking descriptors
		close(client->getFD());

		DBG << "Getting back to accepting clients (fork)" << std::endl;
	}
}
Ejemplo n.º 2
0
void PS_TransparencyDialog::OpenTransparencyDialog(CWnd* pParentWnd)
{
    if (!IsCreated())
        DoCreateDialog(pParentWnd);

    Manage();

    UpdateUIFromDef();
}
Ejemplo n.º 3
0
/*****************************************************************************
 * Run: Gtk+ thread
 *****************************************************************************
 * this part of the interface is in a separate thread so that we can call
 * gtk_main() from within it without annoying the rest of the program.
 *****************************************************************************/
static void Run( intf_thread_t *p_intf )
{
#ifdef NEED_GTK2_MAIN
    gdk_threads_enter();
#else
    /* gnome_program_init needs to know the command line. We don't care, so
     * we give it an empty one */
    char  *p_args[] = { "", NULL };
    int    i_args   = 1;
    int    i_dummy;

    gtk_set_locale();
    gnome_program_init( PACKAGE, VERSION, LIBGNOMEUI_MODULE,
                        i_args, p_args,
                        GNOME_PARAM_APP_DATADIR, "",//PACKAGE_DATA_DIR,
                        NULL );
#endif

    /* Create some useful widgets that will certainly be used */
    p_intf->p_sys->p_app = create_app1();

    /* Set the title of the main window */
    //gtk_window_set_title( GTK_WINDOW(p_intf->p_sys->p_app),
    //                      VOUT_TITLE " (Gtk+ interface)" );

    /* Show the control window */
    gtk_widget_show( p_intf->p_sys->p_app );

#ifdef NEED_GTK2_MAIN
    while( !p_intf->b_die )
    {
        Manage( p_intf );

        /* Sleep to avoid using all CPU - since some interfaces need to
         * access keyboard events, a 100ms delay is a good compromise */
        gdk_threads_leave();
        msleep( INTF_IDLE_SLEEP );
        gdk_threads_enter();
    }
#else
    /* Sleep to avoid using all CPU - since some interfaces needs to access
     * keyboard events, a 100ms delay is a good compromise */
    i_dummy = gtk_timeout_add( INTF_IDLE_SLEEP / 1000, (GtkFunction)Manage,
                               p_intf );
    /* Enter Gtk mode */
    gtk_main();
    /* Remove the timeout */
    gtk_timeout_remove( i_dummy );
#endif

    gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_app) );

#ifdef NEED_GTK2_MAIN
    gdk_threads_leave();
#endif
}
Ejemplo n.º 4
0
void Server::doRunCallback(BIO_p client)
{
	try {
		// Perform handshake to decide whether client is authorized
		BIO_p auth = itsAuth->Authenticate(client);
		Manage(auth);
	} catch (osock::BIO::RemoteDiedException &e) {
		WRN << "Client died (callback)" << std::endl;
	}
}
Ejemplo n.º 5
0
void Manage(int what)
{
	cout << "Would you like to:" << endl;
	cout << "1. Search existing objects" << endl;
	cout << "2. Add a new one" << endl;
	cout << "3. Go back" << endl;

	char ch;

	cin.clear();
	cin.ignore(numeric_limits<streamsize>::max(), '\n');

	ch = getchar();

	switch (ch)
	{
	case'1':
		switch (what)
		{
		case 1:
			bookSearch();
			break;
		case 2:
			clientSearch();
			break;
		case 3:
			catSearch();
			break;
		}
		break;
	case '2':
		switch (what)
		{
		case 1:
			add_book();
			break;
		case 2:
			add_client();
			break;
		case 3:
			add_cat();
			break;
		}
		break;
	case '3':
		break;
	default:
		cout << "Please provide a valid response." << endl;
		cin.clear();
		cin.ignore(numeric_limits<streamsize>::max(), '\n');
		Manage(what);
		break;
	}
system("pause");
}
Ejemplo n.º 6
0
/*****************************************************************************
 * Run: Gtk2 thread
 *****************************************************************************
 * this part of the interface is in a separate thread so that we can call
 * gtk_main() from within it without annoying the rest of the program.
 *****************************************************************************/
static void Run( intf_thread_t *p_intf )
{
#ifdef NEED_GTK2_MAIN
    gdk_threads_enter();
#else
    /* gtk_init needs to know the command line. We don't care, so we
     * give it an empty one */
    char  *p_args[] = { "", NULL };
    char **pp_args  = p_args;
    int    i_args   = 1;
    int    i_dummy;

    gtk_set_locale();
    gtk_init( &i_args, &pp_args );
#endif

    /* Create some useful widgets that will certainly be used */
    p_intf->p_sys->p_window = create_window1();

    /* Set the title of the main window */
    gtk_window_set_title( GTK_WINDOW(p_intf->p_sys->p_window),
                          VOUT_TITLE " (Gtk2 interface)");

    /* Show the control window */
    gtk_widget_show( p_intf->p_sys->p_window );

#ifdef NEED_GTK2_MAIN
    while( !p_intf->b_die )
    {
        Manage( p_intf );

        /* Sleep to avoid using all CPU - since some interfaces need to
         * access keyboard events, a 100ms delay is a good compromise */
        gdk_threads_leave();
        msleep( INTF_IDLE_SLEEP );
        gdk_threads_enter();
    }
#else
    /* Sleep to avoid using all CPU - since some interfaces needs to access
     * keyboard events, a 100ms delay is a good compromise */
    i_dummy = gtk_timeout_add( INTF_IDLE_SLEEP / 1000, (GtkFunction)Manage,
                               p_intf );
    /* Enter Gtk mode */
    gtk_main();
    /* Remove the timeout */
    gtk_timeout_remove( i_dummy );
#endif

    gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_window) );

#ifdef NEED_GTK2_MAIN
    gdk_threads_leave();
#endif
}
Ejemplo n.º 7
0
void Server::serverThread(BIO_p client)
{
	try {
		// Perform handshake to decide whether client is authorized
		BIO_p auth = itsAuth->Authenticate(client);
		Manage(auth);
	} catch (osock::BIO::RemoteDiedException &e) {
		WRN << "Client died (thread)" << std::endl;
	}

	DBG << "Client served (thread)" << std::endl;
}
Ejemplo n.º 8
0
 inline void UntilTask::S2() {
   m_state = 2;
   auto task = m_taskFactory->Create();
   Manage(task);
   auto publisher = Reactors::MakePublisherReactor(&task->GetPublisher());
   auto taskReactor = Reactors::Do(m_callbacks.GetCallback(
     std::bind(&UntilTask::OnTaskUpdate, this, std::placeholders::_1)),
     publisher);
   m_reactorMonitor->AddEvent(publisher);
   m_reactorMonitor->AddReactor(taskReactor);
   task->Execute();
   return S4();
 }
Ejemplo n.º 9
0
void
BookTab::set_tab (UAS_Pointer<UAS_Common> &tab_ptr)
{
  if (f_tab_ptr != tab_ptr)
    {
      f_tab_ptr = tab_ptr;

      if (f_tab_ptr != (const int)0)
	{
	  UAS_String st = f_tab_ptr->tab_title();
	  LabelString ((char *) st);
	  if (f_selected)
	    {
	      deselect();
	      f_selected = FALSE;
	    }
	  Manage();
	}
      else
	{
	  Unmanage();
	}
    }
}
Ejemplo n.º 10
0
/**
* @brief 程序入口
* @param 无
* @return 返回
*/
int main(void)
{
	int nOperRole = 0xff;
	char szOper[OPERCODELEN + 1];

	PubInitUiParam();
	ASSERT_QUIT(Ums_CheckMcVer());	/*重要:判断主控版本*/
	PubLuaOpen();
	PubLuaDisplay("LuaSetUIStyle");	/*设置系统风格*/
	RecordVersion();	/*记录版本信息*/
	PubKbHit();						/*清除按键缓*/

	/**
	* 版本校验(首次运行检测)
	*/
	FirstRunChk();
	/**
	* 模块初始化,重要!!!
	*/
	AppInit();

#if defined(USE_TMS)
	/**<检查是否有应用或者参数的更新*/
	DoTmsTask(TMS_POS_CHKUPDATA);
	GetTmsParamDown();
#endif

	Cup_InitScrLed();

	SetControlChkPinpad(YES);

	
	/*
	* 运行任务
	*/
	while(1)
	{
		/**
		* 设备检查
		*/
		ChkPdAndRF();

		/**
		* 通讯初始化
		*/
		CommInit();
		memset(szOper, 0, sizeof(szOper));
		GetWaterOper(szOper);/**<取做过交易的(有流水)操作员号码*/
		SetOperLimit(szOper);

		GetVarLastOperInfo(szOper, &nOperRole);/**<取最后登陆的操作员信息(保存的)*/
		SetCurrentOper(szOper, NULL, nOperRole);/**<将最后登陆的操作员信息设置给操作员模块*/

		if (ChkIsMCReturn() == APP_SUCC || nOperRole != NORMALOPER || YES != GetVarIsLogin())
		{
			if (OperLogon() != APP_SUCC)
			{
				/*取消已设置的系统风格*/
				PubLuaDisplay("LuaUnSetUIStyle");
				PubLuaClose();
				CommDump();
				Cup_ExitScrLed();
				return APP_QUIT;
			}
		}
		GetCurrentOper(szOper, NULL, &nOperRole);/**<从操作员模块获取当前的操作员信息*/
		SetVarLastOperInfo(szOper, (char)nOperRole);/**<保存最后登陆的操作员信息*/

		/**
		* 系统管理员
		*/
		if (nOperRole == ADMINOPER)
		{
			Manage();
			ParamSave();
			PubClearAll();
		}
		else if(nOperRole == HIDEMENUOPER)
		{
			HideManage();
		}
		else if(nOperRole == MANAGEROPER)
		{
			Operate();
		}
		else
		{
			
			if (APP_SUCC != AppTrans())
			{
				PubLuaDisplay("LuaUnSetUIStyle");
				PubLuaClose();
				CommDump();
				Cup_ExitScrLed();
				return APP_QUIT;
			}
		}
	}
}
int main()
{
    RTR3InitExeNoArguments(0);
    RTPrintf("tstMemAutoPtr: TESTING...\n");

#define CHECK_EXPR(expr) \
    do { bool const f = !!(expr); if (!f) { RTPrintf("tstMemAutoPtr(%d): %s!\n", __LINE__, #expr); g_cErrors++; } } while (0)

    /*
     * Some simple stuff.
     */
    {
        RTCMemAutoPtr<char> NilObj;
        CHECK_EXPR(!NilObj);
        CHECK_EXPR(NilObj.get() == NULL);
        CHECK_EXPR(NilObj.release() == NULL);
        NilObj.reset();
    }

    {
        RTCMemAutoPtr<char> Alloc(10);
        CHECK_EXPR(Alloc.get() != NULL);
        char *pch = Alloc.release();
        CHECK_EXPR(pch != NULL);
        CHECK_EXPR(Alloc.get() == NULL);

        RTCMemAutoPtr<char> Manage(pch);
        CHECK_EXPR(Manage.get() == pch);
        CHECK_EXPR(&Manage[0] == pch);
        CHECK_EXPR(&Manage[1] == &pch[1]);
        CHECK_EXPR(&Manage[9] == &pch[9]);
    }

    /*
     * Use the electric fence memory API to check alternative template
     * arguments and also check some subscript / reference limit thing.
     */
    {
        RTCMemAutoPtr<char, RTCMemEfAutoFree<char>, RTMemEfReallocNP> Electric(10);
        CHECK_EXPR(Electric.get() != NULL);
        Electric[0] = '0';
        CHECK_EXPR(Electric[0]  == '0');
        CHECK_EXPR(*Electric  == '0');
        //CHECK_EXPR(Electric  == '0');
        Electric[9] = '1';
        CHECK_EXPR(Electric[9] == '1');
        /* Electric[10] = '2'; - this will crash (of course) */
    }

    /*
     * Check that memory is actually free when it should be and isn't when it shouldn't.
     * Use the electric heap to get some extra checks.
     */
    g_cFrees = 0;
    {
        RTCMemAutoPtr<char, tstMemAutoPtrDestructorCounter, RTMemEfReallocNP> FreeIt(128);
        FreeIt[127] = '0';
    }
    CHECK_EXPR(g_cFrees == 1);

    g_cFrees = 0;
    {
        RTCMemAutoPtr<char, tstMemAutoPtrDestructorCounter, RTMemEfReallocNP> FreeIt2(128);
        FreeIt2[127] = '1';
        FreeIt2.reset();
        FreeIt2.alloc(128);
        FreeIt2[127] = '2';
        FreeIt2.reset(FreeIt2.get()); /* this one is weird, but it's how things works... */
    }
    CHECK_EXPR(g_cFrees == 2);

    g_cFrees = 0;
    {
        RTCMemAutoPtr<char, tstMemAutoPtrDestructorCounter, RTMemEfReallocNP> DontFreeIt(256);
        DontFreeIt[255] = '0';
        RTMemEfFreeNP(DontFreeIt.release());
    }
    CHECK_EXPR(g_cFrees == 0);

    g_cFrees = 0;
    {
        RTCMemAutoPtr<char, tstMemAutoPtrDestructorCounter, RTMemEfReallocNP> FreeIt3(128);
        FreeIt3[127] = '0';
        CHECK_EXPR(FreeIt3.realloc(128));
        FreeIt3[127] = '0';
        CHECK_EXPR(FreeIt3.realloc(256));
        FreeIt3[255] = '0';
        CHECK_EXPR(FreeIt3.realloc(64));
        FreeIt3[63] = '0';
        CHECK_EXPR(FreeIt3.realloc(32));
        FreeIt3[31] = '0';
    }
    CHECK_EXPR(g_cFrees == 1);

    g_cFrees = 0;
    {
        RTCMemAutoPtr<char, tstMemAutoPtrDestructorCounter, RTMemEfReallocNP> FreeIt4;
        CHECK_EXPR(FreeIt4.alloc(123));
        CHECK_EXPR(FreeIt4.realloc(543));
        FreeIt4 = (char *)NULL;
        CHECK_EXPR(FreeIt4.get() == NULL);
    }
    CHECK_EXPR(g_cFrees == 1);

    /*
     * Check the ->, [] and * (unary) operators with some useful struct.
     */
    {
        RTCMemAutoPtr<TSTMEMAUTOPTRSTRUCT> Struct1(1);
        Struct1->a = 0x11223344;
        Struct1->b = 0x55667788;
        Struct1->c = 0x99aabbcc;
        CHECK_EXPR(Struct1->a == 0x11223344);
        CHECK_EXPR(Struct1->b == 0x55667788);
        CHECK_EXPR(Struct1->c == 0x99aabbcc);

        Struct1[0].a = 0x11223344;
        Struct1[0].b = 0x55667788;
        Struct1[0].c = 0x99aabbcc;
        CHECK_EXPR(Struct1[0].a == 0x11223344);
        CHECK_EXPR(Struct1[0].b == 0x55667788);
        CHECK_EXPR(Struct1[0].c == 0x99aabbcc);

        (*Struct1).a = 0x11223344;
        (*Struct1).b = 0x55667788;
        (*Struct1).c = 0x99aabbcc;
        CHECK_EXPR((*Struct1).a == 0x11223344);
        CHECK_EXPR((*Struct1).b == 0x55667788);
        CHECK_EXPR((*Struct1).c == 0x99aabbcc);

        /* since at it... */
        Struct1.get()->a = 0x11223344;
        Struct1.get()->b = 0x55667788;
        Struct1.get()->c = 0x99aabbcc;
        CHECK_EXPR(Struct1.get()->a == 0x11223344);
        CHECK_EXPR(Struct1.get()->b == 0x55667788);
        CHECK_EXPR(Struct1.get()->c == 0x99aabbcc);
    }

    /*
     * Check the zeroing of memory.
     */
    {
        RTCMemAutoPtr<uint64_t, RTCMemAutoDestructor<uint64_t>, tstMemAutoPtrAllocatorNoZero> Zeroed1(1, true);
        CHECK_EXPR(*Zeroed1 == 0);
    }

    {
        RTCMemAutoPtr<uint64_t, RTCMemAutoDestructor<uint64_t>, tstMemAutoPtrAllocatorNoZero> Zeroed2;
        Zeroed2.alloc(5, true);
        CHECK_EXPR(Zeroed2[0] == 0);
        CHECK_EXPR(Zeroed2[1] == 0);
        CHECK_EXPR(Zeroed2[2] == 0);
        CHECK_EXPR(Zeroed2[3] == 0);
        CHECK_EXPR(Zeroed2[4] == 0);
    }

    /*
     * Summary.
     */
    if (!g_cErrors)
        RTPrintf("tstMemAutoPtr: SUCCESS\n");
    else
        RTPrintf("tstMemAutoPtr: FAILED - %d errors\n", g_cErrors);
    return !!g_cErrors;
}
Ejemplo n.º 12
0
//  object control
void PS_ObjectDialog::OpenObjectDialog()
{
    if (!IsCreated())
    {
        //controlDialog.CreateShell(basePlatform.plotShell.GetWidget(), true, "Plot Object Control");
        CRect rect(0, 0, 180, 400);

        char plotName[80];
        basePlatform.GetMainWindowTitle(plotName, false, 80);
        ConcatString(plotName, "::Control", 80);

        CreateShell(NULL, true, plotName, rect);

        ArgListC args;

        //args.AddArg(XmNautoUnmanage,          True);
        //args.AddWidthHeight(175, 400);
        //controlDialogForm.CreateWidget(controlDialog, args);
        //TODO:
        //controlDialogForm.AddCallback(XmNfocusCallback, FocusCB, this);

        // add buttons to bottom
        // bottom row buttons
        args.Clear();
        args.LeftFormAttach();
        args.RightFormAttach();
        args.BottomFormAttach();
        bottomRowForm.InitWidget(controlDialogForm.GetWidget(), args);

        args.Clear();
        args.AddArg(Arg::XmNwidth, 76);
        args.BottomFormAttach(2);
        args.SetPlaceHolder();

        // close
        args.LeftPosAttach(2);
        //TODO:
        //controlCloseButton.FixedSizeButtonArgs(args);
        controlCloseButton.StdButtonInit(" Close ", bottomRowForm.GetWidget(), args);
        controlCloseButton.AddOtherObjectCallback(CloseButtonCB, this);

        // apply
        args.ResetPlace();
        args.LeftPosAttach(50);
        controlApplyButton.StdButtonInit("Apply", bottomRowForm.GetWidget(), args);
        controlApplyButton.AddOtherObjectCallback(ApplyButtonCB, this);

        // next row buttons
        args.Clear();
        args.LeftFormAttach();
        args.RightFormAttach();
        args.BottomBaseAttach(bottomRowForm);
        nextRowForm.InitWidget(controlDialogForm.GetWidget(), args);

        args.Clear();
        args.AddArg(Arg::XmNwidth, 76);
        args.BottomFormAttach(2);
        args.SetPlaceHolder();

        // step button
        args.LeftPosAttach(2);
        controlClearButton.StdButtonInit(" Clear ", nextRowForm.GetWidget(), args);
        controlClearButton.AddOtherObjectCallback(ClearAllButtonCB, this);

        //  to start
        args.ResetPlace();
        args.LeftPosAttach(50);
        controlAllButton.StdButtonInit(" Set ", nextRowForm.GetWidget(), args);
        controlAllButton.AddOtherObjectCallback(SetAllButtonCB, this);

        // scroll window
        args.Clear();
        args.StdFormAttach();
        args.BottomBaseAttach(nextRowForm);
        //controlScrollArea.needHorizontal = false;
        controlScrollArea.InitWidget(controlDialogForm.GetWidget(), args);
        SetForm(&controlDialogForm);
    }

    Manage();
}
Ejemplo n.º 13
0
int chooseActivity()
{
	char ch;

	cout << "What would you like to do?" << endl << endl;
	cout << "1. Manage books" << endl;
	cout << "2. Manage clients" << endl;
	cout << "3. Manage categories" << endl;
	cout << "4. View books" << endl;
	cout << "5. View clients" << endl;
	cout << "6. View categories" << endl;
	cout << "7. Save session data" << endl;
	cout << "8. Exit" << endl;

	cout.flush();

	cin.clear();
	cin.ignore(numeric_limits<streamsize>::max(), '\n');

	ch = getchar();
	system("CLS");

	switch (ch)
	{
	case '1':
		Manage(1);
		break;
	case '2':
		Manage(2);
		break;
	case '3':
		Manage(3);
		break;
	case '4':
		book_view();
		system("pause");
		break;
	case '5':
		client_view();
		system("pause");
		break;
	case '6':
		cat_print();
		system("pause");
		break;
    case '7':
        AllExport();
        system("pause");
		break;
	case '8':
		return (1);
	default:
		cout << "Please provide a valid response." << endl;
		cin.clear();
		cin.ignore(numeric_limits<streamsize>::max(), '\n');
		chooseActivity();
		return(-1);
		break;
	}
	return(0);
}
Ejemplo n.º 14
0
/*****************************************************************************
 * Run: Gtk+ thread
 *****************************************************************************
 * this part of the interface is in a separate thread so that we can call
 * gtk_main() from within it without annoying the rest of the program.
 *****************************************************************************/
static void Run( intf_thread_t *p_intf )
{
#ifndef NEED_GTK2_MAIN
    /* gtk_init needs to know the command line. We don't care, so we
     * give it an empty one */
    char  *p_args[] = { "", NULL };
    char **pp_args  = p_args;
    int    i_args   = 1;
    int    i_dummy;
#endif
    playlist_t        *p_playlist;
    GtkCellRenderer   *p_renderer = NULL;
    GtkTreeViewColumn *p_column   = NULL;
    GtkListStore      *p_filelist = NULL;
    GtkListStore      *p_playlist_store = NULL;

#ifndef NEED_GTK2_MAIN
    gtk_set_locale ();
    msg_Dbg( p_intf, "Starting pda GTK2+ interface" );
    gtk_init( &i_args, &pp_args );
#else
    /* Initialize Gtk+ */
    msg_Dbg( p_intf, "Starting pda GTK2+ interface thread" );
    gdk_threads_enter();
#endif

    /* Create some useful widgets that will certainly be used */
/* FIXME: magic path */
    add_pixmap_directory("share");
    add_pixmap_directory("/usr/share/vlc");

    /* Path for pixmaps under linupy 1.4 */
    add_pixmap_directory("/usr/local/share/pixmaps/vlc");
    /* Path for pixmaps under linupy 2.0 */
    add_pixmap_directory("/usr/share/pixmaps/vlc");

    p_intf->p_sys->p_window = create_pda();
    if (p_intf->p_sys->p_window == NULL)
    {
        msg_Err( p_intf, "unable to create pda interface" );
    }

    /* Store p_intf to keep an eye on it */
    gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_window),
                         "p_intf", p_intf );

    /* Set the title of the main window */
    gtk_window_set_title( GTK_WINDOW(p_intf->p_sys->p_window),
                          VOUT_TITLE " (PDA Linux interface)");

    /* Get the notebook object */
    p_intf->p_sys->p_notebook = GTK_NOTEBOOK( gtk_object_get_data(
        GTK_OBJECT( p_intf->p_sys->p_window ), "notebook" ) );

    /* Get the slider object */
    p_intf->p_sys->p_slider = (GtkHScale*) lookup_widget( p_intf->p_sys->p_window, "timeSlider" );
    p_intf->p_sys->p_slider_label = (GtkLabel*) lookup_widget( p_intf->p_sys->p_window, "timeLabel" );
    if (p_intf->p_sys->p_slider == NULL)
        msg_Err( p_intf, "Time slider widget not found." );
    if (p_intf->p_sys->p_slider_label == NULL)
        msg_Err( p_intf, "Time label widget not found." );

    /* Connect the date display to the slider */
    p_intf->p_sys->p_adj = gtk_range_get_adjustment( GTK_RANGE(p_intf->p_sys->p_slider) );
    if (p_intf->p_sys->p_adj == NULL)
        msg_Err( p_intf, "Adjustment range not found." );
    g_signal_connect( GTK_OBJECT( p_intf->p_sys->p_adj ), "value_changed",
                         G_CALLBACK( E_(GtkDisplayDate) ), p_intf );
    p_intf->p_sys->f_adj_oldvalue = 0;
    p_intf->p_sys->i_adj_oldvalue = 0;

    /* BEGIN OF FILEVIEW GTK_TREE_VIEW */
    p_intf->p_sys->p_tvfile = NULL;
    p_intf->p_sys->p_tvfile = (GtkTreeView *) lookup_widget( p_intf->p_sys->p_window,
                                                             "tvFileList");
    if (NULL == p_intf->p_sys->p_tvfile)
       msg_Err(p_intf, "Error obtaining pointer to File List");

    /* Insert columns 0 */
    p_renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 0, (gchar *) N_("Filename"), p_renderer, NULL);
    p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 0 );
    gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 0 );
    gtk_tree_view_column_set_sort_column_id(p_column, 0);
    /* Insert columns 1 */
    p_renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 1, (gchar *) N_("Permissions"), p_renderer, NULL);
    p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 1 );
    gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 1 );
    gtk_tree_view_column_set_sort_column_id(p_column, 1);
    /* Insert columns 2 */
    p_renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 2, (gchar *) N_("Size"), p_renderer, NULL);
    p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 2 );
    gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 2 );
    gtk_tree_view_column_set_sort_column_id(p_column, 2);
    /* Insert columns 3 */
    p_renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 3, (gchar *) N_("Owner"), p_renderer, NULL);
    p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 3 );
    gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 3 );
    gtk_tree_view_column_set_sort_column_id(p_column, 3);
    /* Insert columns 4 */
    p_renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 4, (gchar *) N_("Group"), p_renderer, NULL);
    p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 4 );
    gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 4 );
    gtk_tree_view_column_set_sort_column_id(p_column, 4);

    /* Get new directory listing */
    p_filelist = gtk_list_store_new (5,
                G_TYPE_STRING, /* Filename */
                G_TYPE_STRING, /* permissions */
                G_TYPE_UINT64, /* File size */
                G_TYPE_STRING, /* Owner */
                G_TYPE_STRING);/* Group */
    ReadDirectory(p_intf, p_filelist, ".");
    gtk_tree_view_set_model(GTK_TREE_VIEW(p_intf->p_sys->p_tvfile), GTK_TREE_MODEL(p_filelist));
    g_object_unref(p_filelist);     /* Model will be released by GtkTreeView */
    gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(p_intf->p_sys->p_tvfile)),GTK_SELECTION_MULTIPLE);

    /* Column properties */
    gtk_tree_view_set_headers_visible(p_intf->p_sys->p_tvfile, TRUE);
    gtk_tree_view_columns_autosize(p_intf->p_sys->p_tvfile);
    gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(p_intf->p_sys->p_tvfile),TRUE);
    /* END OF FILEVIEW GTK_TREE_VIEW */

    /* BEGIN OF PLAYLIST GTK_TREE_VIEW */
    p_intf->p_sys->p_tvplaylist = NULL;
    p_intf->p_sys->p_tvplaylist = (GtkTreeView *) lookup_widget( p_intf->p_sys->p_window, "tvPlaylist");
    if (NULL == p_intf->p_sys->p_tvplaylist)
       msg_Err(p_intf, "Error obtaining pointer to Play List");

    /* Columns 1 */
    p_renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvplaylist, 0, (gchar *) N_("Filename"), p_renderer, NULL);
    p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvplaylist, 0 );
    gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 0 );
    gtk_tree_view_column_set_sort_column_id(p_column, 0);
    /* Column 2 */
    p_renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvplaylist, 1, (gchar *) N_("Time"), p_renderer, NULL);
    p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvplaylist, 1 );
    gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 1 );
    gtk_tree_view_column_set_sort_column_id(p_column, 1);
#if 0
    /* Column 3 - is a hidden column used for reliable deleting items from the underlying playlist */
    p_renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvplaylist, 2, (gchar *) N_("Index"), p_renderer, NULL);
    p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvplaylist, 2 );
    gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 2 );
    gtk_tree_view_column_set_sort_column_id(p_column, 2);
#endif
    /* update the playlist */
    p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
    p_playlist_store = gtk_list_store_new (3,
                G_TYPE_STRING, /* Filename */
                G_TYPE_STRING, /* Time */
                G_TYPE_UINT);  /* Hidden index */
    PlaylistRebuildListStore(p_playlist_store, p_playlist);
    gtk_tree_view_set_model(GTK_TREE_VIEW(p_intf->p_sys->p_tvplaylist), GTK_TREE_MODEL(p_playlist_store));
    g_object_unref(p_playlist_store);
    vlc_object_release(p_playlist); /* Free the playlist */
    gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(p_intf->p_sys->p_tvplaylist)),GTK_SELECTION_MULTIPLE);

    /* Column properties */
    gtk_tree_view_set_headers_visible(p_intf->p_sys->p_tvplaylist, TRUE);
    gtk_tree_view_columns_autosize(p_intf->p_sys->p_tvplaylist);
    gtk_tree_view_set_headers_clickable(p_intf->p_sys->p_tvplaylist, TRUE);
    /* END OF PLAYLIST GTK_TREE_VIEW */

    /* Hide the Preference TAB for now. */
    GtkWidget *p_preference_tab = NULL;
    p_preference_tab = gtk_notebook_get_nth_page(p_intf->p_sys->p_notebook,5);
    if (p_preference_tab != NULL)
      gtk_widget_hide(p_preference_tab);

    /* Show the control window */
    gtk_widget_show( p_intf->p_sys->p_window );

#ifdef NEED_GTK2_MAIN
    msg_Dbg( p_intf, "Manage GTK keyboard events using threads" );
    while( !p_intf->b_die )
    {
        Manage( p_intf );

        /* Sleep to avoid using all CPU - since some interfaces need to
         * access keyboard events, a 100ms delay is a good compromise */
        gdk_threads_leave();
        if (p_intf->p_libvlc->i_cpu & CPU_CAPABILITY_FPU)
            msleep( INTF_IDLE_SLEEP );
        else
            msleep( 1000 );
        gdk_threads_enter();
    }
#else
    msg_Dbg( p_intf, "Manage GTK keyboard events using timeouts" );
    /* Sleep to avoid using all CPU - since some interfaces needs to access
     * keyboard events, a 1000ms delay is a good compromise */
    if (p_intf->p_libvlc->i_cpu & CPU_CAPABILITY_FPU)
        i_dummy = gtk_timeout_add( INTF_IDLE_SLEEP / 1000, (GtkFunction)Manage, p_intf );
    else
        i_dummy = gtk_timeout_add( 1000, (GtkFunction)Manage, p_intf );

    /* Enter Gtk mode */
    gtk_main();
    /* Remove the timeout */
    gtk_timeout_remove( i_dummy );
#endif

    gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_window) );
#ifdef NEED_GTK2_MAIN
    gdk_threads_leave();
#endif
}