/* * * ProLinga-Run * * Copyright (C) 2002-2008 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 #include #include #include //#include #include "RunShare.hpp" #include "RepositoryCommand.hpp" #include "DataRef.hpp" #include "Screen.hpp" /* Variable (V-) */ //extern VariablePtr varPtr; /* VariableGroupPtr (G-) */ //extern VariableGroupPtr vgrpPtr; void ColorReset(GtkWidget *wdg) { /* Reset base */ gtk_widget_modify_base(wdg, GTK_STATE_NORMAL, NULL); gtk_widget_modify_base(wdg, GTK_STATE_ACTIVE, NULL); gtk_widget_modify_base(wdg, GTK_STATE_PRELIGHT, NULL); gtk_widget_modify_base(wdg, GTK_STATE_SELECTED, NULL); gtk_widget_modify_base(wdg, GTK_STATE_INSENSITIVE, NULL); /* Reset bg */ gtk_widget_modify_bg(wdg, GTK_STATE_NORMAL, NULL); gtk_widget_modify_bg(wdg, GTK_STATE_ACTIVE, NULL); gtk_widget_modify_bg(wdg, GTK_STATE_PRELIGHT, NULL); gtk_widget_modify_bg(wdg, GTK_STATE_SELECTED, NULL); gtk_widget_modify_bg(wdg, GTK_STATE_INSENSITIVE, NULL); /* Reset fg */ gtk_widget_modify_fg(wdg, GTK_STATE_NORMAL, NULL); gtk_widget_modify_fg(wdg, GTK_STATE_ACTIVE, NULL); gtk_widget_modify_fg(wdg, GTK_STATE_PRELIGHT, NULL); gtk_widget_modify_fg(wdg, GTK_STATE_SELECTED, NULL); gtk_widget_modify_fg(wdg, GTK_STATE_INSENSITIVE, NULL); /* Reset text */ gtk_widget_modify_text(wdg, GTK_STATE_NORMAL, NULL); gtk_widget_modify_text(wdg, GTK_STATE_ACTIVE, NULL); gtk_widget_modify_text(wdg, GTK_STATE_PRELIGHT, NULL); gtk_widget_modify_text(wdg, GTK_STATE_SELECTED, NULL); gtk_widget_modify_text(wdg, GTK_STATE_INSENSITIVE, NULL); /* Show widget */ gtk_widget_show(wdg); } void ColorRefresh(GtkWidget *wdg, const char *target, const char *color, const char *state) { GdkColor parseColor; char *wdgState; if (state == NULL) wdgState = "Normal"; else wdgState = (char *)state; /* Get color */ gdk_color_parse(color, &parseColor); /* Determine target */ if (strcmp(target, "BASECOLOR") == 0) { if (strcmp(wdgState, "Normal") == 0) gtk_widget_modify_base(wdg, GTK_STATE_NORMAL, &parseColor); else if (strcmp(wdgState, "Active") == 0) gtk_widget_modify_base(wdg, GTK_STATE_ACTIVE, &parseColor); else if (strcmp(wdgState, "Prelight") == 0) gtk_widget_modify_base(wdg, GTK_STATE_PRELIGHT, &parseColor); else if (strcmp(wdgState, "Selected") == 0) gtk_widget_modify_base(wdg, GTK_STATE_SELECTED, &parseColor); else if (strcmp(wdgState, "Insensitive") == 0) gtk_widget_modify_base(wdg, GTK_STATE_INSENSITIVE, &parseColor); } else if (strcmp(target, "BGCOLOR") == 0) { if (strcmp(wdgState, "Normal") == 0) gtk_widget_modify_bg(wdg, GTK_STATE_NORMAL, &parseColor); else if (strcmp(wdgState, "Active") == 0) gtk_widget_modify_bg(wdg, GTK_STATE_ACTIVE, &parseColor); else if (strcmp(wdgState, "Prelight") == 0) gtk_widget_modify_bg(wdg, GTK_STATE_PRELIGHT, &parseColor); else if (strcmp(wdgState, "Selected") == 0) gtk_widget_modify_bg(wdg, GTK_STATE_SELECTED, &parseColor); else if (strcmp(wdgState, "Insensitive") == 0) gtk_widget_modify_bg(wdg, GTK_STATE_INSENSITIVE, &parseColor); } else if (strcmp(target, "FGCOLOR") == 0) { if (strcmp(wdgState, "Normal") == 0) gtk_widget_modify_fg(wdg, GTK_STATE_NORMAL, &parseColor); else if (strcmp(wdgState, "Active") == 0) gtk_widget_modify_fg(wdg, GTK_STATE_ACTIVE, &parseColor); else if (strcmp(wdgState, "Prelight") == 0) gtk_widget_modify_fg(wdg, GTK_STATE_PRELIGHT, &parseColor); else if (strcmp(wdgState, "Selected") == 0) gtk_widget_modify_fg(wdg, GTK_STATE_SELECTED, &parseColor); else if (strcmp(wdgState, "Insensitive") == 0) gtk_widget_modify_fg(wdg, GTK_STATE_INSENSITIVE, &parseColor); } else if (strcmp(target, "TEXTCOLOR") == 0) { if (strcmp(wdgState, "Normal") == 0) gtk_widget_modify_text(wdg, GTK_STATE_NORMAL, &parseColor); else if (strcmp(wdgState, "Active") == 0) gtk_widget_modify_text(wdg, GTK_STATE_ACTIVE, &parseColor); else if (strcmp(wdgState, "Prelight") == 0) gtk_widget_modify_text(wdg, GTK_STATE_PRELIGHT, &parseColor); else if (strcmp(wdgState, "Selected") == 0) gtk_widget_modify_text(wdg, GTK_STATE_SELECTED, &parseColor); else if (strcmp(wdgState, "Insensitive") == 0) gtk_widget_modify_text(wdg, GTK_STATE_INSENSITIVE, &parseColor); } else { /* Just ignore */ return; } /* Show widget */ gtk_widget_show(wdg); } void ColorWidget(GtkWidget *wdg, const char *wdgName, const char *target, const char *color, const char *state, const bool isMainThread) { GtkWidget *curWdg; GList *wdgList; int i, lengthWdgList; /* get GTK thread lock */ if (isMainThread == false) gdk_threads_enter(); 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 (wdgName != NULL) { if (strcmp(wdgName, (char *)gtk_widget_get_name(curWdg)) == 0) { if (isMainThread == false) { /* Sync with X server */ gdk_flush(); /* release GTK thread lock */ gdk_threads_leave(); } ColorRefresh(curWdg, target, color, state); /* get GTK thread lock */ if (isMainThread == false) gdk_threads_enter(); } } else { if (isMainThread == false) { /* Sync with X server */ gdk_flush(); /* release GTK thread lock */ gdk_threads_leave(); } ColorRefresh(curWdg, target, color, state); /* get GTK thread lock */ if (isMainThread == false) gdk_threads_enter(); } if (GTK_IS_CONTAINER(curWdg)) { if (isMainThread == false) { /* Sync with X server */ gdk_flush(); /* release GTK thread lock */ gdk_threads_leave(); } ColorWidget(curWdg, wdgName, target, color, state, isMainThread); /* get GTK thread lock */ if (isMainThread == false) gdk_threads_enter(); } } if (isMainThread == false) { /* Sync with X server */ gdk_flush(); /* release GTK thread lock */ gdk_threads_leave(); } } void ColorWidgetReset(GtkWidget *wdg, const char *wdgName, const bool isMainThread) { GtkWidget *curWdg; GList *wdgList; int i, lengthWdgList; /* get GTK thread lock */ if (isMainThread == false) gdk_threads_enter(); 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 (wdgName != NULL) { if (strcmp(wdgName, (char *)gtk_widget_get_name(curWdg)) == 0) { if (isMainThread == false) { /* Sync with X server */ gdk_flush(); /* release GTK thread lock */ gdk_threads_leave(); } ColorReset(curWdg); /* get GTK thread lock */ if (isMainThread == false) gdk_threads_enter(); } } else { if (isMainThread == false) { /* Sync with X server */ gdk_flush(); /* release GTK thread lock */ gdk_threads_leave(); } ColorReset(curWdg); /* get GTK thread lock */ if (isMainThread == false) gdk_threads_enter(); } if (GTK_IS_CONTAINER(curWdg)) { if (isMainThread == false) { /* Sync with X server */ gdk_flush(); /* release GTK thread lock */ gdk_threads_leave(); } ColorWidgetReset(curWdg, wdgName, isMainThread); /* get GTK thread lock */ if (isMainThread == false) gdk_threads_enter(); } } if (isMainThread == false) { /* Sync with X server */ gdk_flush(); /* release GTK thread lock */ gdk_threads_leave(); } } void DisplayWidget(GtkWidget *wdg, const char *wdgName, const bool isMainThread) { GtkWidget *curWdg; GList *wdgList; int i, lengthWdgList; /* get GTK thread lock */ if (isMainThread == false) gdk_threads_enter(); 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 (wdgName != NULL) { if (strcmp(wdgName, (char *)gtk_widget_get_name(curWdg)) == 0) { if (isMainThread == false) { /* Sync with X server */ gdk_flush(); /* release GTK thread lock */ gdk_threads_leave(); } DisplayRefresh(GTK_OBJECT(curWdg)); /* get GTK thread lock */ if (isMainThread == false) gdk_threads_enter(); } } else { if (isMainThread == false) { /* Sync with X server */ gdk_flush(); /* release GTK thread lock */ gdk_threads_leave(); } DisplayRefresh(GTK_OBJECT(curWdg)); /* get GTK thread lock */ if (isMainThread == false) gdk_threads_enter(); } if (GTK_IS_CONTAINER(curWdg)) { if (isMainThread == false) { /* Sync with X server */ gdk_flush(); /* release GTK thread lock */ gdk_threads_leave(); } DisplayWidget(curWdg, wdgName, isMainThread); /* get GTK thread lock */ if (isMainThread == false) gdk_threads_enter(); } } if (isMainThread == false) { /* Sync with X server */ gdk_flush(); /* release GTK thread lock */ gdk_threads_leave(); } } /* Command : DISPLAY */ /* Syntax : DISPLAY widget_ref | ALL */ void CmdDisplay(char **argList, int argHits, bool isMainThread, GtkWidget *outputScreen) { int j; char wdgName[255], color[255]; /* Display All */ if (strcmp(argList[1], "ALL") == 0) DisplayWidget(outputScreen, NULL, isMainThread); else if (argHits == 1) /* Refresh certain fields only */ { for (j = 1; j <= argHits; j++) { /* Get widget name */ //getDataRef(argList[j], isMainThread, wdgName, false); DisplayWidget(outputScreen, argList[j], isMainThread); } } else /* Set Colors */ { /* 1=widget 2=target, 3=color, 5=state */ /* Get widget name */ getDataRef(argList[1], isMainThread, wdgName, false); if (strcmp(argList[2], "RESETCOLOR") == 0) ColorWidgetReset(outputScreen, wdgName, isMainThread); else { /* Get color name */ getDataRef(argList[3], isMainThread, color, false); /* Set Color */ if (argHits == 5) ColorWidget(outputScreen, wdgName, argList[2], color, argList[5], isMainThread); else ColorWidget(outputScreen, wdgName, argList[2], color, NULL, isMainThread); } } }