Skip to content

Commit

Permalink
Merge branch 'master' into 610-cant-send-image-in-group-chat
Browse files Browse the repository at this point in the history
  • Loading branch information
lidaobing authored Dec 28, 2024
2 parents 0ece922 + f0224d4 commit 1e1b728
Show file tree
Hide file tree
Showing 25 changed files with 1,976 additions and 1,857 deletions.
216 changes: 110 additions & 106 deletions po/cs.po

Large diffs are not rendered by default.

216 changes: 110 additions & 106 deletions po/de.po

Large diffs are not rendered by default.

216 changes: 110 additions & 106 deletions po/en_GB.po

Large diffs are not rendered by default.

216 changes: 110 additions & 106 deletions po/es.po

Large diffs are not rendered by default.

216 changes: 110 additions & 106 deletions po/fr.po

Large diffs are not rendered by default.

216 changes: 110 additions & 106 deletions po/gl.po

Large diffs are not rendered by default.

216 changes: 110 additions & 106 deletions po/iptux.pot

Large diffs are not rendered by default.

216 changes: 110 additions & 106 deletions po/it.po

Large diffs are not rendered by default.

216 changes: 110 additions & 106 deletions po/lb.po

Large diffs are not rendered by default.

216 changes: 110 additions & 106 deletions po/nb_NO.po

Large diffs are not rendered by default.

216 changes: 110 additions & 106 deletions po/pl.po

Large diffs are not rendered by default.

216 changes: 110 additions & 106 deletions po/pt.po

Large diffs are not rendered by default.

216 changes: 110 additions & 106 deletions po/pt_BR.po

Large diffs are not rendered by default.

216 changes: 110 additions & 106 deletions po/ru.po

Large diffs are not rendered by default.

216 changes: 110 additions & 106 deletions po/uk.po

Large diffs are not rendered by default.

224 changes: 114 additions & 110 deletions po/zh_CN.po

Large diffs are not rendered by default.

216 changes: 110 additions & 106 deletions po/zh_TW.po

Large diffs are not rendered by default.

20 changes: 6 additions & 14 deletions src/api/iptux-core/ProgramData.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef IPTUX_PROGRAMDATACORE_H
#define IPTUX_PROGRAMDATACORE_H

#include <cstdint>
#include <memory>
#include <mutex>

Expand All @@ -9,20 +10,6 @@

