Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only update .pcmanx/pcmanx and .pcmanx/favorites when needed. Fix #86. #87

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 83 additions & 3 deletions src/core/site.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ CSite::CSite(string Name)
m_bHorizontalCenterAlign = true;
m_bVerticalCenterAlign = true;

// UAO support
m_UAO = 2; // 0 = disable, 1 = UAO 2.41, 2 = UAO 2.50
// UAO support
m_UAO = 2; // 0 = disable, 1 = UAO 2.41, 2 = UAO 2.50

m_MenuItem = NULL;

Expand All @@ -106,7 +106,6 @@ CSite::~CSite()
{
}


void CSite::SaveToFile(FILE *fo)
{
fprintf( fo, "[%s]\n", m_Name.c_str() );
Expand Down Expand Up @@ -173,4 +172,85 @@ void CSite::SaveToFile(FILE *fo)
#endif
}

bool CSite::compare_to(const CSite &rhs)
{
if( m_Name != rhs.m_Name ) {
return false;
}
if( m_URL != rhs.m_URL )
return false;
if( m_AutoReconnect != rhs.m_AutoReconnect )
return false;
if( m_AntiIdle != rhs.m_AntiIdle )
return false;
if( m_AntiIdleStr != rhs.m_AntiIdleStr )
return false;
if( m_Encoding != rhs.m_Encoding )
return false;
if( m_DetectDBChar != rhs.m_DetectDBChar )
return false;
if( m_RowsPerPage != rhs.m_RowsPerPage )
return false;
if( m_ColsPerPage != rhs.m_ColsPerPage )
return false;
if( m_TermType != rhs.m_TermType )
return false;
if( m_ESCConv != rhs.m_ESCConv )
return false;
if( m_CRLF != rhs.m_CRLF )
return false;
if( m_Startup != rhs.m_Startup )
return false;
#ifdef USE_EXTERNAL
if( m_UseExternalSSH != rhs.m_UseExternalSSH )
return false;
if( m_UseExternalTelnet != rhs.m_UseExternalTelnet )
return false;
#endif
if( m_bHorizontalCenterAlign != rhs.m_bHorizontalCenterAlign )
return false;
if( m_bVerticalCenterAlign != rhs.m_bVerticalCenterAlign )
return false;
if( m_UAO != rhs.m_UAO )
return false;
if( m_PreLoginPrompt != rhs.m_PreLoginPrompt )
return false;
if( m_PreLogin != rhs.m_PreLogin )
return false;
if( m_PostLogin != rhs.m_PostLogin )
return false;
if( m_LoginPrompt != rhs.m_LoginPrompt )
return false;
if( m_Login != rhs.m_Login )
return false;
if( m_PasswdPrompt != rhs.m_PasswdPrompt )
return false;
if( m_Passwd != rhs.m_Passwd )
return false;
#ifdef USE_PROXY
if( m_ProxyType != rhs.m_ProxyType )
return false;
if( m_ProxyAddr != rhs.m_ProxyAddr )
return false;
if( m_ProxyPort != rhs.m_ProxyPort )
return false;
if( m_ProxyUser != rhs.m_ProxyUser )
return false;
if( m_ProxyPass != rhs.m_ProxyPass )
return false;
#endif

return true;
}

bool operator==(const CSite &lhs, const CSite &rhs)
{
CSite site(lhs);
return site.compare_to(rhs)? true: false;
}

bool operator!=(const CSite &lhs, const CSite &rhs)
{
CSite site(lhs);
return site.compare_to(rhs)? false: true;
}
20 changes: 12 additions & 8 deletions src/core/site.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class CSite
string m_TermType;

int m_CRLF;
GtkWidget* m_MenuItem;
GtkWidget* m_MenuItem;
// Send CR, LF, or CRLF when Enter is pressed
const char* GetCRLF()
{
Expand All @@ -96,7 +96,7 @@ class CSite
bool m_bHorizontalCenterAlign;
bool m_bVerticalCenterAlign;

int m_UAO;
int m_UAO;

#ifdef USE_PROXY
// Proxy settings
Expand Down Expand Up @@ -131,13 +131,17 @@ class CSite
X_EXPORT string& GetPostLogin(){ return m_PostLogin; }
X_EXPORT void SetPostLogin(string postlogin){ m_PostLogin = postlogin; }

X_EXPORT bool compare_to(const CSite &rhs);
friend bool operator==(const CSite &lhs, const CSite &rhs);
friend bool operator!=(const CSite &lhs, const CSite &rhs);

protected:
string m_Passwd;
string m_Login;
string m_LoginPrompt;
string m_PasswdPrompt;
string m_PreLogin;
string m_PreLoginPrompt;
string m_Passwd;
string m_Login;
string m_LoginPrompt;
string m_PasswdPrompt;
string m_PreLogin;
string m_PreLoginPrompt;
string m_PostLogin;
};

