/* * * ProLinga-UI * * Copyright (C) 2002-2008 Xobas Software. * All rights reserved. * * This file is part of ProLinga-UI. * * ProLinga-UI 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-UI 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-UI. If not, see . * * More information is available at the following addresses: * * Website : http://www.prolinga.org * * Email : prolinga-list@prolinga.org * * */ #include "UICommon.h" #include #include #include #include #include "UIShare.hpp" GtkWidget* LookupWidget(GtkWidget *widget, const gchar *widget_name) { GladeXML *xml; GList *wdgList; GtkWidget *wdgt; xml = glade_get_widget_tree(widget); wdgt = glade_xml_get_widget(xml, widget_name); wdgList = glade_xml_get_widget_prefix(xml, ""); /* if (strcmp((char *)widget_name, "External") == 0) { lengthWdgList = g_list_length(wdgList); for (i = 1; i < lengthWdgList; i++) { tmpWdg = GTK_WIDGET(g_list_nth_data(wdgList, i)); printf("WIDGET : %s NAME : %s\n", G_OBJECT_TYPE_NAME(G_OBJECT(tmpWdg)), gtk_widget_get_name(tmpWdg)); } } */ if(wdgt == NULL) g_warning ("Widget not found: %s", widget_name); /* Return */ return wdgt; } DesktopScreen::DesktopScreen() { screenName = NULL; screenWidget = NULL; nextPtr = NULL; } DesktopScreen::~DesktopScreen() { /* Clean up */ if (screenName != NULL) delete screenName; } GtkWidget *DesktopScreen::getOneValue(DesktopScreenPtr *dtsPtr, const char *name) { DesktopScreenPtr curPtr; curPtr = *dtsPtr; while (curPtr != NULL) { if (strcmp(curPtr->screenName, name) == 0) return curPtr->screenWidget; curPtr= curPtr->nextPtr; } return NULL; } void DesktopScreen::putValue(DesktopScreenPtr *dtsPtr, const char *name, const GtkWidget *wdgScreen) { DesktopScreenPtr newPtr; /* Prepend value to list. Double allowed (multiple modeless) */ newPtr = new DesktopScreen; newPtr->screenName = new char[(strlen(name)+1)]; strcpy(newPtr->screenName, name); newPtr->screenWidget = GTK_WIDGET(wdgScreen); newPtr->nextPtr = *dtsPtr; *dtsPtr = newPtr; } void DesktopScreen::deleteValue(DesktopScreenPtr *dtsPtr, const char *name, const GtkWidget *wdgScreen) { DesktopScreenPtr curPtr, prevPtr; curPtr = *dtsPtr; prevPtr = NULL; while (curPtr != NULL) { if ((strcmp(curPtr->screenName, name) == 0) && (GTK_WIDGET(curPtr->screenWidget) == GTK_WIDGET(wdgScreen))) { if (prevPtr == NULL) { /* First Record */ *dtsPtr = curPtr->nextPtr; break; } else { prevPtr->nextPtr = curPtr->nextPtr; break; } delete curPtr; } prevPtr = curPtr; curPtr = curPtr->nextPtr; } } GtkWidget *DesktopScreen::getFirstValue(DesktopScreenPtr *dtsPtr) { if (*dtsPtr != NULL) return (*dtsPtr)->screenWidget; else return NULL; } int DesktopScreen::isOnDesktop(DesktopScreenPtr dtsPtr, const char *name) { DesktopScreenPtr curPtr; int hits = 0; /* Check if and how many times screen name exits in mem list */ curPtr = dtsPtr; while (curPtr != NULL) { if (strcmp(curPtr->screenName, name) == 0) hits++; curPtr= curPtr->nextPtr; } return hits; } int DesktopScreen::numberOnDesktop(DesktopScreenPtr dtsPtr) { DesktopScreenPtr curPtr; int hits = 0; curPtr = dtsPtr; while (curPtr != NULL) { hits++; curPtr= curPtr->nextPtr; } return hits; } void DesktopScreen::printList(DesktopScreenPtr dtsPtr) const { DesktopScreenPtr curPtr; curPtr = dtsPtr; while (curPtr != NULL) { printf("Screen Name %s\n", curPtr->screenName); curPtr = curPtr->nextPtr; } }