/* * * ProLinga-Run * * Copyright (C) 2002-2009 Xobas Software. * All rights reserved. * * This file is part of ProLinga-Run. * * ProLinga-Run 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 3 of the License, or * (at your option) any later version. * * ProLinga-Run 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 ProLinga-Run. If not, see . * * More information is available at the following addresses: * * Website : http://www.prolinga.org * * Email : prolinga-list@prolinga.org * * */ #include "RunCommon.h" #include GtkWidget *LocateWidget(GtkWidget *wdg, const char *wdgName) { GtkWidget *curWdg, *locWdg = NULL; GList *wdgList; int i, lengthWdgList; /* Get pointer to widget */ wdgList = gtk_container_get_children(GTK_CONTAINER(wdg)); lengthWdgList = g_list_length(wdgList); for (i = 0; i < lengthWdgList; i++) { curWdg = GTK_WIDGET(g_list_nth_data(wdgList, i)); // printf("WIDGET : %s NAME : %s\n", G_OBJECT_TYPE_NAME(G_OBJECT(curWdg)), gtk_widget_get_name(curWdg)); if (strcmp(wdgName, (char *)gtk_widget_get_name(curWdg)) == 0) return curWdg; if (GTK_IS_CONTAINER(curWdg)) { locWdg = LocateWidget(curWdg, wdgName); if (locWdg != NULL) return locWdg; } } /* Return */ return locWdg; } /* Command : FOCUS */ /* Syntax : FOCUS screen_widget_name */ void CmdFocus(const char **argList, int argHits, bool isMainThread, GtkWidget *outputScreen) { GtkWidget *curWdg = NULL; /* get GTK thread lock */ if (isMainThread == false) gdk_threads_enter(); /* Set Focus on Widget */ curWdg = LocateWidget(outputScreen, argList[1]); if (isMainThread == false) { /* Sync with X server */ gdk_flush(); /* release GTK thread lock */ gdk_threads_leave(); } /* If no widget found, return */ if (curWdg == NULL) return; /* get GTK thread lock */ if (isMainThread == false) gdk_threads_enter(); /* Set focus */ gtk_widget_grab_focus(curWdg); if (isMainThread == false) { /* Sync with X server */ gdk_flush(); /* release GTK thread lock */ gdk_threads_leave(); } }