Expand Down
20 changes: 10 additions & 10 deletions src/editfavdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ class CListBox;
class CEditFavDlg : public CDialog
{
public:
CEditFavDlg(CWidget* parent, vector<CSite>& sites);

static void OnAdd(GtkWidget* btn, CEditFavDlg* _this);
static void OnEdit(GtkWidget* btn, CEditFavDlg* _this);
static void OnRemove(GtkWidget* btn, CEditFavDlg* _this);
static void OnUp(GtkWidget* btn, CEditFavDlg* _this);
static void OnDown(GtkWidget* btn, CEditFavDlg* _this);
static void OnRowActivated(GtkTreeView *tree_view, GtkTreePath* path,
CEditFavDlg(CWidget* parent, vector<CSite>& sites);

static void OnAdd(GtkWidget* btn, CEditFavDlg* _this);
static void OnEdit(GtkWidget* btn, CEditFavDlg* _this);
static void OnRemove(GtkWidget* btn, CEditFavDlg* _this);
static void OnUp(GtkWidget* btn, CEditFavDlg* _this);
static void OnDown(GtkWidget* btn, CEditFavDlg* _this);
static void OnRowActivated(GtkTreeView *tree_view, GtkTreePath* path,
GtkTreeViewColumn* col, CEditFavDlg* _this);

vector<CSite>& m_Sites;
CListBox* m_List;
vector<CSite> m_Sites;
CListBox* m_List;
GtkWidget* m_EditBtn;
protected:
};
Expand Down
67 changes: 53 additions & 14 deletions src/generalprefpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,23 +183,62 @@ CGeneralPrefPage::CGeneralPrefPage()
}


void CGeneralPrefPage::OnOK()
bool CGeneralPrefPage::OnOK()
{
AppConfig.QueryOnCloseCon = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_QueryOnCloseCon));
AppConfig.QueryOnExit = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_QueryOnExit));
AppConfig.CancelSelAfterCopy = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_CancelSelAfterCopy));
AppConfig.Opacity = (int) gtk_adjustment_get_value(GTK_ADJUSTMENT(m_Opacity_adj));
bool pref_updated = false;

if( AppConfig.QueryOnCloseCon != gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_QueryOnCloseCon)) ) {
pref_updated = true;
AppConfig.QueryOnCloseCon = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_QueryOnCloseCon));
}
if( AppConfig.QueryOnExit != gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_QueryOnExit)) ) {
pref_updated = true;
AppConfig.QueryOnExit = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_QueryOnExit));
}
if( AppConfig.CancelSelAfterCopy != gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_CancelSelAfterCopy)) ) {
pref_updated = true;
AppConfig.CancelSelAfterCopy = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_CancelSelAfterCopy));
}
if( AppConfig.Opacity != (int) gtk_adjustment_get_value(GTK_ADJUSTMENT(m_Opacity_adj)) ) {
pref_updated = true;
AppConfig.Opacity = (int) gtk_adjustment_get_value(GTK_ADJUSTMENT(m_Opacity_adj));
}
#ifdef USE_MOUSE
AppConfig.MouseSupport = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_MouseSupport));
if( AppConfig.MouseSupport != gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_MouseSupport)) ) {
pref_updated = true;
AppConfig.MouseSupport = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_MouseSupport));
}
#endif
#ifdef USE_DOCKLET
AppConfig.ShowTrayIcon = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_ShowTrayIcon));
if( AppConfig.ShowTrayIcon != gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_ShowTrayIcon)) ) {
pref_updated = true;
AppConfig.ShowTrayIcon = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_ShowTrayIcon));
}
#endif
AppConfig.AntiAliasFont = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_AAFont));
AppConfig.PopupNotifier = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(m_PopupNotifier));
AppConfig.PopupTimeout = (int)gtk_spin_button_get_value( GTK_SPIN_BUTTON(m_PopupTimeout));
AppConfig.MidClickAsClose = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(m_MidClickAsClose));
AppConfig.WebBrowser = gtk_entry_get_text(GTK_ENTRY(m_WebBrowser));
AppConfig.MailClient = gtk_entry_get_text(GTK_ENTRY(m_MailClient));
if( AppConfig.AntiAliasFont != gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_AAFont)) ) {
pref_updated = true;
AppConfig.AntiAliasFont = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_AAFont));
}
if( AppConfig.PopupNotifier != gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_PopupNotifier)) ) {
pref_updated = true;
AppConfig.PopupNotifier = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_PopupNotifier));
}
if( AppConfig.PopupTimeout != (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(m_PopupTimeout)) ) {
pref_updated = true;
AppConfig.PopupTimeout = (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(m_PopupTimeout));
}
if( AppConfig.MidClickAsClose != gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_MidClickAsClose)) ) {
pref_updated = true;
AppConfig.MidClickAsClose = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_MidClickAsClose));
}
if( AppConfig.WebBrowser != gtk_entry_get_text(GTK_ENTRY(m_WebBrowser)) ) {
pref_updated = true;
AppConfig.WebBrowser = gtk_entry_get_text(GTK_ENTRY(m_WebBrowser));
}
if( AppConfig.MailClient != gtk_entry_get_text(GTK_ENTRY(m_MailClient)) ) {
pref_updated = true;
AppConfig.MailClient = gtk_entry_get_text(GTK_ENTRY(m_MailClient));
}

