static BOOL CALLBACK config_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) { char name[MAX_PATH+1]; int n; const char *s; (void)lparam; switch (msg) { case WM_INITDIALOG: center_window (dlg, 0); s = get_log_file (); SetDlgItemText (dlg, IDC_DEBUG_LOGFILE, s? s:""); config_dlg_set_labels (dlg); break; case WM_COMMAND: switch (LOWORD (wparam)) { case IDOK: n = GetDlgItemText (dlg, IDC_DEBUG_LOGFILE, name, MAX_PATH-1); set_log_file (n>0?name:NULL); EndDialog (dlg, TRUE); break; } break; } return FALSE; }
/*! \brief Locate the marker specified by the given direction * * - -3 means first marker * - -1 means previous marker * \param direction - 0 means current marker * - 1 means next marker * - 3 means last marker * \param current - Number of markers currently defined */ int find_marker (int direction, int *current) { // No markers; nothing to do, so return 'not found' if (num_markers < 1) { return 0; } /* Which marker to move to */ if (direction == -3) { /* First marker */ *current = 0; } else if (direction == -1) { /* Previous Marker */ if (--*current < 0) { *current = num_markers - 1; } } else if (direction == 0) { /* Center map on current Marker */ center_window (gmap.markers[*current].x, gmap.markers[*current].y); } else if (direction == 1) { /* Next Marker */ if (++*current >= num_markers) { *current = 0; } } else if (direction == 3) { /* Last Marker */ *current = num_markers - 1; } return 1; }
static void starlog_open_window(Starlog *s) { if(IsWindowVisible(s->hwnd)) { return; } center_window(s->hwnd); ShowWindow(s->hwnd, SW_SHOW); SetForegroundWindow(s->hwnd); SetFocus(s->edit_log); }
void but_loadNeutrino(gpointer callback_data, guint callback_action, GtkWidget *widget){ GtkWidget *file_selector = gtk_file_selection_new(_("select a Neutrino Channellist.")); gtk_file_selection_hide_fileop_buttons (GTK_FILE_SELECTION(file_selector)); g_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->ok_button), "clicked", G_CALLBACK (load_file),(gpointer) file_selector); g_signal_connect_swapped (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->ok_button), "clicked", G_CALLBACK (gtk_widget_destroy), (gpointer) file_selector); g_signal_connect_swapped (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->cancel_button), "clicked", G_CALLBACK (gtk_widget_destroy), (gpointer) file_selector); center_window(GTK_WINDOW(file_selector)); gtk_widget_show (file_selector); gtk_file_selection_complete(GTK_FILE_SELECTION(file_selector),"*.xml"); }
void popup_preferences_dialog(Widget parent, int arg) { static Widget preferences_shell = 0; static struct topic_info info; static struct topic_item items[NUM_PREFS_TOPICS]; static struct prefs_choice *prefs = NULL; if (preferences_shell == 0) { /* called 1st time; create widget */ info.ok_callback = apply_prefs_cb; info.cancel_callback = revert_prefs_cb; info.items = items; /* info.items_size = NUM_PREFS_TOPICS; */ prefs = xmalloc(sizeof *prefs); prefs->depwin_cnt = 0; prefs->depwin = NULL; /* prefs->orig = orig_prefs; */ /* apply_prefs_cb/revert_prefs_cb are responsible for copying the changed preferences into the current preferences as appropriate, and free()ing prefs.changed */ /* prefs->changed = xmalloc(sizeof *(prefs->changed)); */ /* copy_resources(orig_prefs, prefs->changed); */ prefs->db = NULL; /* XrmGetStringDatabase(""); */ info.data = prefs; preferences_shell = create_topic_window(parent, "xdvik: Preferences", Xdvi_PREFS_DIALOG_NAME, &info, initialize_items, "OK", "Cancel"); info.shell = preferences_shell; center_window(preferences_shell, parent); select_topic(&info, 0); } if (arg >= 0) select_topic(&info, arg); XtPopup(preferences_shell, XtGrabNone); if (resource.no_init_file) { popup_message(preferences_shell, MSG_WARN, NULL, "You specified the resource `noInitFile' or the `-q' command-line option. " "Any preferences that you set in this dialog will be lost when you exit xdvi."); } }
void saveNeutrino(gint bouquet){ GtkWidget *file_selector; if (bouquet){ save_all_bouquets(); // alle Bouquets speichern. return; } file_selector = gtk_file_selection_new(_("save a Neutrino Channellist.")); gtk_file_selection_hide_fileop_buttons (GTK_FILE_SELECTION(file_selector)); g_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->ok_button), "clicked", G_CALLBACK (save_akt_bouquet),(gpointer) file_selector); g_signal_connect_swapped (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->ok_button), "clicked", G_CALLBACK (gtk_widget_destroy), (gpointer) file_selector); g_signal_connect_swapped (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->cancel_button), "clicked", G_CALLBACK (gtk_widget_destroy), (gpointer) file_selector); center_window(GTK_WINDOW(file_selector)); gtk_widget_show (file_selector); gtk_file_selection_complete(GTK_FILE_SELECTION(file_selector),"*.xml"); }
void save_all_bouquets(){ FILE *stream; GNode *node_bouquet; GNode *node_channel; bouquetEntry *bouquet; channelEntry *channel; gchar txtBuffer[100]; if (!(stream = fopen(get_path (ZAPIT_BOUQ_NEW), "wb"))){ GtkWidget* dialog; dialog = gtk_message_dialog_new (NULL,0, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, txtIn(_("could not create bouquets-file"))); center_window(GTK_WINDOW(dialog)); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); return; } fputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",stream); fputs("<zapit>\n",stream); node_bouquet = g_node_first_child(MW_GET("RIGHT_NODE_ROOT")); while (node_bouquet){ bouquet = node_bouquet->data; node_channel = g_node_first_child (node_bouquet); if (node_channel) { // Bouquet enthält Sender. sprintf(txtBuffer,"\t<Bouquet name=\"%s\" hidden=\"%d\" locked=\"%d\">\n", ascToXML(bouquet->bouquetName), bouquet->hidden, bouquet->locked); fputs(txtBuffer,stream); while (node_channel){ channel = (channelEntry *) node_channel->data; sprintf(txtBuffer,"\t\t<channel serviceID=\"%.4x\" name=\"%s\" onid=\"%.4x\"/>\n", channel->serviceID, ascToXML(channel->channelName), channel->onid); fputs(txtBuffer,stream); node_channel = node_channel ->next; } fputs("\t</Bouquet>\n",stream); } node_bouquet = node_bouquet->next; } fputs("</zapit>\n",stream); fclose(stream); }
//////////////////////////////////////////////////////////////////////////////// // save the actual Bouquet. //////////////////////////////////////////////////////////////////////////////// void save_akt_bouquet(GtkFileSelection *selector, gpointer file_selector) { FILE *stream; gchar *filename; gchar txtBuffer[200]; bouquetEntry *bouquet; channelEntry *channel; GNode *node_bouquet, *node_channel; filename = (gchar*) gtk_file_selection_get_filename(GTK_FILE_SELECTION(file_selector)); if (!(stream = fopen(filename, "wb"))){ GtkWidget* dialog; sprintf(txtBuffer,_("Could not read: '%s' \n"),filename); dialog = gtk_message_dialog_new (NULL,0, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,txtIn(txtBuffer)); center_window(GTK_WINDOW(dialog)); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); return; } fputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",stream); fputs("<zapit>\n",stream); node_bouquet = MW_GET("AKT_BOUQUET"); bouquet = node_bouquet->data; node_channel = g_node_first_child (node_bouquet); if (node_channel){ // Bouquet enthält Sender. sprintf(txtBuffer,"\t<Bouquet name=\"%s\" hidden=\"%d\" locked=\"%d\">\n", ascToXML(bouquet->bouquetName), bouquet->hidden, bouquet->locked); fputs(txtBuffer,stream); while (node_channel){ channel = node_channel->data; ascToXML(channel->channelName); sprintf(txtBuffer,"\t\t<channel serviceID=\"%.4x\" name=\"%s\" onid=\"%.4x\"/>\n", channel->serviceID, ascToXML(channel->channelName), channel->onid); fputs(txtBuffer,stream); node_channel = node_channel ->next; } fputs("\t</Bouquet>\n",stream); } fputs("</zapit>\n",stream); fclose(stream); }
/*! \brief Locate the bounded area specified by the given direction * * - -3 means first box * - -1 means previous box * \param direction - 0 means current box * - 1 means next box * - 3 means last box * \param current - Number of bounded areas currently defined */ int find_bound (int direction, int *current) { // No bounding areas; nothing to do, so return 'not found' if (num_bound_boxes < 1) { return 0; } /* Which bounding box to move to */ if (direction == -3) { /* First box */ *current = 0; } else if (direction == -1) { /* Previous box */ if (--*current < 0) { *current = num_bound_boxes - 1; } } else if (direction == 0) { /* Center map on current Box, if it's not too big */ int x, y; x = (bound_box[*current].x2 - bound_box[*current].x1) / 2 + bound_box[*current].x1; y = (bound_box[*current].y2 - bound_box[*current].y1) / 2 + bound_box[*current].y1 + 1; center_window (x, y); } else if (direction == 1) { /* Next Box */ if (++*current >= num_bound_boxes) { *current = 0; } } else if (direction == 3) { /* Last Box */ *current = num_bound_boxes - 1; } return 1; }
/* * Popup a window with wrapped text in it. * For Motif, the text is explicitly wrapped inside this method. */ static Widget internal_popup_window(Widget parent, popupMessageSizeHintT size, popupMessageT type, int x_coord, int y_coord, const char *helptext, char *msg_buf, #ifndef MOTIF const char *xaw_ret_action_str, #endif pre_message_cbT pre_cb, XtPointer arg, const char *yes_button, message_cbT yes_cb, XtPointer yes_arg, const char *no_button, message_cbT no_cb, XtPointer no_arg, const char *cancel_button, message_cbT cancel_cb, XtPointer cancel_arg) { int my_popup_num = 0; #ifdef MOTIF XmString str; #endif Widget ret; ASSERT(type < (sizeof my_msg_map / sizeof my_msg_map[0]), "too few elements in my_msg_map"); #if DEBUG fprintf(stderr, "internal_popup_window called with prompt: \"%s\"\n", msg_buf); #endif if (globals.widgets.top_level == 0) { /* If toplevel window hasn't been created yet, dump messages to STDERR and return. */ fprintf(stderr, "\n%s:\n%s\n", my_msg_map[type].window_title, msg_buf); if (helptext) { fputs("---------- helptext ----------\n", stderr); fputs(helptext, stderr); fputs("\n---------- end of helptext ----------\n", stderr); } return NULL; } /* search for first free position in g_popup_array */ while (my_popup_num < MAX_POPUPS && (g_popup_array[my_popup_num] == 1)) { my_popup_num++; } if (my_popup_num == MAX_POPUPS) { /* already enough popups on screen, just dump it to stderr */ fprintf(stderr, "%s: %s\n", my_msg_map[type].window_title, msg_buf); /* Note: If a mad function continues to open popups, this will * stop after MAX_POPUPS, but open a new window for each * window the user pops down. Maybe we ought to do something * about this. */ return NULL; } else { /* mark it as non-free */ g_popup_array[my_popup_num] = 1; } #if DEBUG fprintf(stderr, "first free position in g_popup_array: %d\n", my_popup_num); #endif /* just to make sure ... */ if (parent == NULL) parent = globals.widgets.top_level; /* create a new set of widgets for the additional popup. */ ret = create_dialogs(size, parent, my_popup_num, helptext, pre_cb, arg, yes_button, yes_cb, yes_arg, no_button, no_cb, no_arg, cancel_button, cancel_cb, cancel_arg); #ifdef MOTIF XtVaSetValues(popup_window[my_popup_num], XmNtitle, my_msg_map[type].window_title, NULL); XtVaSetValues(dialog[my_popup_num], XmNdialogType, my_msg_map[type].motif_msg_type, NULL); { /* wrap message at space before MSG_WRAP_LEN */ char *testwrap = msg_buf; int ctr; for (ctr = 0; *testwrap++; ctr++) { if (*testwrap == '\n') { ctr = 0; } else if (ctr > MSG_WRAP_LEN) { size_t before_len = 0, after_len = 0; char *before_ptr, *after_ptr; before_ptr = after_ptr = testwrap; /* try to find shortest sequence before or after point to wrap at; this seems to give the most pleasing results. */ while (before_ptr > msg_buf && !isspace((int)*--before_ptr)) { before_len++; } while (*after_ptr != '\0' && !isspace((int)*++after_ptr)) { after_len++; } if (before_len < after_len && isspace((int)*before_ptr)) { /* use last in sequence of multiple spaces */ while (isspace((int)*++before_ptr)) { ; } /* back up, and wrap */ *--before_ptr = '\n'; ctr = 0; } else if (isspace((int)*after_ptr)) { /* use last in sequence of multiple spaces */ while (isspace((int)*++after_ptr)) { ; } /* back up, and wrap */ *--after_ptr = '\n'; ctr = 0; } } } } str = XmStringCreateLtoR((char *)msg_buf, G_charset); XtVaSetValues(dialog[my_popup_num], XmNmessageString, str, XmNtraversalOn, True, XmNhighlightOnEnter, True, NULL); XmStringFree(str); XtManageChild(dialog[my_popup_num]); if (x_coord > 0 && y_coord > 0) { position_window(XtParent(dialog[my_popup_num]), (Position)x_coord, (Position)y_coord); } XtPopup(XtParent(dialog[my_popup_num]), XtGrabNone); /* XtPopup(XtParent(dialog[my_popup_num]), XtGrabExclusive); */ #else /* MOTIF */ /* add a binding of xaw_ret_action_str to <Return> to relevant widgets. The callbacks (xaw_ret_action_str) are responsible for parsing the passed arguments (pointers, or empty arguments). */ if (xaw_ret_action_str != NULL) { XtTranslations xlats; char *translation_str; if (yes_arg != NULL) translation_str = get_string_va("<Key>Return:close-popup(%d)%s(%p)", my_popup_num, xaw_ret_action_str, yes_arg); else translation_str = get_string_va("<Key>Return:close-popup(%d)%s()", my_popup_num, xaw_ret_action_str); xlats = XtParseTranslationTable(translation_str); free(translation_str); XtOverrideTranslations(popup_window[my_popup_num], xlats); XtOverrideTranslations(message_paned[my_popup_num], xlats); XtOverrideTranslations(message_text[my_popup_num], xlats); } XtVaSetValues(popup_window[my_popup_num], XtNtitle, my_msg_map[type].window_title, NULL); XtVaSetValues(message_text[my_popup_num], XtNstring, msg_buf, NULL); XtRealizeWidget(popup_window[my_popup_num]); XSetWMProtocols(XtDisplay(popup_window[my_popup_num]), XtWindow(popup_window[my_popup_num]), &WM_DELETE_WINDOW, 1); if (x_coord <= 0 || y_coord <= 0) center_window(popup_window[my_popup_num], parent); else position_window(popup_window[my_popup_num], (Position)x_coord, (Position)y_coord); if (my_popup_num > 0) { /* some window managers position new windows exactly above the existing one; to prevent this, move it with some offset from the previous one: */ Position x = 0, y = 0; XtVaGetValues(popup_window[my_popup_num-1], XtNx, &x, XtNy, &y, NULL); XtVaSetValues(popup_window[my_popup_num], XtNx, x + POPUP_OFFSET, XtNy, y + POPUP_OFFSET, NULL); } XtPopup(popup_window[my_popup_num], XtGrabNone); /* XtPopup(XtParent(popup_window[my_popup_num]), XtGrabExclusive); */ if (XtIsManaged(message_not_ok[my_popup_num]) && XtIsManaged(message_help[my_popup_num])) { /* center the help button. This is something of a sham, since it won't survive resizing; but in general most users won't resize dialogs ;-) */ Position x1, x2, bw; int w, dist; XtVaGetValues(message_ok[my_popup_num], XtNx, &x1, XtNwidth, &w, XtNborderWidth, &bw, NULL); XtVaGetValues(message_help[my_popup_num], XtNx, &x2, NULL); /* following formula is measured, not calculated - I have no idea why it's e.g. 2 * w, not 1.5 * w ... */ dist = (x2 - x1 - 2 * w) / 2 - 2 * bw; XtVaSetValues(message_not_ok[my_popup_num], XtNhorizDistance, dist, NULL); } #endif /* MOTIF */ return ret; }
/* Dialog processing loop. */ static BOOL CALLBACK dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) { static pinentry_t pe; static int item; /* { */ /* int idx; */ /* for (idx=0; msgcodes[idx].string; idx++) */ /* if (msg == msgcodes[idx].msg) */ /* break; */ /* if (msgcodes[idx].string) */ /* fprintf (debugfp, "received %s\n", msgcodes[idx].string); */ /* else */ /* fprintf (debugfp, "received WM_%u\n", msg); */ /* } */ switch (msg) { case WM_INITDIALOG: dialog_handle = dlg; pe = (pinentry_t)lparam; if (!pe) abort (); set_dlg_item_text (dlg, IDC_PINENT_PROMPT, pe->prompt); set_dlg_item_text (dlg, IDC_PINENT_DESC, pe->description); set_dlg_item_text (dlg, IDC_PINENT_TEXT, ""); if (pe->ok) { set_dlg_item_text (dlg, IDOK, pe->ok); resize_button (GetDlgItem (dlg, IDOK), pe->ok); } if (pe->cancel) { set_dlg_item_text (dlg, IDCANCEL, pe->cancel); resize_button (GetDlgItem (dlg, IDCANCEL), pe->cancel); } if (pe->error) set_dlg_item_text (dlg, IDC_PINENT_ERR, pe->error); if (confirm_mode) { EnableWindow (GetDlgItem (dlg, IDC_PINENT_TEXT), FALSE); SetWindowPos (GetDlgItem (dlg, IDC_PINENT_TEXT), NULL, 0, 0, 0, 0, (SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_HIDEWINDOW)); item = IDOK; } else item = IDC_PINENT_TEXT; center_window (dlg, HWND_TOP); /* Unfortunately we can't use SetForegroundWindow because there is no easy eay to have all the calling processes do an AllowSetForegroundWindow. What we do instead is to bad hack by simulating a click to the Window. */ /* if (SetForegroundWindow (dlg) && lock_set_foreground_window) */ /* { */ /* lock_set_foreground_window (LSFW_LOCK); */ /* } */ /* show_window_hierarchy (GetDesktopWindow (), 0); */ ShowWindow (dlg, SW_SHOW); move_mouse_and_click ( GetDlgItem (dlg, IDC_PINENT_PROMPT) ); raise_sip (dlg); break; case WM_COMMAND: switch (LOWORD (wparam)) { case IDOK: if (confirm_mode) confirm_yes = 1; else ok_button_clicked (dlg, pe); EndDialog (dlg, TRUE); break; case IDCANCEL: pe->result = -1; EndDialog (dlg, FALSE); break; } break; case WM_KEYDOWN: if (wparam == VK_RETURN) { if (confirm_mode) confirm_yes = 1; else ok_button_clicked (dlg, pe); EndDialog (dlg, TRUE); } break; } return FALSE; }
void load_file(GtkFileSelection *selector, gpointer file_selector) { FILE *stream; gchar *pfad; gchar *filename; gchar txtBuffer[200]; gchar bouquetName[MAX_TXT_LEN+1]; bouquetEntry *bouquet; channelEntry *channel; GNode *node_root; GNode *node_bouquet; GNode *node_channel; gint sumBouquets = 0; gint diseqc, transportID, frequenz, symbolRate, fec, polarity, onid, serviceID, serviceType; gchar name[MAX_TXT_LEN+1]; //****************************** // load bouquets file & fill GNode. //****************************** filename = (gchar*) gtk_file_selection_get_filename(GTK_FILE_SELECTION(file_selector)); if (!(stream = fopen(filename, "rb"))){ GtkWidget* dialog; sprintf(txtBuffer,_("Could not read: '%s' \n"),filename); dialog = gtk_message_dialog_new (NULL,0, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,txtIn(txtBuffer)); center_window(GTK_WINDOW(dialog)); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); return; } fgets(txtBuffer,BUFFER_SIZE,stream); // xml Version. fgets(txtBuffer,BUFFER_SIZE,stream); // ZAPIT - ID. if (!strFind(txtBuffer,"<ZAPIT>" )){ GtkWidget* dialog= gtk_message_dialog_new (NULL,0, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, txtIn(_("channel format unknown"))); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); fclose(stream); return; } GTK_LIST_STORE(MW_GET("LEFT_LIST_STORE"))->sort_column_id = -2; // switch off sorting. clear_left_listview(); fgets(txtBuffer,BUFFER_SIZE,stream); // Bouquet-Kennung. if (!strFind(txtBuffer,"<BOUQUET" )){ GtkWidget* dialog= gtk_message_dialog_new (NULL,0, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, txtIn(_("This is not a Bouquet File.\n" "Please select a bouquet-file like 'bouquets.xml'."))); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); fclose(stream); return; } // ***** OK, this seems to be a bouquets file. fseek(stream,0,0); fgets(txtBuffer,BUFFER_SIZE,stream); // xml Version. fgets(txtBuffer,BUFFER_SIZE,stream); // ZAPIT - ID. node_root = MW_GET("LEFT_NODE_ROOT"); while(1){ // read all Bouquets. fgets(txtBuffer,BUFFER_SIZE,stream); // Bouquet-Daten. if (strFind(txtBuffer,"</ZAPIT>" )) break; bouquet = malloc(sizeof(bouquetEntry)); sumBouquets++; node_bouquet = g_node_append(node_root, g_node_new(bouquet)); XMLtoAsc(bouquetName, extractData(txtBuffer,"name")); strcpy(bouquet->bouquetName,bouquetName); bouquet->hidden = atoi(extractData(txtBuffer,"hidden")); bouquet->locked = atoi(extractData(txtBuffer,"locked")); node_channel = g_node_last_child (node_bouquet); while(1){ // read all channels. fgets(txtBuffer,BUFFER_SIZE,stream); if (strFind(txtBuffer,"</BOUQUET>" )) break; channel = malloc(sizeof(channelEntry)); node_channel = g_node_append(node_bouquet, g_node_new(channel)); channel->serviceID= strtol(extractData(txtBuffer,"serviceID"),NULL,16); XMLtoAsc(channel->channelName, extractData(txtBuffer,"name")); channel->onid= strtol(extractData(txtBuffer,"onid"),NULL, 16); channel->frequency = 0; } } fclose(stream); // ****************************** // die services Datei einlesen und die Bouquets in verkette Liste mit diesen // Daten ergänzen. // ****************************** pfad=filename+strlen(filename); while(*pfad!='\\' && *pfad!='/') pfad--; *++pfad='\0'; strcpy(txtBuffer, filename); strcat(txtBuffer,ZAPIT_SERV_NAME); if (!(stream = fopen(txtBuffer, "rb"))){ GtkWidget* dialog; strcat(txtBuffer, _(" not found.")); dialog = gtk_message_dialog_new (NULL,0, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,txtIn(txtBuffer)); center_window(GTK_WINDOW(dialog)); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); clear_left_listview(); return; } fgets(txtBuffer,BUFFER_SIZE,stream); // xml Version. fgets(txtBuffer,BUFFER_SIZE,stream); // ZAPIT-Kennung. while (1){ // alle Satelliten einlesen. fgets(txtBuffer,BUFFER_SIZE,stream); // Sat / Kabel Daten. if (!strFind(txtBuffer,"<sat" ) && !strFind(txtBuffer,"<cable" )) break; diseqc = atoi(extractData(txtBuffer,"diseqc")); while (1){ // alle Transponder einlesen. fgets(txtBuffer,BUFFER_SIZE,stream); // Transponder if (strFind(txtBuffer,"</" )) break; transportID= strtol(extractData(txtBuffer,"transponder id"),NULL, 16); onid = strtol(extractData(txtBuffer,"onid"),NULL,16); frequenz= atoi(extractData(txtBuffer,"frequency")); symbolRate= atoi(extractData(txtBuffer,"symbol_rate")); fec= atoi(extractData(txtBuffer,"fec_inner")); polarity= atoi(extractData(txtBuffer,"polarization")); while(1){ // Alle Channels einlesen. gint test=0; fgets(txtBuffer,BUFFER_SIZE,stream); // Kanaldaten. if (strFind(txtBuffer,"</" )) break; serviceID = strtol(extractData(txtBuffer,"service_id"),NULL,16); XMLtoAsc(name, extractData(txtBuffer,"name")); serviceType = strtol(extractData(txtBuffer,"service_type"),NULL,16); // ****************************** // jeden einzelnen Sender in der Liste mit den neuen Daten ergänzen. // ****************************** node_bouquet = g_node_first_child(node_root); while (node_bouquet){ node_channel = g_node_first_child(node_bouquet); while (node_channel){ channel = node_channel->data; if ((serviceID == channel->serviceID) && (onid == channel->onid)) { // dieser Sender ist in den Bouquets. Also fehlende Daten ergänzen. channel->serviceType=serviceType; channel->diseqc=diseqc; channel->transportID=transportID; channel->frequency=frequenz; channel->symbolRate=symbolRate; channel->fec=fec; channel->polarisation=polarity; test++; } node_channel = node_channel->next; } node_bouquet=node_bouquet->next; } // ****************************** // Wenn der Sender aus den Services nicht in den Bouquets vorhanden war und die Liste // das komplette Bouquet enthält-> im Bouquet "*NEW*" eintragen. // ****************************** if (!test && sumBouquets > 1){ node_bouquet = g_node_last_child(node_root); bouquet = node_bouquet->data; if (strcmp(bouquet->bouquetName, "*NEW*")){ bouquet = malloc(sizeof(bouquetEntry)); node_bouquet = g_node_append(node_root, g_node_new(bouquet)); strcpy(bouquet->bouquetName,"*NEW*"); bouquet->hidden = FALSE; bouquet->locked = FALSE; sumBouquets++; } channel = malloc(sizeof(channelEntry)); g_node_append(node_bouquet, g_node_new(channel)); channel->serviceType=serviceType; channel->diseqc=diseqc; channel->transportID=transportID; channel->frequency=frequenz; channel->symbolRate=symbolRate; channel->fec=fec; channel->polarisation=polarity; XMLtoAsc(channel->channelName,name); channel->onid= onid; channel->serviceID= serviceID; } } } } fclose(stream); //****************************** // Die Bouquets überprüfen. Wenn kein Eintrag bei (z.B.) Frequez vorhanden ist, // war der Sender nicht in der services enthalten -> Daten sind nicht komplett! // -> löschen. Ebenso wenn Datendienste nicht eingelsen werden sollten. //****************************** node_bouquet = g_node_first_child(node_root); while (node_bouquet){ node_channel = g_node_first_child (node_bouquet); while (node_channel){ channel = node_channel->data; if ( (!channel->frequency) || ((!GTK_TOGGLE_BUTTON(MW_GET("OPT_READ_DATA"))->active) && (getServicePic(channel->serviceType) == DATA)) ) { // Sender war in der Bouquets-datei, aber nicht in der Services -> Sender löschen. node_channel = remove_node(node_channel); continue; } node_channel = node_channel ->next; } if (!g_node_first_child (node_bouquet)){ // bouquet now empty ? -> delete it. node_bouquet = remove_node(node_bouquet); sumBouquets--; continue; } node_bouquet = node_bouquet->next; } gtk_widget_grab_focus(GTK_WIDGET(MW_GET("OPT_READ_SHORT"))); // unfocus search entry. fill_left_listview(); }
//*********************************************************************** static void do_init_dialog(HWND hwnd) { char msgstr[81] ; // hwndTopLevel = hwnd ; // do I need this? wsprintfA(msgstr, "%s", Version) ; SetWindowTextA(hwnd, msgstr) ; SetClassLongA(hwnd, GCL_HICON, (LONG) LoadIcon(g_hinst, (LPCTSTR)WINWIZICO)); SetClassLongA(hwnd, GCL_HICONSM, (LONG) LoadIcon(g_hinst, (LPCTSTR)WINWIZICO)); hwndMain = hwnd ; set_up_working_spaces(hwnd) ; // do this *before* tooltips !! //*************************************************************************** // add tooltips and bitmaps //*************************************************************************** hToolTip = create_tooltips(hwnd, 150, 100, 10000) ; add_main_tooltips(hwnd, hToolTip) ; // RECT rWindow; // unsigned stTop ; RECT myRect ; // GetWindowRect(hwnd, &myRect) ; GetClientRect(hwnd, &myRect) ; cxClient = (myRect.right - myRect.left) ; cyClient = (myRect.bottom - myRect.top) ; center_window() ; //**************************************************************** // create/configure status bar //**************************************************************** MainStatusBar = new CStatusBar(hwnd) ; MainStatusBar->MoveToBottom(cxClient, cyClient) ; // re-position status-bar parts { int sbparts[3]; sbparts[0] = (int) (6 * cxClient / 10) ; sbparts[1] = (int) (8 * cxClient / 10) ; sbparts[2] = -1; MainStatusBar->SetParts(3, &sbparts[0]); } //**************************************************************** // create/configure terminal //**************************************************************** uint ctrl_bottom = get_bottom_line(hwnd, IDC_MAP_AREA) ; uint lvdy = cyClient - ctrl_bottom - MainStatusBar->height() ; myTerminal = new CTerminal(hwnd, IDC_TERMINAL, g_hinst, 0, ctrl_bottom, cxClient-1, lvdy, LVL_STY_VIRTUAL | LVL_STY_NO_HEADER | LVL_STY_PAGE_TO_END ) ; myTerminal->set_terminal_font("Courier New", 100, EZ_ATTR_BOLD) ; myTerminal->lview_assign_column_headers() ; set_local_terminal_colors() ; // should this be wrapped in the terminal module? // Subclass the terminal ListView // wpOrigTermProc = (WNDPROC) SetWindowLongPtr(term->hwndSelf, GWL_WNDPROC, (LONG) TermSubclassProc); wpOrigTermProc = (WNDPROC) myTerminal->terminal_lview_subclass((LONG) TermSubclassProc); // SetClassLong(this_port->cpterm->hwndSelf, GCL_HCURSOR,(long) 0); // disable class cursor // termout("terminal size: columns=%u, screen rows=%u", term->cols, term->rows) ; termout("terminal size: columns=%u, screen rows=%u", myTerminal->get_term_columns(), myTerminal->get_term_rows()) ; //**************************************************************** main_timer_id = SetTimer(hwnd, IDT_TIMER_MAIN, 100, (TIMERPROC) NULL) ; }
/** * ダイアログのプロシージャ。 * @param [in] hDlg ダイアログボックスのハンドルが格納されています * @param [in] uMsg メッセージが格納されています * @param [in] wParam メッセージの追加情報が格納されています * @param [in] lParam メッセージの追加情報が格納されています * @return メッセージを処理した場合は 0 以外(TRUE)、そうでなければ 0(FALSE) */ static BOOL CALLBACK DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static HWND hwndComboBox = NULL; static HWND hwndEdit = NULL; static LRESULT selectedIndex = CB_ERR; static int length = 0; char *imeControl = NULL; switch (uMsg) { case WM_INITDIALOG: center_window(hDlg); hwndComboBox = GetDlgItem(hDlg, IDC_COMBO1); SendMessage(hwndComboBox, CB_LIMITTEXT, 0, 0); hwndEdit = GetWindow(hwndComboBox, GW_CHILD); SetFocus(hwndComboBox); SetFocus(GetDlgItem(hDlg, IDC_COMBO1)); for (unsigned int i = 0; i < history.size(); i++) { SendMessage(hwndComboBox, CB_INSERTSTRING, i, (LPARAM)history[i].c_str()); } CheckRadioButton(hDlg, IDC_RADIO1, IDC_RADIO4, selectedRadioButton); CheckDlgButton(hDlg, IDC_CHECK1, selectedCheckBox); if (selectedRadioButton == IDC_RADIO1 || selectedRadioButton == IDC_RADIO2) { EnableWindow(GetDlgItem(hDlg, IDC_CHECK1), FALSE); } if (selectedText.size() != 0) { SetWindowText(hwndEdit, selectedText.c_str()); } if ((imeControl = iniFile->read("IME", "control")) && strcmp(imeControl, "1") == 0) { HIMC hImc; DWORD dwConv, dwSent; hImc = ImmGetContext(hDlg); ImmGetConversionStatus(hImc, &dwConv, &dwSent); if (ImmGetOpenStatus(hImc)) { ImmSetOpenStatus(hImc, false); } ImmReleaseContext(hDlg, hImc); } // SetFocus でフォーカス移動を行った場合は FALSE を返さなければならない return FALSE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hDlg, IDCANCEL); return TRUE; case IDOK: if (IsDlgButtonChecked(hDlg, IDC_RADIO1)) { selectedRadioButton = IDC_RADIO1; } else if (IsDlgButtonChecked(hDlg, IDC_RADIO2)) { selectedRadioButton = IDC_RADIO2; } else if (IsDlgButtonChecked(hDlg, IDC_RADIO3)) { selectedRadioButton = IDC_RADIO3; } else if (IsDlgButtonChecked(hDlg, IDC_RADIO4)) { selectedRadioButton = IDC_RADIO4; } selectedCheckBox = IsDlgButtonChecked(hDlg, IDC_CHECK1); // 設定ファイルに状態を書き出す switch (selectedRadioButton) { case IDC_RADIO1: iniFile->write("Config", "radio", "1"); break; case IDC_RADIO2: iniFile->write("Config", "radio", "2"); break; case IDC_RADIO3: iniFile->write("Config", "radio", "3"); break; case IDC_RADIO4: iniFile->write("Config", "radio", "4"); break; default: iniFile->write("Config", "radio", "1"); break; } if (selectedCheckBox) { iniFile->write("Config", "check", "TRUE"); } else { iniFile->write("Config", "check", "FALSE"); } // 履歴を保存 length = GetWindowTextLength(hwndEdit); if (length != 0) { char *buf = new char[length + 1]; buf[length] = '\0'; GetWindowText(hwndEdit, buf, length + 1); std::string temp = buf; delete[] buf; history.insert(history.begin(), temp); for (unsigned int i = 0; i < history.size() - 1; i++) { for (unsigned int j = i + 1; j < history.size(); j++) { std::string str1 = history[i]; std::string str2 = history[j]; if (str1 == str2) { history[j] = ""; } } } int index = 0; for (unsigned int i = 0; i < MAX_HISTORY && i < history.size(); i++) { if (history[i] != "") { std::string key = "history"; char num[3] = {0}; sprintf_s(num, "%d", index); key += num; iniFile->write("History", key.c_str(), history[i].c_str()); index++; } } } if (length != 0) { EndDialog(hDlg, IDOK); } else { EndDialog(hDlg, IDCANCEL); } return TRUE; case IDC_RADIO1: case IDC_RADIO2: CheckRadioButton(hDlg, IDC_RADIO1, IDC_RADIO4, LOWORD(wParam)); EnableWindow(GetDlgItem(hDlg, IDC_CHECK1), FALSE); return TRUE; case IDC_RADIO3: case IDC_RADIO4: CheckRadioButton(hDlg, IDC_RADIO1, IDC_RADIO4, LOWORD(wParam)); EnableWindow(GetDlgItem(hDlg, IDC_CHECK1), TRUE); return TRUE; case IDC_COMBO1: switch (HIWORD(wParam)) { case CBN_SELCHANGE: // 選択項目が変更されたとき case CBN_EDITUPDATE: // 直接入力で内容が変更されたとき。変更内容が表示される前に呼ばれる case CBN_EDITCHANGE: // 直接入力で内容が変更されたとき。変更内容が表示された後に呼ばれる selectedIndex = SendMessage(hwndComboBox, CB_GETCURSEL, 0, 0); break; } break; default: break; } return FALSE; case WM_TIMER: return FALSE; case WM_CLOSE: EndDialog(hDlg, WM_CLOSE); return TRUE; default: break; } return FALSE; }
int work_over_actions(struct _config *cfg, char *path, char *strings[3]) { int i = 0, enable = TRUE, searchfor = 0, action = 0; struct process_record *pr = NULL; char buf[BUFSIZE]; if (strings[0]) ses_read_i(&cfg->sessionroot, path, strings[0], 0, &enable); if (!enable) return 0; if (!ses_read_i(&cfg->sessionroot, path, strings[1], 0, &searchfor)) return 0; pr = get_nth_process_record(process_records, nprocesses, path, searchfor); i = 0; action = 0; sprintf(buf, strings[2], i); while (ses_read_i(&cfg->sessionroot, path, buf, 0, &action)) { switch (action) { case SESSION_ACTION_HIDE: if (pr && pr->window) ShowWindow(pr->window, SW_HIDE); break; case SESSION_ACTION_SHOW: if (pr && pr->window) { ShowWindow(pr->window, /*SW_SHOWNORMAL*/ SW_SHOW); SetForegroundWindow(pr->window); }; break; case SESSION_ACTION_MINIMIZE: if (pr && pr->window) ShowWindow(pr->window, SW_MINIMIZE); break; case SESSION_ACTION_MAXIMIZE: if (pr && pr->window) ShowWindow(pr->window, SW_MAXIMIZE); break; case SESSION_ACTION_CENTER: if (pr && pr->window) center_window(pr->window); break; case SESSION_ACTION_KILL: if (pr && pr->window) SendMessage(pr->window, WM_CLOSE, 0, 0); break; case SESSION_ACTION_MURDER: if (pr) TerminateProcess(pr->hprocess, 0); break; case SESSION_ACTION_RUN: launch_putty(0, path); break; }; i++; sprintf(buf, strings[2], i); }; return i; };