namespace iptux {

/* flags
// 消息(:7);当有消息时自动打开聊天窗口
// 图标(:6);程序启动后只显示托盘图标而不显示面板
// 传输(:5);当有文件传输时自动打开文件传输窗口
// enter(:4);使用Enter键发送消息
// 历史(:3);关闭好友对话框后自动清空聊天历史
// 日志(:2);开启日志记录功能
// 黑名单(:1);不允许删除的好友再出现
// 共享(:0);好友请求本人的共享文件时需要得到确认
*//* sndfgs
// 传输(:2);文件传输完成后需要播放提示音
// 消息(:1);有消息到来后需要播放提示音
// 声音(:0);是否需要提示音
*/
class ProgramData {
public:
explicit ProgramData(std::shared_ptr<IptuxConfig> config);
Expand Down Expand Up @@ -65,6 +52,7 @@ class ProgramData {
bool IsSaveChatHistory() const;
bool IsUsingBlacklist() const;
bool IsFilterFileShareRequest() const;
bool isHideTaskbarWhenMainWindowIconified() const;
void set_port(uint16_t port, bool is_init = false);
void setOpenChat(bool value) { open_chat = value; }
void setHideStartup(bool value) { hide_startup = value; }
Expand All @@ -74,6 +62,9 @@ class ProgramData {
void setRecordLog(bool value) { record_log = value; }
void setOpenBlacklist(bool value) { open_blacklist = value; }
void setProofShared(bool value) { proof_shared = value; }
void setHideTaskbarWhenMainWindowIconified(bool value) {
hide_taskbar_when_main_window_iconified_ = value;
}

bool need_restart() const { return need_restart_; }

Expand Down Expand Up @@ -115,6 +106,7 @@ class ProgramData {
uint8_t record_log : 1;
uint8_t open_blacklist : 1;
uint8_t proof_shared : 1;
uint8_t hide_taskbar_when_main_window_iconified_ : 1;
uint8_t need_restart_ : 1;

private:
Expand Down
1 change: 1 addition & 0 deletions src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define PHOTO_PATH "/iptux/photo"

#mesondefine SYSTEM_DARWIN
#mesondefine HAVE_APPINDICATOR

#if defined(__APPLE__) || defined(__CYGWIN__)
#define O_LARGEFILE 0
Expand Down
13 changes: 12 additions & 1 deletion src/iptux-core/ProgramData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ void ProgramData::WriteProgData() {
config->SetBool("record_log", record_log);
config->SetBool("open_blacklist", open_blacklist);
config->SetBool("proof_shared", proof_shared);

config->SetBool("hide_taskbar_when_main_window_iconified",
hide_taskbar_when_main_window_iconified_);
config->SetString("access_shared_limit", passwd);
config->SetInt("send_message_retry_in_us", send_message_retry_in_us);
WriteNetSegment();
Expand Down Expand Up @@ -141,6 +142,8 @@ void ProgramData::ReadProgData() {
record_log = config->GetBool("record_log", true);
open_blacklist = config->GetBool("open_blacklist");
proof_shared = config->GetBool("proof_shared");
hide_taskbar_when_main_window_iconified_ =
config->GetBool("hide_taskbar_when_main_window_iconified");

passwd = config->GetString("access_shared_limit");
send_message_retry_in_us =
Expand Down Expand Up @@ -234,6 +237,14 @@ bool ProgramData::IsFilterFileShareRequest() const {
return proof_shared;
}

bool ProgramData::isHideTaskbarWhenMainWindowIconified() const {
#if HAVE_APPINDICATOR
return hide_taskbar_when_main_window_iconified_;
#else
return false;
#endif
}

ProgramData& ProgramData::SetUsingBlacklist(bool value) {
open_blacklist = value;
return *this;
Expand Down
4 changes: 4 additions & 0 deletions src/iptux/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class Application {
PPalInfo getMe();
GMenuModel* menu() { return menu_; }

GtkWidget* getPreferenceDialog() { return preference_dialog_; }
void setPreferenceDialog(GtkWidget* dialog) { preference_dialog_ = dialog; }

private:
std::shared_ptr<IptuxConfig> config;
std::shared_ptr<ProgramData> data;
Expand All @@ -58,6 +61,7 @@ class Application {
LogSystem* logSystem = 0;
NotificationService* notificationService = 0;
GMenuModel* menu_ = 0;
GtkWidget* preference_dialog_ = 0;
bool use_header_bar_ = false;
bool started{false};

Expand Down
72 changes: 47 additions & 25 deletions src/iptux/DataSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,14 @@ DataSettings::~DataSettings() {
* @param parent 父窗口指针
*/
void DataSettings::ResetDataEntry(Application* app, GtkWidget* parent) {
if (app->getPreferenceDialog()) {
gtk_window_present(GTK_WINDOW(app->getPreferenceDialog()));
return;
}

DataSettings dset(app, parent);
GtkWidget* dialog = GTK_WIDGET(dset.dialog());
app->setPreferenceDialog(dialog);

/* 运行对话框 */
gtk_widget_show_all(dialog);
Expand Down Expand Up @@ -98,6 +104,7 @@ void DataSettings::ResetDataEntry(Application* app, GtkWidget* parent) {
break;
}
}
app->setPreferenceDialog(NULL);
}

/**
Expand Down Expand Up @@ -395,6 +402,14 @@ GtkWidget* DataSettings::CreateSystem() {
gtk_grid_attach(GTK_GRID(box), widget, 0, row, 2, 1);
g_datalist_set_data(&widset, "shared-check-widget", widget);

#if HAVE_APPINDICATOR
row++;
widget = gtk_check_button_new_with_label(
_("Hide the taskbar when the main window is minimized"));
gtk_grid_attach(GTK_GRID(box), widget, 0, row, 2, 1);
g_datalist_set_data(&widset, "taskbar-check-widget", widget);
#endif

return GTK_WIDGET(box);
}

Expand Down Expand Up @@ -576,6 +591,12 @@ void DataSettings::SetSystemValue() {
widget = GTK_WIDGET(g_datalist_get_data(&widset, "shared-check-widget"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),
g_progdt->IsFilterFileShareRequest());
#if HAVE_APPINDICATOR
widget = GTK_WIDGET(g_datalist_get_data(&widset, "taskbar-check-widget"));
gtk_toggle_button_set_active(
GTK_TOGGLE_BUTTON(widget),
g_progdt->isHideTaskbarWhenMainWindowIconified());
#endif
}

/**
Expand Down Expand Up @@ -836,7 +857,7 @@ string DataSettings::ObtainSystemValue(bool dryrun) {
gint active;

auto g_cthrd = app->getCoreThread();
auto g_progdt = g_cthrd->getProgramData();
auto progdt = g_cthrd->getProgramData();

ostringstream oss;

Expand All @@ -858,9 +879,9 @@ string DataSettings::ObtainSystemValue(bool dryrun) {
port_valid = false;
}

if (port_valid && port != g_progdt->port()) {
if (port_valid && port != progdt->port()) {
if (!dryrun) {
g_progdt->set_port(port);
progdt->set_port(port);
}
}

Expand All @@ -873,15 +894,15 @@ string DataSettings::ObtainSystemValue(bool dryrun) {
text = gtk_editable_get_chars(GTK_EDITABLE(widget), 0, -1);
g_strstrip(text);
if (*text != '\0') {
g_progdt->codeset = text;
progdt->codeset = text;
} else
g_free(text);

widget = GTK_WIDGET(g_datalist_get_data(&widset, "encode-entry-widget"));
text = gtk_editable_get_chars(GTK_EDITABLE(widget), 0, -1);
g_strstrip(text);
if (*text != '\0') {
g_progdt->encode = text;
progdt->encode = text;
} else
g_free(text);

Expand All @@ -892,57 +913,58 @@ string DataSettings::ObtainSystemValue(bool dryrun) {
snprintf(path, MAX_PATHLEN, "%d", active);
gtk_tree_model_get_iter_from_string(model, &iter, path);
gtk_tree_model_get(model, &iter, 1, &file, -1);
if (strcmp(g_progdt->palicon, file) != 0) {
if (strcmp(progdt->palicon, file) != 0) {
snprintf(path, MAX_PATHLEN, __PIXMAPS_PATH "/icon/%s", file);
if (access(path, F_OK) != 0) {
g_free(file);
g_free(g_progdt->palicon);
g_progdt->palicon = g_strdup("pal-icon");
g_free(progdt->palicon);
progdt->palicon = g_strdup("pal-icon");
snprintf(path, MAX_PATHLEN, "%s" ICON_PATH "/pal-icon",
g_get_user_config_dir());
gtk_tree_model_get(model, &iter, 0, &pixbuf, -1);
gdk_pixbuf_save(pixbuf, path, "png", NULL, NULL);
gtk_icon_theme_add_builtin_icon(g_progdt->palicon, MAX_ICONSIZE,
pixbuf);
gtk_icon_theme_add_builtin_icon(progdt->palicon, MAX_ICONSIZE, pixbuf);
g_object_unref(pixbuf);
} else {
g_free(g_progdt->palicon);
g_progdt->palicon = file;
g_free(progdt->palicon);
progdt->palicon = file;
}
} else
g_free(file);
}

widget = GTK_WIDGET(g_datalist_get_data(&widset, "font-chooser-widget"));
g_free(g_progdt->font);
g_progdt->font =
g_strdup(gtk_font_chooser_get_font(GTK_FONT_CHOOSER(widget)));
g_free(progdt->font);
progdt->font = g_strdup(gtk_font_chooser_get_font(GTK_FONT_CHOOSER(widget)));

widget = GTK_WIDGET(g_datalist_get_data(&widset, "chat-check-widget"));
g_progdt->setOpenChat(
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
progdt->setOpenChat(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
widget = GTK_WIDGET(g_datalist_get_data(&widset, "statusicon-check-widget"));
g_progdt->setHideStartup(
progdt->setHideStartup(
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
widget =
GTK_WIDGET(g_datalist_get_data(&widset, "transmission-check-widget"));
g_progdt->setOpenTransmission(
progdt->setOpenTransmission(
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
widget = GTK_WIDGET(g_datalist_get_data(&widset, "enterkey-check-widget"));
g_progdt->setUseEnterKey(
progdt->setUseEnterKey(
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
widget = GTK_WIDGET(g_datalist_get_data(&widset, "history-check-widget"));
g_progdt->setClearupHistory(
progdt->setClearupHistory(
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
widget = GTK_WIDGET(g_datalist_get_data(&widset, "log-check-widget"));
g_progdt->setRecordLog(
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
progdt->setRecordLog(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
widget = GTK_WIDGET(g_datalist_get_data(&widset, "blacklist-check-widget"));
g_progdt->setOpenBlacklist(
progdt->setOpenBlacklist(
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
widget = GTK_WIDGET(g_datalist_get_data(&widset, "shared-check-widget"));
g_progdt->setProofShared(
progdt->setProofShared(
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
#if HAVE_APPINDICATOR
widget = GTK_WIDGET(g_datalist_get_data(&widset, "taskbar-check-widget"));
progdt->setHideTaskbarWhenMainWindowIconified(
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
#endif
return oss.str();
}

Expand Down
35 changes: 25 additions & 10 deletions src/iptux/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,23 @@
//
#include "config.h"
#include "MainWindow.h"

#include <cinttypes>
#include <ctime>
#include <glib/gi18n.h>
#include <glog/logging.h>
#include <string>
#include <thread>

#include "iptux-core/Const.h"
#include "iptux-utils/output.h"
#include "iptux-utils/utils.h"
#include "iptux/DataSettings.h"
#include "iptux/Application.h"
#include "iptux/DetectPal.h"
#include "iptux/DialogGroup.h"
#include "iptux/DialogPeer.h"
#include "iptux/RevisePal.h"
#include "iptux/ShareFile.h"
#include "iptux/UiHelper.h"
#include "iptux/UiModels.h"
#include "iptux/callback.h"
#include "iptux/dialog.h"
#include <ctime>
#include <glib/gi18n.h>
#include <glog/logging.h>
#include <string>
#include <thread>

using namespace std;

Expand All @@ -51,6 +47,23 @@ static const char* config_names[] = {
[CFG_INFO_STYLE] = "mwin_info_style",
};

static void main_window_on_state_event(GtkWidget* self,
GdkEvent* event,
gpointer user_data) {
GdkWindowState event_state = event->window_state.new_window_state;
MainWindow* mwin = (MainWindow*)user_data;
auto progdt = mwin->getApp()->getProgramData();

if (!progdt->isHideTaskbarWhenMainWindowIconified())
return;

if (event_state & GDK_WINDOW_STATE_ICONIFIED) {
gtk_window_set_skip_taskbar_hint(GTK_WINDOW(self), TRUE);
} else {
gtk_window_set_skip_taskbar_hint(GTK_WINDOW(self), FALSE);
}
}

/**
* 类构造函数.
*/
Expand Down Expand Up @@ -482,6 +495,8 @@ GtkWidget* MainWindow::CreateMainWindow() {
this);
g_signal_connect(window, "delete-event",
G_CALLBACK(gtk_window_iconify_on_delete), nullptr);
g_signal_connect(window, "window-state-event",
G_CALLBACK(main_window_on_state_event), this);
return window;
}

Expand Down
1 change: 0 additions & 1 deletion src/iptux/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ sources = files([
])
dependencies = [gtk_dep, jsoncpp_dep, glog_dep, gflags_dep, sigc_dep]

appindicator_dep = dependency('ayatana-appindicator3-0.1', required: get_option('appindicator'))
if appindicator_dep.found()
sources += ['AppIndicator.cpp']
dependencies += [appindicator_dep]
Expand Down
7 changes: 7 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ else
conf_data.set('SYSTEM_DARWIN', 0)
endif

appindicator_dep = dependency('ayatana-appindicator3-0.1', required: get_option('appindicator'))
if appindicator_dep.found()
conf_data.set('HAVE_APPINDICATOR', 1)
else
conf_data.set('HAVE_APPINDICATOR', 0)
endif

configure_file(
input: 'config.h.in',
output: 'config.h',
Expand Down

0 comments on commit 1e1b728

Please sign in to comment.