return pref_updated;
}
9 changes: 4 additions & 5 deletions src/generalprefpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
class CGeneralPrefPage : public CWidget
{
public:
CGeneralPrefPage();
void OnOK();
CGeneralPrefPage();
bool OnOK();
public:
GtkWidget *m_QueryOnCloseCon;
GtkWidget *m_QueryOnExit;
GtkWidget *m_CancelSelAfterCopy;

GtkWidget *m_Opacity;
GtkObject *m_Opacity_adj;
GtkWidget *m_Opacity;
GtkObject *m_Opacity_adj;
#ifdef USE_MOUSE
GtkWidget *m_MouseSupport;
#endif
Expand All @@ -55,7 +55,6 @@ class CGeneralPrefPage : public CWidget
GtkWidget *m_PopupTimeout;
GtkWidget *m_MidClickAsClose;
GtkWidget *m_pWgetFiles;

};

#endif
101 changes: 81 additions & 20 deletions src/keysettingpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ CKeySettingPage::CKeySettingPage(GtkWidget *parent): CWidget()
/**
* Get value from gtk entries and save them into AppConfig
*/
void CKeySettingPage::OnOK()
bool CKeySettingPage::OnOK()
{
bool setting_updated = false;

// show message dialog
GtkWidget *MessageDialog = gtk_message_dialog_new(
GTK_WINDOW(m_Parent),
Expand All @@ -130,25 +132,84 @@ void CKeySettingPage::OnOK()
gtk_dialog_run(GTK_DIALOG(MessageDialog));
gtk_widget_destroy(MessageDialog);

AppConfig.keySiteList = gtk_entry_get_text(GTK_ENTRY(m_Entries[keySiteList]));
AppConfig.keyNewConn0 = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyNewConn0]));
AppConfig.keyNewConn1 = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyNewConn1]));
AppConfig.keyReconn0 = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyReconn0]));
AppConfig.keyReconn1 = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyReconn1]));
AppConfig.keyClose0 = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyClose0]));
AppConfig.keyClose1 = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyClose1]));
AppConfig.keyNextPage = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyNextPage]));
AppConfig.keyPrevPage = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyPrevPage]));
AppConfig.keyFirstPage = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyFirstPage]));
AppConfig.keyLastPage = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyLastPage]));
AppConfig.keyCopy0 = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyCopy0]));
AppConfig.keyCopy1 = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyCopy1]));
AppConfig.keyPaste0 = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyPaste0]));
AppConfig.keyPaste1 = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyPaste1]));
AppConfig.keyPasteClipboard = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyPasteClipboard]));
AppConfig.keyEmotions = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyEmotions]));
AppConfig.keyFullscreen = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyFullscreen]));
AppConfig.keyShowMainWindow = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyShowMainWindow]));
if( AppConfig.keySiteList != gtk_entry_get_text(GTK_ENTRY(m_Entries[keySiteList])) ) {
setting_updated = true;
AppConfig.keySiteList = gtk_entry_get_text(GTK_ENTRY(m_Entries[keySiteList]));
}
if( AppConfig.keyNewConn0 != gtk_entry_get_text(GTK_ENTRY(m_Entries[keyNewConn0])) ) {
setting_updated = true;
AppConfig.keyNewConn0 = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyNewConn0]));
}
if( AppConfig.keyNewConn1 != gtk_entry_get_text(GTK_ENTRY(m_Entries[keyNewConn1])) ) {
setting_updated = true;
AppConfig.keyNewConn1 = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyNewConn1]));
}
if( AppConfig.keyReconn0 != gtk_entry_get_text(GTK_ENTRY(m_Entries[keyReconn0])) ) {
setting_updated = true;
AppConfig.keyReconn0 = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyReconn0]));
}
if( AppConfig.keyReconn1 != gtk_entry_get_text(GTK_ENTRY(m_Entries[keyReconn1])) ) {
setting_updated = true;
AppConfig.keyReconn1 = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyReconn1]));
}
if( AppConfig.keyClose0 != gtk_entry_get_text(GTK_ENTRY(m_Entries[keyClose0])) ) {
setting_updated = true;
AppConfig.keyClose0 = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyClose0]));
}
if( AppConfig.keyClose1 != gtk_entry_get_text(GTK_ENTRY(m_Entries[keyClose1])) ) {
setting_updated = true;
AppConfig.keyClose1 = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyClose1]));
}
if( AppConfig.keyNextPage != gtk_entry_get_text(GTK_ENTRY(m_Entries[keyNextPage])) ) {
setting_updated = true;
AppConfig.keyNextPage = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyNextPage]));
}
if( AppConfig.keyPrevPage != gtk_entry_get_text(GTK_ENTRY(m_Entries[keyPrevPage])) ) {
setting_updated = true;
AppConfig.keyPrevPage = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyPrevPage]));
}
if( AppConfig.keyFirstPage != gtk_entry_get_text(GTK_ENTRY(m_Entries[keyFirstPage])) ) {
setting_updated = true;
AppConfig.keyFirstPage = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyFirstPage]));
}
if( AppConfig.keyLastPage != gtk_entry_get_text(GTK_ENTRY(m_Entries[keyLastPage])) ) {
setting_updated = true;
AppConfig.keyLastPage = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyLastPage]));
}
if( AppConfig.keyCopy0 != gtk_entry_get_text(GTK_ENTRY(m_Entries[keyCopy0])) ) {
setting_updated = true;
AppConfig.keyCopy0 = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyCopy0]));
}
if( AppConfig.keyCopy1 != gtk_entry_get_text(GTK_ENTRY(m_Entries[keyCopy1])) ) {
setting_updated = true;
AppConfig.keyCopy1 = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyCopy1]));
}
if( AppConfig.keyPaste0 != gtk_entry_get_text(GTK_ENTRY(m_Entries[keyPaste0])) ) {
setting_updated = true;
AppConfig.keyPaste0 = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyPaste0]));
}
if( AppConfig.keyPaste1 != gtk_entry_get_text(GTK_ENTRY(m_Entries[keyPaste1])) ) {
setting_updated = true;
AppConfig.keyPaste1 = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyPaste1]));
}
if( AppConfig.keyPasteClipboard != gtk_entry_get_text(GTK_ENTRY(m_Entries[keyPasteClipboard])) ) {
setting_updated = true;
AppConfig.keyPasteClipboard = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyPasteClipboard]));
}
if( AppConfig.keyEmotions != gtk_entry_get_text(GTK_ENTRY(m_Entries[keyEmotions])) ) {
setting_updated = true;
AppConfig.keyEmotions = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyEmotions]));
}
if( AppConfig.keyFullscreen != gtk_entry_get_text(GTK_ENTRY(m_Entries[keyFullscreen])) ) {
setting_updated = true;
AppConfig.keyFullscreen = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyFullscreen]));
}
if( AppConfig.keyShowMainWindow != gtk_entry_get_text(GTK_ENTRY(m_Entries[keyShowMainWindow])) ) {
setting_updated = true;
AppConfig.keyShowMainWindow = gtk_entry_get_text(GTK_ENTRY(m_Entries[keyShowMainWindow]));
}

return setting_updated;
}

gboolean CKeySettingPage::onKeyPress(GtkWidget *widget, GdkEventKey *event, gpointer data)
Expand Down
Loading