Skip to content

Commit

Permalink
replace Dialog with DialogBase
Browse files Browse the repository at this point in the history
  • Loading branch information
lidaobing committed Oct 8, 2021
1 parent af2398c commit 200068d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/iptux/DialogBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class DialogBase : public SessionAbstract, public sigc::trackable {
DialogBase(Application* app, GroupInfo* grp);
virtual ~DialogBase();

virtual GtkWindow* getWindow() = 0;
void ClearHistoryTextView();

protected:
Expand All @@ -45,7 +46,6 @@ class DialogBase : public SessionAbstract, public sigc::trackable {
virtual GtkWidget* CreateHistoryArea();
virtual GtkWidget* CreateFileSendArea();
virtual GtkWidget* CreateFileSendTree(GtkTreeModel* model);
virtual GtkWindow* getWindow() = 0;
virtual GSList* GetSelPal() { return NULL; };

void MainWindowSignalSetup(GtkWindow* window);
Expand Down
2 changes: 1 addition & 1 deletion src/iptux/DialogGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ GtkWindow* DialogGroup::CreateMainWindow() {
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
g_datalist_set_data(&widset, "window-widget", window);
widget_enable_dnd_uri(GTK_WIDGET(window));
grpinf->setDialog(GTK_WINDOW(window));
grpinf->setDialogBase(this);

MainWindowSignalSetup(GTK_WINDOW(window));

Expand Down
2 changes: 1 addition & 1 deletion src/iptux/DialogPeer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void DialogPeer::PeerDialogEntry(Application* app, GroupInfo* grpinf) {
void DialogPeer::init() {
auto dlgpr = this;
auto window = GTK_WIDGET(dlgpr->CreateMainWindow());
grpinf->setDialog(GTK_WINDOW(window));
grpinf->setDialogBase(this);
gtk_container_add(GTK_CONTAINER(window), dlgpr->CreateAllArea());
gtk_widget_show_all(window);
gtk_widget_grab_focus(GTK_WIDGET(inputTextviewWidget));
Expand Down
9 changes: 7 additions & 2 deletions src/iptux/UiModels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "iptux-core/Models.h"
#include "iptux-utils/output.h"
#include "iptux-utils/utils.h"
#include "iptux/DialogBase.h"
#include "iptux/UiHelper.h"

using namespace std;
Expand Down Expand Up @@ -334,7 +335,7 @@ bool GroupInfo::hasPal(PPalInfo pal) const {
GroupInfo::GroupInfo(PPalInfo pal, CPPalInfo me, LogSystem* logSystem)
: grpid(0),
buffer(NULL),
dialog(NULL),
dialogBase(NULL),
me(me),
type(GROUP_BELONG_TYPE_REGULAR),
logSystem(logSystem) {
Expand All @@ -348,14 +349,18 @@ GroupInfo::GroupInfo(iptux::GroupBelongType t,
LogSystem* logSystem)
: grpid(0),
buffer(NULL),
dialog(NULL),
dialogBase(NULL),
me(me),
members(pals),
type(t),
logSystem(logSystem) {
inputBuffer = gtk_text_buffer_new(NULL);
}

GtkWidget* GroupInfo::getDialog() const {
return dialogBase ? GTK_WIDGET(dialogBase->getWindow()) : nullptr;
}

bool GroupInfo::addPal(PPalInfo pal) {
if (type == GROUP_BELONG_TYPE_REGULAR) {
LOG_WARN("should not call addPal on GROUP_BELONG_TYPE_REGULAR");
Expand Down
9 changes: 5 additions & 4 deletions src/iptux/UiModels.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class SessionAbstract {
/**
* 群组信息.
*/
class DialogBase;
class GroupInfo {
public:
GroupInfo(PPalInfo pal, CPPalInfo me, LogSystem* logSystem);
Expand Down Expand Up @@ -67,9 +68,9 @@ class GroupInfo {

GtkTextBuffer* getInputBuffer() const { return inputBuffer; }

void setDialog(GtkWindow* dialog) { this->dialog = GTK_WIDGET(dialog); }
GtkWidget* getDialog() const { return dialog; }
void clearDialog() { dialog = nullptr; }
void setDialogBase(DialogBase* dialogBase) { this->dialogBase = dialogBase; }
GtkWidget* getDialog() const;
void clearDialog() { dialogBase = nullptr; }

public:
sigc::signal<void(GroupInfo*, int, int)> signalUnreadMsgCountUpdated;
Expand All @@ -81,7 +82,7 @@ class GroupInfo {
GtkTextBuffer* buffer; ///< 历史消息缓冲区 *

private:
GtkWidget* dialog; ///< 对话框(若存在则必须与对话框类关联)
DialogBase* dialogBase;
GtkTextBuffer* inputBuffer; /// 输入缓冲

private:
Expand Down

0 comments on commit 200068d

Please sign in to comment.