// global.cxx // // Global class implementation for the Glaum project // #include "prototype.h" #include "defines.h" #include "global.h" #include #include Global::Global() { gchar *listTitle[1] = {"MP3 Source"}; notebook = gtk_notebook_new(); textWidget = gtk_text_new(NULL, NULL); sourceEntryWidget = gtk_entry_new(); destEntryWidget = gtk_entry_new(); statusbar = gtk_statusbar_new(); workingEntryWidget = gtk_entry_new(); lastBatchRowSelected = 0; batchRowCount = 0; dialogLock = MODAL_FILE_SELECTION; sudo = SUDO_FOR_BURNING; cdrecordSpeed = CDRECORD_DEFAULT_SPEED; cdrecordDevice = CDRECORD_DEFAULT_DEVICE; cdrecordVerboseOutput = CDRECORD_USE_VERBOSE; listWidget = gtk_clist_new_with_titles(1, listTitle); gtk_clist_set_selection_mode(GTK_CLIST(listWidget), GTK_SELECTION_SINGLE); gtk_clist_set_column_auto_resize(GTK_CLIST(listWidget), 0, TRUE); gtk_clist_set_shadow_type(GTK_CLIST(listWidget), GTK_SHADOW_OUT); gtk_clist_column_titles_passive(GTK_CLIST(listWidget)); X(listWidget, "select_row", batch_row_selected, (gpointer)this); sudoCheckbox = gtk_check_button_new_with_label("SUDO for burning"); dialogLockCheckbox = gtk_check_button_new_with_label("Modal Select File Dialog"); cdrecordVerboseCheckbox = gtk_check_button_new_with_label("Verbose cdrecord output"); cdrecordSpeedEntry = gtk_entry_new_with_max_length(3); cdrecordDeviceEntry = gtk_entry_new_with_max_length(8); } Global::~Global() { } void Global::resetTextWidget(void) { gtk_text_set_point(GTK_TEXT(textWidget), 0); gtk_text_forward_delete(GTK_TEXT(textWidget), gtk_text_get_length(GTK_TEXT(textWidget))); } void Global::appendTextWidget(std::string text) { gtk_text_insert(GTK_TEXT(textWidget), NULL, NULL, NULL, text.c_str(), text.length()); } void Global::message(std::string msg) { guint id = gtk_statusbar_get_context_id(GTK_STATUSBAR(statusbar), msg.c_str()); gtk_statusbar_push(GTK_STATUSBAR(statusbar), id, msg.c_str()); } void Global::makeFileDialog(std::string title, bool single = true) { fileDialog = gtk_file_selection_new(title.c_str()); if(single) X(GTK_FILE_SELECTION(fileDialog)->ok_button, "clicked", store_src, (gpointer)this); else X(GTK_FILE_SELECTION(fileDialog)->ok_button, "clicked", batch_store, (gpointer)this); X(GTK_FILE_SELECTION(fileDialog)->cancel_button, "clicked", close_fileopen, (gpointer)this); if(dialogLock) { X(GTK_FILE_SELECTION(fileDialog)->ok_button, "clicked", close_fileopen, (gpointer)this); gtk_grab_add(fileDialog); } gtk_widget_show(fileDialog); } void Global::batchAppend(std::string item) { gchar *temp[1] = {(gchar*)item.c_str()}; gtk_clist_append(GTK_CLIST(listWidget), temp); batchRowCount++; } void Global::batchRemove(std::string item) { gint row = 0; row = gtk_clist_find_row_from_data(GTK_CLIST(listWidget), (gpointer)item.c_str()); gtk_clist_remove(GTK_CLIST(listWidget), row); batchRowCount--; } void Global::batchRemove(int row) { gtk_clist_remove(GTK_CLIST(listWidget), row); } void Global::batchClear(void) { gtk_clist_clear(GTK_CLIST(listWidget)); batchRowCount = 0; } void Global::batchSwapUp(void) { gtk_clist_swap_rows(GTK_CLIST(listWidget), lastBatchRowSelected, lastBatchRowSelected--); } void Global::batchSwapDown(void) { gtk_clist_swap_rows(GTK_CLIST(listWidget), lastBatchRowSelected, lastBatchRowSelected++); } std::string Global::getBatchCurrentFile(const int idx) { char *fileName[1]; gtk_clist_get_text(GTK_CLIST(listWidget), idx, 0, fileName); return *fileName; } GtkWidget *Global::getSudoCheckbox(void) { if(sudoCheckbox == NULL) sudoCheckbox = gtk_check_button_new_with_label("SUDO for burning"); return sudoCheckbox; } GtkWidget *Global::getDialogLockCheckbox(void) { if(dialogLockCheckbox == NULL) dialogLockCheckbox = gtk_check_button_new_with_label("Modal Select File Dialog"); return dialogLockCheckbox; } GtkWidget *Global::getCdrecordVerboseCheckbox(void) { if(cdrecordVerboseCheckbox == NULL) cdrecordVerboseCheckbox = gtk_check_button_new_with_label("Verbose cdrecord output"); return cdrecordVerboseCheckbox; } GtkWidget *Global::getCdrecordSpeedEntryWidget(void) { if(cdrecordSpeedEntry == NULL) cdrecordSpeedEntry = gtk_entry_new_with_max_length(3); return cdrecordSpeedEntry; } GtkWidget *Global::getCdrecordDeviceEntryWidget(void) { if(cdrecordDeviceEntry == NULL) cdrecordDeviceEntry = gtk_entry_new_with_max_length(8); return cdrecordDeviceEntry; }