Browse files

New GUI

  • Loading branch information...
1 parent 11b2275 commit 42d5515914cb37bded5cffcbb8049a40c69d1435 @hessionb committed Apr 19, 2012
Showing with 146 additions and 15 deletions.
  1. +3 −0 etc/classcatcher.log
  2. +7 −0 etc/cookie.txt
  3. +46 −0 headers/error.h
  4. +4 −0 headers/gui.h
  5. +5 −3 headers/popup.h
  6. +53 −0 src/error.cpp
  7. +2 −2 src/gui.cpp
  8. +21 −5 src/popup.cpp
  9. +5 −5 src/tree.cpp
View
3 etc/classcatcher.log
@@ -0,0 +1,3 @@
+CRN: 92111 - 6
+CRN: 99999 - None
+CRN: 98888 - None
View
7 etc/cookie.txt
@@ -0,0 +1,7 @@
+# Netscape HTTP Cookie File
+# http://www.netscape.com/newsref/std/cookie_spec.html
+# This is a generated file! Do not edit.
+
+.vt.edu TRUE / TRUE NATIVE_LOGIN TRUE
+.vt.edu TRUE / TRUE SESSID QUlVVlQzMTIwNjAxODU=
+banweb.banner.vt.edu FALSE /ssb/prod TRUE TESTID set
View
46 headers/error.h
@@ -0,0 +1,46 @@
+/***
+ * Brian Hession, Erik Wenkel, James Miller
+ *
+ * Error window
+ *
+ * Error window that pops up when something
+ * bad happens.
+ *
+ */
+
+#ifndef ERROR_H
+#define ERROR_H
+
+#include <gtkmm/window.h>
+#include <gtkmm/box.h>
+#include <gtkmm/label.h>
+#include <gtkmm/button.h>
+#include <glibmm/ustring.h>
+
+
+class Error : public Gtk::Window {
+
+ public:
+ Error();
+ virtual ~Error();
+
+ void setfields( Gtk::Window* w );
+ void setlabel( Glib::ustring s );
+
+ protected:
+ // Signal handlers
+ void on_close();
+
+ // Formatting
+ Gtk::VBox m_VBox;
+
+ // Widgets
+ Gtk::Label errorlabel;
+ Gtk::Button close_button;
+
+ // Parent
+ Gtk::Window* parent;
+};
+
+#endif
+
View
4 headers/gui.h
@@ -20,6 +20,7 @@
#include "credentials.h"
#include "options.h"
#include "popup.h"
+#include "error.h"
// Create class GUI extending Gtk::Window
@@ -66,6 +67,9 @@ class GUI : public Gtk::Window {
// Test
Popup popup;
+
+ // Error
+ Error error;
};
#endif
View
8 headers/popup.h
@@ -22,6 +22,7 @@
#include <glibmm/ustring.h>
#include "tree.h"
+#include "error.h"
class Popup : public Gtk::Window {
@@ -30,12 +31,13 @@ class Popup : public Gtk::Window {
Popup();
virtual ~Popup();
- void set_values( Gtk::Window* parent, Tree* t );
+ void set_values( Gtk::Window* parent, Tree* t, Error* e );
protected:
// Signal handlers
void on_apply();
void on_close();
+ void on_error();
// Entry model
class ModelColumns : public Gtk::TreeModel::ColumnRecord {
@@ -46,8 +48,7 @@ class Popup : public Gtk::Window {
}
Gtk::TreeModelColumn<Glib::ustring> m_col_name;
- };
- ModelColumns m_columns;
+ } m_columns;
// For entry completion
typedef std::map<int, Glib::ustring> type_actions_map;
@@ -70,6 +71,7 @@ class Popup : public Gtk::Window {
// Pointers to Parent widgets
Gtk::Window* parent;
Tree* classlist;
+ Error* error;
};
#endif
View
53 src/error.cpp
@@ -0,0 +1,53 @@
+/***
+ * Brian Hession, Erik Wenkel, James Miller
+ *
+ * Error popup implementation
+ *
+ */
+
+#include "error.h"
+
+Error::Error()
+:
+ // Initializing
+ errorlabel( "Error: " ),
+ close_button( "_Close", true )
+{
+ // Window properties
+ set_title( "Error Message" );
+ set_size_request( 200, 5 );
+ set_resizable( false );
+ set_border_width( 5 );
+ set_keep_above( true );
+ set_decorated( false );
+
+ m_VBox.pack_start( errorlabel, Gtk::PACK_SHRINK );
+ m_VBox.pack_start( close_button, Gtk::PACK_SHRINK );
+
+ add( m_VBox );
+
+ // Add signal
+ close_button.signal_clicked().connect( sigc::mem_fun( *this,
+ &Error::on_close ) );
+
+ show_all_children();
+}
+
+Error::~Error() {}
+
+void Error::setfields( Gtk::Window* w ) {
+
+ parent = w;
+}
+
+void Error::setlabel( Glib::ustring s ) {
+
+ errorlabel.set_text( s );
+}
+
+void Error::on_close() {
+
+ parent->set_sensitive( true );
+ hide();
+}
+
View
4 src/gui.cpp
@@ -82,10 +82,10 @@ void GUI::deleteclass() {
void GUI::popupwindow() {
// Make window popup
- popup.set_values( this, &classtree );
+ popup.set_values( this, &classtree, &error );
int x, y;
get_position( x, y );
- popup.move( x + 15, y + 15 );
+ popup.move( x + 15, y + 50 );
set_sensitive( false );
popup.show();
}
View
26 src/popup.cpp
@@ -30,6 +30,7 @@ Popup::Popup()
set_resizable( false );
set_border_width( 5 );
set_keep_above( true );
+ set_decorated( false );
// Term combo
term_combo.set_id_column( 0 );
@@ -359,10 +360,24 @@ Popup::Popup()
Popup::~Popup() {}
// set_tree
-void Popup::set_values( Gtk::Window* g, Tree* t ) {
+void Popup::set_values( Gtk::Window* g, Tree* t, Error* e ) {
parent = g;
classlist = t;
+ error = e;
+}
+
+// Error
+void Popup::on_error() {
+
+ error->setfields( this );
+ set_sensitive( false );
+
+ int x, y;
+ get_position( x, y );
+ error->move( x + 30, y + 60 );
+
+ error->show();
}
bool isvalid( Glib::ustring s, unsigned int len ) {
@@ -387,10 +402,11 @@ void Popup::on_apply() {
course.subj = subj_entry.get_text();
course.crse = crse_entry.get_text();
- if(isvalid(course.crn,5))
- std::cout << "good" << std::endl;
- if(isvalid(course.crse,4))
- std::cout << "good" << std::endl;
+ if(!isvalid(course.crn,5) || !isvalid(course.crse, 4)) {
+ error->setlabel( "Invalid Field" );
+ on_error();
+ return;
+ }
// Reset Fields
crn_entry.delete_text( 0, -1 );
View
10 src/tree.cpp
@@ -29,7 +29,7 @@ Tree::~Tree() {}
void Tree::loadfromfile() {
// Read from text file
- std::ifstream coursefile( "include/.courses" );
+ std::ifstream coursefile( "etc/.courses" );
if( coursefile.is_open() ) {
while( true ) {
Tree::Course c;
@@ -75,8 +75,8 @@ void Tree::deleteclass() {
if( *iter ) {
Glib::ustring str = (*iter)[m_Columns.m_col_crn];
- std::ifstream coursefile( "include/.courses" );
- std::ofstream tempfile( "include/.courses.tmp" );
+ std::ifstream coursefile( "etc/.courses" );
+ std::ofstream tempfile( "etc/.courses.tmp" );
if( coursefile.is_open() && tempfile.is_open() ) {
while( true ) {
char buf[10], line[256];
@@ -89,8 +89,8 @@ void Tree::deleteclass() {
}
coursefile.close();
tempfile.close();
- std::remove( "include/.courses" ); // Remove and rename file
- std::rename( "include/.courses.tmp", "include/.courses" );
+ std::remove( "etc/.courses" ); // Remove and rename file
+ std::rename( "etc/.courses.tmp", "etc/.courses" );
}
m_refTreeModel->erase( iter ); // Erase from tree
}

0 comments on commit 42d5515

Please sign in to comment.