mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 04:18:39 +00:00
Rename GTK client files to match the classes they contain (#2073)
This also brings naming closer to Qt client which simplifies things a bit.
This commit is contained in:
@@ -15,16 +15,16 @@
|
|||||||
|
|
||||||
#include <libtransmission/transmission.h>
|
#include <libtransmission/transmission.h>
|
||||||
|
|
||||||
#include "actions.h"
|
#include "Actions.h"
|
||||||
#include "conf.h"
|
#include "Prefs.h"
|
||||||
#include "tr-core.h"
|
#include "PrefsDialog.h"
|
||||||
#include "tr-prefs.h"
|
#include "Session.h"
|
||||||
#include "util.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
TrCore* myCore = nullptr;
|
Session* myCore = nullptr;
|
||||||
|
|
||||||
void action_cb(Glib::RefPtr<Gtk::Action> const& a, void* user_data)
|
void action_cb(Glib::RefPtr<Gtk::Action> const& a, void* user_data)
|
||||||
{
|
{
|
||||||
@@ -176,7 +176,7 @@ Gtk::UIManager* myUIManager = nullptr;
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void gtr_actions_set_core(Glib::RefPtr<TrCore> const& core)
|
void gtr_actions_set_core(Glib::RefPtr<Session> const& core)
|
||||||
{
|
{
|
||||||
myCore = gtr_get_ptr(core);
|
myCore = gtr_get_ptr(core);
|
||||||
}
|
}
|
||||||
@@ -10,14 +10,14 @@
|
|||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
|
||||||
#include "tr-core.h"
|
class Session;
|
||||||
|
|
||||||
#define WINDOW_ICON "transmission-main-window-icon"
|
#define WINDOW_ICON "transmission-main-window-icon"
|
||||||
#define TRAY_ICON "transmission-tray-icon"
|
#define TRAY_ICON "transmission-tray-icon"
|
||||||
#define NOTIFICATION_ICON "transmission-notification-icon"
|
#define NOTIFICATION_ICON "transmission-notification-icon"
|
||||||
|
|
||||||
void gtr_actions_init(Glib::RefPtr<Gtk::UIManager> const& ui_manager, void* callback_user_data);
|
void gtr_actions_init(Glib::RefPtr<Gtk::UIManager> const& ui_manager, void* callback_user_data);
|
||||||
void gtr_actions_set_core(Glib::RefPtr<TrCore> const& core);
|
void gtr_actions_set_core(Glib::RefPtr<Session> const& core);
|
||||||
void gtr_actions_handler(Glib::ustring const& action_name, void* user_data);
|
void gtr_actions_handler(Glib::ustring const& action_name, void* user_data);
|
||||||
|
|
||||||
void gtr_action_activate(Glib::ustring const& action_name);
|
void gtr_action_activate(Glib::ustring const& action_name);
|
||||||
@@ -40,22 +40,22 @@
|
|||||||
#include <libtransmission/utils.h>
|
#include <libtransmission/utils.h>
|
||||||
#include <libtransmission/version.h>
|
#include <libtransmission/version.h>
|
||||||
|
|
||||||
#include "actions.h"
|
#include "Actions.h"
|
||||||
#include "application.h"
|
#include "Application.h"
|
||||||
#include "conf.h"
|
#include "DetailsDialog.h"
|
||||||
#include "details.h"
|
#include "Dialogs.h"
|
||||||
#include "dialogs.h"
|
#include "HigWorkarea.h"
|
||||||
#include "hig.h"
|
#include "MainWindow.h"
|
||||||
#include "makemeta-ui.h"
|
#include "MakeDialog.h"
|
||||||
#include "msgwin.h"
|
#include "MessageLogWindow.h"
|
||||||
#include "open-dialog.h"
|
#include "OptionsDialog.h"
|
||||||
#include "relocate.h"
|
#include "Prefs.h"
|
||||||
#include "stats.h"
|
#include "PrefsDialog.h"
|
||||||
#include "tr-core.h"
|
#include "RelocateDialog.h"
|
||||||
#include "tr-icon.h"
|
#include "Session.h"
|
||||||
#include "tr-prefs.h"
|
#include "StatsDialog.h"
|
||||||
#include "tr-window.h"
|
#include "SystemTrayIcon.h"
|
||||||
#include "util.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#define MY_CONFIG_NAME "transmission"
|
#define MY_CONFIG_NAME "transmission"
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ private:
|
|||||||
bool update_model_loop();
|
bool update_model_loop();
|
||||||
|
|
||||||
void on_core_busy(bool busy);
|
void on_core_busy(bool busy);
|
||||||
void on_core_error(TrCore::ErrorCode code, Glib::ustring const& msg);
|
void on_core_error(Session::ErrorCode code, Glib::ustring const& msg);
|
||||||
void on_add_torrent(tr_ctor* ctor);
|
void on_add_torrent(tr_ctor* ctor);
|
||||||
void on_prefs_changed(tr_quark key);
|
void on_prefs_changed(tr_quark key);
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ private:
|
|||||||
sigc::connection refresh_actions_tag_;
|
sigc::connection refresh_actions_tag_;
|
||||||
std::unique_ptr<SystemTrayIcon> icon_;
|
std::unique_ptr<SystemTrayIcon> icon_;
|
||||||
std::unique_ptr<MainWindow> wind_;
|
std::unique_ptr<MainWindow> wind_;
|
||||||
Glib::RefPtr<TrCore> core_;
|
Glib::RefPtr<Session> core_;
|
||||||
std::unique_ptr<MessageLogWindow> msgwin_;
|
std::unique_ptr<MessageLogWindow> msgwin_;
|
||||||
std::unique_ptr<PrefsDialog> prefs_;
|
std::unique_ptr<PrefsDialog> prefs_;
|
||||||
std::vector<std::string> error_list_;
|
std::vector<std::string> error_list_;
|
||||||
@@ -557,7 +557,7 @@ void Application::Impl::on_startup()
|
|||||||
|
|
||||||
gtr_pref_flag_set(TR_KEY_alt_speed_enabled, tr_sessionUsesAltSpeed(session));
|
gtr_pref_flag_set(TR_KEY_alt_speed_enabled, tr_sessionUsesAltSpeed(session));
|
||||||
gtr_pref_int_set(TR_KEY_peer_port, tr_sessionGetPeerPort(session));
|
gtr_pref_int_set(TR_KEY_peer_port, tr_sessionGetPeerPort(session));
|
||||||
core_ = TrCore::create(session);
|
core_ = Session::create(session);
|
||||||
|
|
||||||
/* init the ui manager */
|
/* init the ui manager */
|
||||||
ui_manager_ = Gtk::UIManager::create();
|
ui_manager_ = Gtk::UIManager::create();
|
||||||
@@ -958,19 +958,19 @@ void Application::Impl::flush_torrent_errors()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::Impl::on_core_error(TrCore::ErrorCode code, Glib::ustring const& msg)
|
void Application::Impl::on_core_error(Session::ErrorCode code, Glib::ustring const& msg)
|
||||||
{
|
{
|
||||||
switch (code)
|
switch (code)
|
||||||
{
|
{
|
||||||
case TrCore::ERR_ADD_TORRENT_ERR:
|
case Session::ERR_ADD_TORRENT_ERR:
|
||||||
error_list_.push_back(Glib::path_get_basename(msg));
|
error_list_.push_back(Glib::path_get_basename(msg));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TrCore::ERR_ADD_TORRENT_DUP:
|
case Session::ERR_ADD_TORRENT_DUP:
|
||||||
duplicates_list_.push_back(msg);
|
duplicates_list_.push_back(msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TrCore::ERR_NO_MORE_TORRENTS:
|
case Session::ERR_NO_MORE_TORRENTS:
|
||||||
flush_torrent_errors();
|
flush_torrent_errors();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -68,55 +68,57 @@ if(ENABLE_NLS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(${PROJECT_NAME}_SOURCES
|
set(${PROJECT_NAME}_SOURCES
|
||||||
actions.cc
|
Actions.cc
|
||||||
application.cc
|
Application.cc
|
||||||
conf.cc
|
DetailsDialog.cc
|
||||||
details.cc
|
Dialogs.cc
|
||||||
dialogs.cc
|
FaviconCache.cc
|
||||||
favicon.cc
|
FileList.cc
|
||||||
file-list.cc
|
FilterBar.cc
|
||||||
filter.cc
|
FreeSpaceLabel.cc
|
||||||
hig.cc
|
HigWorkarea.cc
|
||||||
icons.cc
|
IconCache.cc
|
||||||
main.cc
|
main.cc
|
||||||
makemeta-ui.cc
|
MainWindow.cc
|
||||||
msgwin.cc
|
MakeDialog.cc
|
||||||
notify.cc
|
MessageLogWindow.cc
|
||||||
open-dialog.cc
|
Notify.cc
|
||||||
relocate.cc
|
OptionsDialog.cc
|
||||||
stats.cc
|
Prefs.cc
|
||||||
torrent-cell-renderer.cc
|
PrefsDialog.cc
|
||||||
tr-core.cc
|
RelocateDialog.cc
|
||||||
tr-icon.cc
|
Session.cc
|
||||||
tr-prefs.cc
|
StatsDialog.cc
|
||||||
tr-window.cc
|
SystemTrayIcon.cc
|
||||||
util.cc
|
TorrentCellRenderer.cc
|
||||||
|
Utils.cc
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/transmission-resources.c
|
${CMAKE_CURRENT_BINARY_DIR}/transmission-resources.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set(${PROJECT_NAME}_HEADERS
|
set(${PROJECT_NAME}_HEADERS
|
||||||
actions.h
|
Actions.h
|
||||||
application.h
|
Application.h
|
||||||
conf.h
|
DetailsDialog.h
|
||||||
details.h
|
Dialogs.h
|
||||||
dialogs.h
|
FaviconCache.h
|
||||||
favicon.h
|
FileList.h
|
||||||
file-list.h
|
FilterBar.h
|
||||||
filter.h
|
FreeSpaceLabel.h
|
||||||
hig.h
|
HigWorkarea.h
|
||||||
icons.h
|
IconCache.h
|
||||||
makemeta-ui.h
|
MainWindow.h
|
||||||
msgwin.h
|
MakeDialog.h
|
||||||
notify.h
|
MessageLogWindow.h
|
||||||
open-dialog.h
|
Notify.h
|
||||||
relocate.h
|
OptionsDialog.h
|
||||||
stats.h
|
Prefs.h
|
||||||
torrent-cell-renderer.h
|
PrefsDialog.h
|
||||||
tr-core.h
|
RelocateDialog.h
|
||||||
tr-icon.h
|
Session.h
|
||||||
tr-prefs.h
|
StatsDialog.h
|
||||||
tr-window.h
|
SystemTrayIcon.h
|
||||||
util.h
|
TorrentCellRenderer.h
|
||||||
|
Utils.h
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/transmission-resources.h
|
${CMAKE_CURRENT_BINARY_DIR}/transmission-resources.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -20,22 +20,22 @@
|
|||||||
#include <libtransmission/transmission.h>
|
#include <libtransmission/transmission.h>
|
||||||
#include <libtransmission/utils.h> /* tr_free */
|
#include <libtransmission/utils.h> /* tr_free */
|
||||||
|
|
||||||
#include "actions.h"
|
#include "Actions.h"
|
||||||
#include "conf.h"
|
#include "DetailsDialog.h"
|
||||||
#include "details.h"
|
#include "FaviconCache.h" /* gtr_get_favicon() */
|
||||||
#include "favicon.h" /* gtr_get_favicon() */
|
#include "FileList.h"
|
||||||
#include "file-list.h"
|
#include "HigWorkarea.h"
|
||||||
#include "hig.h"
|
#include "Prefs.h"
|
||||||
#include "tr-core.h"
|
#include "PrefsDialog.h"
|
||||||
#include "tr-prefs.h"
|
#include "Session.h"
|
||||||
#include "util.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
|
|
||||||
class DetailsDialog::Impl
|
class DetailsDialog::Impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Impl(DetailsDialog& dialog, Glib::RefPtr<TrCore> const& core);
|
Impl(DetailsDialog& dialog, Glib::RefPtr<Session> const& core);
|
||||||
~Impl();
|
~Impl();
|
||||||
|
|
||||||
void set_torrents(std::vector<int> const& torrent_ids);
|
void set_torrents(std::vector<int> const& torrent_ids);
|
||||||
@@ -148,7 +148,7 @@ private:
|
|||||||
Gtk::Label* file_label_ = nullptr;
|
Gtk::Label* file_label_ = nullptr;
|
||||||
|
|
||||||
std::vector<int> ids_;
|
std::vector<int> ids_;
|
||||||
Glib::RefPtr<TrCore> const core_;
|
Glib::RefPtr<Session> const core_;
|
||||||
sigc::connection periodic_refresh_tag_;
|
sigc::connection periodic_refresh_tag_;
|
||||||
|
|
||||||
Glib::Quark const TORRENT_ID_KEY = Glib::Quark("tr-torrent-id-key");
|
Glib::Quark const TORRENT_ID_KEY = Glib::Quark("tr-torrent-id-key");
|
||||||
@@ -2570,12 +2570,12 @@ DetailsDialog::Impl::~Impl()
|
|||||||
periodic_refresh_tag_.disconnect();
|
periodic_refresh_tag_.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<DetailsDialog> DetailsDialog::create(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core)
|
std::unique_ptr<DetailsDialog> DetailsDialog::create(Gtk::Window& parent, Glib::RefPtr<Session> const& core)
|
||||||
{
|
{
|
||||||
return std::unique_ptr<DetailsDialog>(new DetailsDialog(parent, core));
|
return std::unique_ptr<DetailsDialog>(new DetailsDialog(parent, core));
|
||||||
}
|
}
|
||||||
|
|
||||||
DetailsDialog::DetailsDialog(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core)
|
DetailsDialog::DetailsDialog(Gtk::Window& parent, Glib::RefPtr<Session> const& core)
|
||||||
: Gtk::Dialog({}, parent)
|
: Gtk::Dialog({}, parent)
|
||||||
, impl_(std::make_unique<Impl>(*this, core))
|
, impl_(std::make_unique<Impl>(*this, core))
|
||||||
{
|
{
|
||||||
@@ -2583,7 +2583,7 @@ DetailsDialog::DetailsDialog(Gtk::Window& parent, Glib::RefPtr<TrCore> const& co
|
|||||||
|
|
||||||
DetailsDialog::~DetailsDialog() = default;
|
DetailsDialog::~DetailsDialog() = default;
|
||||||
|
|
||||||
DetailsDialog::Impl::Impl(DetailsDialog& dialog, Glib::RefPtr<TrCore> const& core)
|
DetailsDialog::Impl::Impl(DetailsDialog& dialog, Glib::RefPtr<Session> const& core)
|
||||||
: dialog_(dialog)
|
: dialog_(dialog)
|
||||||
, core_(core)
|
, core_(core)
|
||||||
{
|
{
|
||||||
@@ -14,19 +14,19 @@
|
|||||||
#include <glibmm.h>
|
#include <glibmm.h>
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
|
||||||
class TrCore;
|
class Session;
|
||||||
|
|
||||||
class DetailsDialog : public Gtk::Dialog
|
class DetailsDialog : public Gtk::Dialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~DetailsDialog() override;
|
~DetailsDialog() override;
|
||||||
|
|
||||||
static std::unique_ptr<DetailsDialog> create(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core);
|
static std::unique_ptr<DetailsDialog> create(Gtk::Window& parent, Glib::RefPtr<Session> const& core);
|
||||||
|
|
||||||
void set_torrents(std::vector<int> const& torrent_ids);
|
void set_torrents(std::vector<int> const& torrent_ids);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DetailsDialog(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core);
|
DetailsDialog(Gtk::Window& parent, Glib::RefPtr<Session> const& core);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Impl;
|
class Impl;
|
||||||
@@ -27,9 +27,9 @@
|
|||||||
|
|
||||||
#include <libtransmission/transmission.h>
|
#include <libtransmission/transmission.h>
|
||||||
|
|
||||||
#include "dialogs.h"
|
#include "Dialogs.h"
|
||||||
#include "tr-core.h"
|
#include "Session.h"
|
||||||
#include "util.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
/***
|
/***
|
||||||
****
|
****
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
void gtr_confirm_remove(
|
void gtr_confirm_remove(
|
||||||
Gtk::Window& parent,
|
Gtk::Window& parent,
|
||||||
Glib::RefPtr<TrCore> const& core,
|
Glib::RefPtr<Session> const& core,
|
||||||
std::vector<int> const& torrent_ids,
|
std::vector<int> const& torrent_ids,
|
||||||
bool delete_files)
|
bool delete_files)
|
||||||
{
|
{
|
||||||
@@ -26,13 +26,13 @@
|
|||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
|
||||||
class TrCore;
|
class Session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prompt the user to confirm removing a torrent.
|
* Prompt the user to confirm removing a torrent.
|
||||||
*/
|
*/
|
||||||
void gtr_confirm_remove(
|
void gtr_confirm_remove(
|
||||||
Gtk::Window& parent,
|
Gtk::Window& parent,
|
||||||
Glib::RefPtr<TrCore> const& core,
|
Glib::RefPtr<Session> const& core,
|
||||||
std::vector<int> const& torrent_ids,
|
std::vector<int> const& torrent_ids,
|
||||||
bool delete_files);
|
bool delete_files);
|
||||||
@@ -13,8 +13,8 @@
|
|||||||
#include <libtransmission/transmission.h>
|
#include <libtransmission/transmission.h>
|
||||||
#include <libtransmission/web.h> /* tr_webRun() */
|
#include <libtransmission/web.h> /* tr_webRun() */
|
||||||
|
|
||||||
#include "favicon.h"
|
#include "FaviconCache.h"
|
||||||
#include "util.h" /* gtr_get_host_from_url() */
|
#include "Utils.h" /* gtr_get_host_from_url() */
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -17,12 +17,12 @@
|
|||||||
#include <libtransmission/transmission.h>
|
#include <libtransmission/transmission.h>
|
||||||
#include <libtransmission/utils.h>
|
#include <libtransmission/utils.h>
|
||||||
|
|
||||||
#include "file-list.h"
|
#include "FileList.h"
|
||||||
#include "hig.h"
|
#include "HigWorkarea.h"
|
||||||
#include "icons.h"
|
#include "IconCache.h"
|
||||||
#include "tr-core.h"
|
#include "PrefsDialog.h"
|
||||||
#include "tr-prefs.h"
|
#include "Session.h"
|
||||||
#include "util.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#define TR_COLUMN_ID_KEY "tr-model-column-id-key"
|
#define TR_COLUMN_ID_KEY "tr-model-column-id-key"
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ FileModelColumns const file_cols;
|
|||||||
class FileList::Impl
|
class FileList::Impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Impl(FileList& widget, Glib::RefPtr<TrCore> const& core, int torrent_id);
|
Impl(FileList& widget, Glib::RefPtr<Session> const& core, int torrent_id);
|
||||||
~Impl();
|
~Impl();
|
||||||
|
|
||||||
void set_torrent(int torrent_id);
|
void set_torrent(int torrent_id);
|
||||||
@@ -97,7 +97,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
FileList& widget_;
|
FileList& widget_;
|
||||||
|
|
||||||
Glib::RefPtr<TrCore> const core_;
|
Glib::RefPtr<Session> const core_;
|
||||||
// GtkWidget* top_ = nullptr; // == widget_
|
// GtkWidget* top_ = nullptr; // == widget_
|
||||||
Gtk::TreeView* view_ = nullptr;
|
Gtk::TreeView* view_ = nullptr;
|
||||||
Glib::RefPtr<Gtk::TreeStore> store_;
|
Glib::RefPtr<Gtk::TreeStore> store_;
|
||||||
@@ -815,13 +815,13 @@ void FileList::Impl::cell_edited_callback(Glib::ustring const& path_string, Glib
|
|||||||
rename_data);
|
rename_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileList::FileList(Glib::RefPtr<TrCore> const& core, int torrent_id)
|
FileList::FileList(Glib::RefPtr<Session> const& core, int torrent_id)
|
||||||
: Gtk::ScrolledWindow()
|
: Gtk::ScrolledWindow()
|
||||||
, impl_(std::make_unique<Impl>(*this, core, torrent_id))
|
, impl_(std::make_unique<Impl>(*this, core, torrent_id))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FileList::Impl::Impl(FileList& widget, Glib::RefPtr<TrCore> const& core, int torrent_id)
|
FileList::Impl::Impl(FileList& widget, Glib::RefPtr<Session> const& core, int torrent_id)
|
||||||
: widget_(widget)
|
: widget_(widget)
|
||||||
, core_(core)
|
, core_(core)
|
||||||
{
|
{
|
||||||
@@ -12,12 +12,12 @@
|
|||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
|
||||||
class TrCore;
|
class Session;
|
||||||
|
|
||||||
class FileList : public Gtk::ScrolledWindow
|
class FileList : public Gtk::ScrolledWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileList(Glib::RefPtr<TrCore> const& core, int torrent_id);
|
FileList(Glib::RefPtr<Session> const& core, int torrent_id);
|
||||||
~FileList() override;
|
~FileList() override;
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
@@ -16,11 +16,11 @@
|
|||||||
#include <libtransmission/transmission.h>
|
#include <libtransmission/transmission.h>
|
||||||
#include <libtransmission/utils.h>
|
#include <libtransmission/utils.h>
|
||||||
|
|
||||||
#include "favicon.h" /* gtr_get_favicon() */
|
#include "FaviconCache.h" /* gtr_get_favicon() */
|
||||||
#include "filter.h"
|
#include "FilterBar.h"
|
||||||
#include "hig.h" /* GUI_PAD */
|
#include "HigWorkarea.h" /* GUI_PAD */
|
||||||
#include "tr-core.h" /* MC_TORRENT */
|
#include "Session.h" /* MC_TORRENT */
|
||||||
#include "util.h" /* gtr_get_host_from_url() */
|
#include "Utils.h" /* gtr_get_host_from_url() */
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
80
gtk/FreeSpaceLabel.cc
Normal file
80
gtk/FreeSpaceLabel.cc
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* This file Copyright (C) 2008-2021 Mnemosyne LLC
|
||||||
|
*
|
||||||
|
* It may be used under the GNU GPL versions 2 or 3
|
||||||
|
* or any future license endorsed by Mnemosyne LLC.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <glibmm/i18n.h>
|
||||||
|
|
||||||
|
#include "FreeSpaceLabel.h"
|
||||||
|
#include "Session.h"
|
||||||
|
#include "Utils.h"
|
||||||
|
|
||||||
|
class FreeSpaceLabel::Impl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Impl(FreeSpaceLabel& label, Glib::RefPtr<Session> const& core, std::string const& dir);
|
||||||
|
~Impl();
|
||||||
|
|
||||||
|
void set_dir(std::string const& dir);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool on_freespace_timer();
|
||||||
|
|
||||||
|
private:
|
||||||
|
FreeSpaceLabel& label_;
|
||||||
|
Glib::RefPtr<Session> const core_;
|
||||||
|
std::string dir_;
|
||||||
|
sigc::connection timer_id_;
|
||||||
|
};
|
||||||
|
|
||||||
|
FreeSpaceLabel::Impl::~Impl()
|
||||||
|
{
|
||||||
|
timer_id_.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FreeSpaceLabel::Impl::on_freespace_timer()
|
||||||
|
{
|
||||||
|
auto* const session = core_->get_session();
|
||||||
|
if (session == nullptr)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto const bytes = tr_sessionGetDirFreeSpace(session, dir_.c_str());
|
||||||
|
auto const text = bytes < 0 ? _("Error") : gtr_sprintf(_("%s free"), tr_strlsize(bytes));
|
||||||
|
auto const markup = gtr_sprintf("<i>%s</i>", text);
|
||||||
|
label_.set_markup(markup);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
FreeSpaceLabel::FreeSpaceLabel(Glib::RefPtr<Session> const& core, std::string const& dir)
|
||||||
|
: Gtk::Label()
|
||||||
|
, impl_(std::make_unique<Impl>(*this, core, dir))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
FreeSpaceLabel::~FreeSpaceLabel() = default;
|
||||||
|
|
||||||
|
FreeSpaceLabel::Impl::Impl(FreeSpaceLabel& label, Glib::RefPtr<Session> const& core, std::string const& dir)
|
||||||
|
: label_(label)
|
||||||
|
, core_(core)
|
||||||
|
, dir_(dir)
|
||||||
|
{
|
||||||
|
timer_id_ = Glib::signal_timeout().connect_seconds(sigc::mem_fun(this, &Impl::on_freespace_timer), 3);
|
||||||
|
on_freespace_timer();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FreeSpaceLabel::set_dir(std::string const& dir)
|
||||||
|
{
|
||||||
|
impl_->set_dir(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FreeSpaceLabel::Impl::set_dir(std::string const& dir)
|
||||||
|
{
|
||||||
|
dir_ = dir;
|
||||||
|
on_freespace_timer();
|
||||||
|
}
|
||||||
28
gtk/FreeSpaceLabel.h
Normal file
28
gtk/FreeSpaceLabel.h
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* This file Copyright (C) 2008-2021 Mnemosyne LLC
|
||||||
|
*
|
||||||
|
* It may be used under the GNU GPL versions 2 or 3
|
||||||
|
* or any future license endorsed by Mnemosyne LLC.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <glibmm.h>
|
||||||
|
#include <gtkmm.h>
|
||||||
|
|
||||||
|
class Session;
|
||||||
|
|
||||||
|
class FreeSpaceLabel : public Gtk::Label
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FreeSpaceLabel(Glib::RefPtr<Session> const& core, std::string const& dir = {});
|
||||||
|
~FreeSpaceLabel() override;
|
||||||
|
|
||||||
|
void set_dir(std::string const& dir);
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
std::unique_ptr<Impl> const impl_;
|
||||||
|
};
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
#include <libtransmission/tr-macros.h>
|
#include <libtransmission/tr-macros.h>
|
||||||
|
|
||||||
#include "hig.h"
|
#include "HigWorkarea.h"
|
||||||
#include "util.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
HigWorkarea::HigWorkarea()
|
HigWorkarea::HigWorkarea()
|
||||||
{
|
{
|
||||||
@@ -11,8 +11,8 @@
|
|||||||
#include <glibmm.h>
|
#include <glibmm.h>
|
||||||
#include <giomm.h>
|
#include <giomm.h>
|
||||||
|
|
||||||
#include "icons.h"
|
#include "IconCache.h"
|
||||||
#include "util.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#define VOID_PIXBUF_KEY "void-pixbuf"
|
#define VOID_PIXBUF_KEY "void-pixbuf"
|
||||||
|
|
||||||
@@ -27,20 +27,20 @@
|
|||||||
#include <libtransmission/transmission.h>
|
#include <libtransmission/transmission.h>
|
||||||
#include <libtransmission/utils.h> /* tr_formatter_speed_KBps() */
|
#include <libtransmission/utils.h> /* tr_formatter_speed_KBps() */
|
||||||
|
|
||||||
#include "actions.h"
|
#include "Actions.h"
|
||||||
#include "conf.h"
|
#include "FilterBar.h"
|
||||||
#include "filter.h"
|
#include "HigWorkarea.h"
|
||||||
#include "hig.h"
|
#include "MainWindow.h"
|
||||||
#include "torrent-cell-renderer.h"
|
#include "Prefs.h"
|
||||||
#include "tr-core.h"
|
#include "PrefsDialog.h"
|
||||||
#include "tr-prefs.h"
|
#include "Session.h"
|
||||||
#include "tr-window.h"
|
#include "TorrentCellRenderer.h"
|
||||||
#include "util.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
class MainWindow::Impl
|
class MainWindow::Impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Impl(MainWindow& window, Glib::RefPtr<Gtk::UIManager> const& ui_mgr, Glib::RefPtr<TrCore> const& core);
|
Impl(MainWindow& window, Glib::RefPtr<Gtk::UIManager> const& ui_mgr, Glib::RefPtr<Session> const& core);
|
||||||
~Impl();
|
~Impl();
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::TreeSelection> get_selection() const;
|
Glib::RefPtr<Gtk::TreeSelection> get_selection() const;
|
||||||
@@ -94,7 +94,7 @@ private:
|
|||||||
Glib::RefPtr<Gtk::TreeSelection> selection_;
|
Glib::RefPtr<Gtk::TreeSelection> selection_;
|
||||||
TorrentCellRenderer* renderer_ = nullptr;
|
TorrentCellRenderer* renderer_ = nullptr;
|
||||||
Gtk::TreeViewColumn* column_ = nullptr;
|
Gtk::TreeViewColumn* column_ = nullptr;
|
||||||
Glib::RefPtr<TrCore> const core_;
|
Glib::RefPtr<Session> const core_;
|
||||||
sigc::connection pref_handler_id_;
|
sigc::connection pref_handler_id_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -449,12 +449,12 @@ void MainWindow::Impl::onOptionsClicked(Gtk::Button* button)
|
|||||||
std::unique_ptr<MainWindow> MainWindow::create(
|
std::unique_ptr<MainWindow> MainWindow::create(
|
||||||
Gtk::Application& app,
|
Gtk::Application& app,
|
||||||
Glib::RefPtr<Gtk::UIManager> const& uim,
|
Glib::RefPtr<Gtk::UIManager> const& uim,
|
||||||
Glib::RefPtr<TrCore> const& core)
|
Glib::RefPtr<Session> const& core)
|
||||||
{
|
{
|
||||||
return std::unique_ptr<MainWindow>(new MainWindow(app, uim, core));
|
return std::unique_ptr<MainWindow>(new MainWindow(app, uim, core));
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::MainWindow(Gtk::Application& app, Glib::RefPtr<Gtk::UIManager> const& ui_mgr, Glib::RefPtr<TrCore> const& core)
|
MainWindow::MainWindow(Gtk::Application& app, Glib::RefPtr<Gtk::UIManager> const& ui_mgr, Glib::RefPtr<Session> const& core)
|
||||||
: Gtk::ApplicationWindow()
|
: Gtk::ApplicationWindow()
|
||||||
, impl_(std::make_unique<Impl>(*this, ui_mgr, core))
|
, impl_(std::make_unique<Impl>(*this, ui_mgr, core))
|
||||||
{
|
{
|
||||||
@@ -463,7 +463,7 @@ MainWindow::MainWindow(Gtk::Application& app, Glib::RefPtr<Gtk::UIManager> const
|
|||||||
|
|
||||||
MainWindow::~MainWindow() = default;
|
MainWindow::~MainWindow() = default;
|
||||||
|
|
||||||
MainWindow::Impl::Impl(MainWindow& window, Glib::RefPtr<Gtk::UIManager> const& ui_mgr, Glib::RefPtr<TrCore> const& core)
|
MainWindow::Impl::Impl(MainWindow& window, Glib::RefPtr<Gtk::UIManager> const& ui_mgr, Glib::RefPtr<Session> const& core)
|
||||||
: core_(core)
|
: core_(core)
|
||||||
{
|
{
|
||||||
static struct
|
static struct
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
#include <glibmm.h>
|
#include <glibmm.h>
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
|
||||||
class TrCore;
|
class Session;
|
||||||
|
|
||||||
class MainWindow : public Gtk::ApplicationWindow
|
class MainWindow : public Gtk::ApplicationWindow
|
||||||
{
|
{
|
||||||
@@ -37,7 +37,7 @@ public:
|
|||||||
static std::unique_ptr<MainWindow> create(
|
static std::unique_ptr<MainWindow> create(
|
||||||
Gtk::Application& app,
|
Gtk::Application& app,
|
||||||
Glib::RefPtr<Gtk::UIManager> const& uim,
|
Glib::RefPtr<Gtk::UIManager> const& uim,
|
||||||
Glib::RefPtr<TrCore> const& core);
|
Glib::RefPtr<Session> const& core);
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::TreeSelection> get_selection() const;
|
Glib::RefPtr<Gtk::TreeSelection> get_selection() const;
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
void refresh();
|
void refresh();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MainWindow(Gtk::Application& app, Glib::RefPtr<Gtk::UIManager> const& uim, Glib::RefPtr<TrCore> const& core);
|
MainWindow(Gtk::Application& app, Glib::RefPtr<Gtk::UIManager> const& uim, Glib::RefPtr<Session> const& core);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Impl;
|
class Impl;
|
||||||
@@ -13,11 +13,11 @@
|
|||||||
#include <libtransmission/makemeta.h>
|
#include <libtransmission/makemeta.h>
|
||||||
#include <libtransmission/utils.h> /* tr_formatter_mem_B() */
|
#include <libtransmission/utils.h> /* tr_formatter_mem_B() */
|
||||||
|
|
||||||
#include "hig.h"
|
#include "HigWorkarea.h"
|
||||||
#include "makemeta-ui.h"
|
#include "MakeDialog.h"
|
||||||
#include "tr-core.h"
|
#include "PrefsDialog.h"
|
||||||
#include "tr-prefs.h"
|
#include "Session.h"
|
||||||
#include "util.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#define FILE_CHOSEN_KEY "file-is-chosen"
|
#define FILE_CHOSEN_KEY "file-is-chosen"
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ public:
|
|||||||
Gtk::Window& parent,
|
Gtk::Window& parent,
|
||||||
tr_metainfo_builder& builder,
|
tr_metainfo_builder& builder,
|
||||||
std::string const& target,
|
std::string const& target,
|
||||||
Glib::RefPtr<TrCore> const& core);
|
Glib::RefPtr<Session> const& core);
|
||||||
~MakeProgressDialog() override;
|
~MakeProgressDialog() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -43,7 +43,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
tr_metainfo_builder& builder_;
|
tr_metainfo_builder& builder_;
|
||||||
std::string const target_;
|
std::string const target_;
|
||||||
Glib::RefPtr<TrCore> const core_;
|
Glib::RefPtr<Session> const core_;
|
||||||
|
|
||||||
sigc::connection progress_tag_;
|
sigc::connection progress_tag_;
|
||||||
Gtk::Label* progress_label_ = nullptr;
|
Gtk::Label* progress_label_ = nullptr;
|
||||||
@@ -55,7 +55,7 @@ private:
|
|||||||
class MakeDialog::Impl
|
class MakeDialog::Impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Impl(MakeDialog& dialog, Glib::RefPtr<TrCore> const& core);
|
Impl(MakeDialog& dialog, Glib::RefPtr<Session> const& core);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onSourceToggled2(Gtk::ToggleButton* tb, Gtk::FileChooserButton* chooser);
|
void onSourceToggled2(Gtk::ToggleButton* tb, Gtk::FileChooserButton* chooser);
|
||||||
@@ -78,7 +78,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
MakeDialog& dialog_;
|
MakeDialog& dialog_;
|
||||||
Glib::RefPtr<TrCore> const core_;
|
Glib::RefPtr<Session> const core_;
|
||||||
|
|
||||||
Gtk::RadioButton* file_radio_ = nullptr;
|
Gtk::RadioButton* file_radio_ = nullptr;
|
||||||
Gtk::FileChooserButton* file_chooser_ = nullptr;
|
Gtk::FileChooserButton* file_chooser_ = nullptr;
|
||||||
@@ -195,7 +195,7 @@ MakeProgressDialog::MakeProgressDialog(
|
|||||||
Gtk::Window& parent,
|
Gtk::Window& parent,
|
||||||
tr_metainfo_builder& builder,
|
tr_metainfo_builder& builder,
|
||||||
std::string const& target,
|
std::string const& target,
|
||||||
Glib::RefPtr<TrCore> const& core)
|
Glib::RefPtr<Session> const& core)
|
||||||
: Gtk::Dialog(_("New Torrent"), parent, true)
|
: Gtk::Dialog(_("New Torrent"), parent, true)
|
||||||
, builder_(builder)
|
, builder_(builder)
|
||||||
, target_(target)
|
, target_(target)
|
||||||
@@ -415,12 +415,12 @@ void MakeDialog::Impl::on_drag_data_received(
|
|||||||
drag_context->drag_finish(success, false, time_);
|
drag_context->drag_finish(success, false, time_);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<MakeDialog> MakeDialog::create(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core)
|
std::unique_ptr<MakeDialog> MakeDialog::create(Gtk::Window& parent, Glib::RefPtr<Session> const& core)
|
||||||
{
|
{
|
||||||
return std::unique_ptr<MakeDialog>(new MakeDialog(parent, core));
|
return std::unique_ptr<MakeDialog>(new MakeDialog(parent, core));
|
||||||
}
|
}
|
||||||
|
|
||||||
MakeDialog::MakeDialog(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core)
|
MakeDialog::MakeDialog(Gtk::Window& parent, Glib::RefPtr<Session> const& core)
|
||||||
: Gtk::Dialog(_("New Torrent"), parent)
|
: Gtk::Dialog(_("New Torrent"), parent)
|
||||||
, impl_(std::make_unique<Impl>(*this, core))
|
, impl_(std::make_unique<Impl>(*this, core))
|
||||||
{
|
{
|
||||||
@@ -428,7 +428,7 @@ MakeDialog::MakeDialog(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core)
|
|||||||
|
|
||||||
MakeDialog::~MakeDialog() = default;
|
MakeDialog::~MakeDialog() = default;
|
||||||
|
|
||||||
MakeDialog::Impl::Impl(MakeDialog& dialog, Glib::RefPtr<TrCore> const& core)
|
MakeDialog::Impl::Impl(MakeDialog& dialog, Glib::RefPtr<Session> const& core)
|
||||||
: dialog_(dialog)
|
: dialog_(dialog)
|
||||||
, core_(core)
|
, core_(core)
|
||||||
{
|
{
|
||||||
@@ -12,17 +12,17 @@
|
|||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
|
||||||
class TrCore;
|
class Session;
|
||||||
|
|
||||||
class MakeDialog : public Gtk::Dialog
|
class MakeDialog : public Gtk::Dialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~MakeDialog() override;
|
~MakeDialog() override;
|
||||||
|
|
||||||
static std::unique_ptr<MakeDialog> create(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core);
|
static std::unique_ptr<MakeDialog> create(Gtk::Window& parent, Glib::RefPtr<Session> const& core);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MakeDialog(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core);
|
MakeDialog(Gtk::Window& parent, Glib::RefPtr<Session> const& core);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Impl;
|
class Impl;
|
||||||
@@ -16,12 +16,12 @@
|
|||||||
#include <libtransmission/transmission.h>
|
#include <libtransmission/transmission.h>
|
||||||
#include <libtransmission/log.h>
|
#include <libtransmission/log.h>
|
||||||
|
|
||||||
#include "conf.h"
|
#include "HigWorkarea.h"
|
||||||
#include "hig.h"
|
#include "MessageLogWindow.h"
|
||||||
#include "msgwin.h"
|
#include "Prefs.h"
|
||||||
#include "tr-core.h"
|
#include "PrefsDialog.h"
|
||||||
#include "tr-prefs.h"
|
#include "Session.h"
|
||||||
#include "util.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
class MessageLogColumnsModel : public Gtk::TreeModelColumnRecord
|
class MessageLogColumnsModel : public Gtk::TreeModelColumnRecord
|
||||||
{
|
{
|
||||||
@@ -45,7 +45,7 @@ MessageLogColumnsModel const message_log_cols;
|
|||||||
class MessageLogWindow::Impl
|
class MessageLogWindow::Impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Impl(MessageLogWindow& window, Glib::RefPtr<TrCore> const& core);
|
Impl(MessageLogWindow& window, Glib::RefPtr<Session> const& core);
|
||||||
~Impl();
|
~Impl();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -67,7 +67,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
MessageLogWindow& window_;
|
MessageLogWindow& window_;
|
||||||
|
|
||||||
Glib::RefPtr<TrCore> const core_;
|
Glib::RefPtr<Session> const core_;
|
||||||
Gtk::TreeView* view_ = nullptr;
|
Gtk::TreeView* view_ = nullptr;
|
||||||
Glib::RefPtr<Gtk::ListStore> store_;
|
Glib::RefPtr<Gtk::ListStore> store_;
|
||||||
Glib::RefPtr<Gtk::TreeModelFilter> filter_;
|
Glib::RefPtr<Gtk::TreeModelFilter> filter_;
|
||||||
@@ -429,12 +429,12 @@ Gtk::ComboBox* debug_level_combo_new()
|
|||||||
*** Public Functions
|
*** Public Functions
|
||||||
**/
|
**/
|
||||||
|
|
||||||
std::unique_ptr<MessageLogWindow> MessageLogWindow::create(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core)
|
std::unique_ptr<MessageLogWindow> MessageLogWindow::create(Gtk::Window& parent, Glib::RefPtr<Session> const& core)
|
||||||
{
|
{
|
||||||
return std::unique_ptr<MessageLogWindow>(new MessageLogWindow(parent, core));
|
return std::unique_ptr<MessageLogWindow>(new MessageLogWindow(parent, core));
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageLogWindow::MessageLogWindow(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core)
|
MessageLogWindow::MessageLogWindow(Gtk::Window& parent, Glib::RefPtr<Session> const& core)
|
||||||
: Gtk::Window(Gtk::WINDOW_TOPLEVEL)
|
: Gtk::Window(Gtk::WINDOW_TOPLEVEL)
|
||||||
, impl_(std::make_unique<Impl>(*this, core))
|
, impl_(std::make_unique<Impl>(*this, core))
|
||||||
{
|
{
|
||||||
@@ -443,7 +443,7 @@ MessageLogWindow::MessageLogWindow(Gtk::Window& parent, Glib::RefPtr<TrCore> con
|
|||||||
|
|
||||||
MessageLogWindow::~MessageLogWindow() = default;
|
MessageLogWindow::~MessageLogWindow() = default;
|
||||||
|
|
||||||
MessageLogWindow::Impl::Impl(MessageLogWindow& window, Glib::RefPtr<TrCore> const& core)
|
MessageLogWindow::Impl::Impl(MessageLogWindow& window, Glib::RefPtr<Session> const& core)
|
||||||
: window_(window)
|
: window_(window)
|
||||||
, core_(core)
|
, core_(core)
|
||||||
{
|
{
|
||||||
@@ -12,17 +12,17 @@
|
|||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
|
||||||
class TrCore;
|
class Session;
|
||||||
|
|
||||||
class MessageLogWindow : public Gtk::Window
|
class MessageLogWindow : public Gtk::Window
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~MessageLogWindow() override;
|
~MessageLogWindow() override;
|
||||||
|
|
||||||
static std::unique_ptr<MessageLogWindow> create(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core);
|
static std::unique_ptr<MessageLogWindow> create(Gtk::Window& parent, Glib::RefPtr<Session> const& core);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MessageLogWindow(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core);
|
MessageLogWindow(Gtk::Window& parent, Glib::RefPtr<Session> const& core);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Impl;
|
class Impl;
|
||||||
@@ -11,11 +11,11 @@
|
|||||||
#include <giomm.h>
|
#include <giomm.h>
|
||||||
#include <glibmm/i18n.h>
|
#include <glibmm/i18n.h>
|
||||||
|
|
||||||
#include "conf.h"
|
#include "Notify.h"
|
||||||
#include "notify.h"
|
#include "Prefs.h"
|
||||||
#include "tr-core.h"
|
#include "PrefsDialog.h"
|
||||||
#include "tr-prefs.h"
|
#include "Session.h"
|
||||||
#include "util.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#define NOTIFICATIONS_DBUS_NAME "org.freedesktop.Notifications"
|
#define NOTIFICATIONS_DBUS_NAME "org.freedesktop.Notifications"
|
||||||
#define NOTIFICATIONS_DBUS_CORE_OBJECT "/org/freedesktop/Notifications"
|
#define NOTIFICATIONS_DBUS_CORE_OBJECT "/org/freedesktop/Notifications"
|
||||||
@@ -30,7 +30,7 @@ namespace
|
|||||||
|
|
||||||
struct TrNotification
|
struct TrNotification
|
||||||
{
|
{
|
||||||
Glib::RefPtr<TrCore> core;
|
Glib::RefPtr<Session> core;
|
||||||
int torrent_id = 0;
|
int torrent_id = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ void notify_callback(Glib::RefPtr<Gio::AsyncResult>& res, TrNotification const&
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void gtr_notify_torrent_completed(Glib::RefPtr<TrCore> const& core, int torrent_id)
|
void gtr_notify_torrent_completed(Glib::RefPtr<Session> const& core, int torrent_id)
|
||||||
{
|
{
|
||||||
if (gtr_pref_flag_get(TR_KEY_torrent_complete_sound_enabled))
|
if (gtr_pref_flag_get(TR_KEY_torrent_complete_sound_enabled))
|
||||||
{
|
{
|
||||||
@@ -10,10 +10,10 @@
|
|||||||
|
|
||||||
#include <glibmm.h>
|
#include <glibmm.h>
|
||||||
|
|
||||||
class TrCore;
|
class Session;
|
||||||
|
|
||||||
void gtr_notify_init();
|
void gtr_notify_init();
|
||||||
|
|
||||||
void gtr_notify_torrent_added(Glib::ustring const& name);
|
void gtr_notify_torrent_added(Glib::ustring const& name);
|
||||||
|
|
||||||
void gtr_notify_torrent_completed(Glib::RefPtr<TrCore> const& core, int torrent_id);
|
void gtr_notify_torrent_completed(Glib::RefPtr<Session> const& core, int torrent_id);
|
||||||
@@ -15,13 +15,14 @@
|
|||||||
#include <libtransmission/transmission.h>
|
#include <libtransmission/transmission.h>
|
||||||
#include <libtransmission/file.h> /* tr_sys_path_is_same() */
|
#include <libtransmission/file.h> /* tr_sys_path_is_same() */
|
||||||
|
|
||||||
#include "conf.h"
|
#include "FileList.h"
|
||||||
#include "file-list.h"
|
#include "FreeSpaceLabel.h"
|
||||||
#include "hig.h"
|
#include "HigWorkarea.h"
|
||||||
#include "open-dialog.h"
|
#include "OptionsDialog.h"
|
||||||
#include "tr-core.h"
|
#include "Prefs.h"
|
||||||
#include "tr-prefs.h"
|
#include "PrefsDialog.h"
|
||||||
#include "util.h" /* gtr_priority_combo_get_value() */
|
#include "Session.h"
|
||||||
|
#include "Utils.h" /* gtr_priority_combo_get_value() */
|
||||||
|
|
||||||
/****
|
/****
|
||||||
*****
|
*****
|
||||||
@@ -49,7 +50,7 @@ std::list<std::string> get_recent_destinations()
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
void save_recent_destination(Glib::RefPtr<TrCore> const& core, std::string const& dir)
|
void save_recent_destination(Glib::RefPtr<Session> const& core, std::string const& dir)
|
||||||
{
|
{
|
||||||
if (dir.empty())
|
if (dir.empty())
|
||||||
{
|
{
|
||||||
@@ -85,7 +86,7 @@ void save_recent_destination(Glib::RefPtr<TrCore> const& core, std::string const
|
|||||||
class OptionsDialog::Impl
|
class OptionsDialog::Impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Impl(OptionsDialog& dialog, Glib::RefPtr<TrCore> const& core, std::unique_ptr<tr_ctor, void (*)(tr_ctor*)> ctor);
|
Impl(OptionsDialog& dialog, Glib::RefPtr<Session> const& core, std::unique_ptr<tr_ctor, void (*)(tr_ctor*)> ctor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void sourceChanged(Gtk::FileChooserButton* b);
|
void sourceChanged(Gtk::FileChooserButton* b);
|
||||||
@@ -99,7 +100,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
OptionsDialog& dialog_;
|
OptionsDialog& dialog_;
|
||||||
|
|
||||||
Glib::RefPtr<TrCore> const core_;
|
Glib::RefPtr<Session> const core_;
|
||||||
FileList* file_list_ = nullptr;
|
FileList* file_list_ = nullptr;
|
||||||
Gtk::CheckButton* run_check_ = nullptr;
|
Gtk::CheckButton* run_check_ = nullptr;
|
||||||
Gtk::CheckButton* trash_check_ = nullptr;
|
Gtk::CheckButton* trash_check_ = nullptr;
|
||||||
@@ -253,7 +254,7 @@ void addTorrentFilters(Gtk::FileChooser* chooser)
|
|||||||
|
|
||||||
std::unique_ptr<OptionsDialog> OptionsDialog::create(
|
std::unique_ptr<OptionsDialog> OptionsDialog::create(
|
||||||
Gtk::Window& parent,
|
Gtk::Window& parent,
|
||||||
Glib::RefPtr<TrCore> const& core,
|
Glib::RefPtr<Session> const& core,
|
||||||
std::unique_ptr<tr_ctor, void (*)(tr_ctor*)> ctor)
|
std::unique_ptr<tr_ctor, void (*)(tr_ctor*)> ctor)
|
||||||
{
|
{
|
||||||
return std::unique_ptr<OptionsDialog>(new OptionsDialog(parent, core, std::move(ctor)));
|
return std::unique_ptr<OptionsDialog>(new OptionsDialog(parent, core, std::move(ctor)));
|
||||||
@@ -261,7 +262,7 @@ std::unique_ptr<OptionsDialog> OptionsDialog::create(
|
|||||||
|
|
||||||
OptionsDialog::OptionsDialog(
|
OptionsDialog::OptionsDialog(
|
||||||
Gtk::Window& parent,
|
Gtk::Window& parent,
|
||||||
Glib::RefPtr<TrCore> const& core,
|
Glib::RefPtr<Session> const& core,
|
||||||
std::unique_ptr<tr_ctor, void (*)(tr_ctor*)> ctor)
|
std::unique_ptr<tr_ctor, void (*)(tr_ctor*)> ctor)
|
||||||
: Gtk::Dialog(_("Torrent Options"), parent)
|
: Gtk::Dialog(_("Torrent Options"), parent)
|
||||||
, impl_(std::make_unique<Impl>(*this, core, std::move(ctor)))
|
, impl_(std::make_unique<Impl>(*this, core, std::move(ctor)))
|
||||||
@@ -272,7 +273,7 @@ OptionsDialog::~OptionsDialog() = default;
|
|||||||
|
|
||||||
OptionsDialog::Impl::Impl(
|
OptionsDialog::Impl::Impl(
|
||||||
OptionsDialog& dialog,
|
OptionsDialog& dialog,
|
||||||
Glib::RefPtr<TrCore> const& core,
|
Glib::RefPtr<Session> const& core,
|
||||||
std::unique_ptr<tr_ctor, void (*)(tr_ctor*)> ctor)
|
std::unique_ptr<tr_ctor, void (*)(tr_ctor*)> ctor)
|
||||||
: dialog_(dialog)
|
: dialog_(dialog)
|
||||||
, core_(core)
|
, core_(core)
|
||||||
@@ -410,7 +411,7 @@ OptionsDialog::Impl::Impl(
|
|||||||
*****
|
*****
|
||||||
****/
|
****/
|
||||||
|
|
||||||
void TorrentFileChooserDialog::onOpenDialogResponse(int response, Glib::RefPtr<TrCore> const& core)
|
void TorrentFileChooserDialog::onOpenDialogResponse(int response, Glib::RefPtr<Session> const& core)
|
||||||
{
|
{
|
||||||
/* remember this folder the next time we use this dialog */
|
/* remember this folder the next time we use this dialog */
|
||||||
gtr_pref_string_set(TR_KEY_open_dialog_dir, get_current_folder());
|
gtr_pref_string_set(TR_KEY_open_dialog_dir, get_current_folder());
|
||||||
@@ -431,12 +432,12 @@ void TorrentFileChooserDialog::onOpenDialogResponse(int response, Glib::RefPtr<T
|
|||||||
|
|
||||||
std::unique_ptr<TorrentFileChooserDialog> TorrentFileChooserDialog::create(
|
std::unique_ptr<TorrentFileChooserDialog> TorrentFileChooserDialog::create(
|
||||||
Gtk::Window& parent,
|
Gtk::Window& parent,
|
||||||
Glib::RefPtr<TrCore> const& core)
|
Glib::RefPtr<Session> const& core)
|
||||||
{
|
{
|
||||||
return std::unique_ptr<TorrentFileChooserDialog>(new TorrentFileChooserDialog(parent, core));
|
return std::unique_ptr<TorrentFileChooserDialog>(new TorrentFileChooserDialog(parent, core));
|
||||||
}
|
}
|
||||||
|
|
||||||
TorrentFileChooserDialog::TorrentFileChooserDialog(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core)
|
TorrentFileChooserDialog::TorrentFileChooserDialog(Gtk::Window& parent, Glib::RefPtr<Session> const& core)
|
||||||
: Gtk::FileChooserDialog(parent, _("Open a Torrent"), Gtk::FILE_CHOOSER_ACTION_OPEN)
|
: Gtk::FileChooserDialog(parent, _("Open a Torrent"), Gtk::FILE_CHOOSER_ACTION_OPEN)
|
||||||
{
|
{
|
||||||
add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
|
add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
|
||||||
@@ -461,7 +462,7 @@ TorrentFileChooserDialog::TorrentFileChooserDialog(Gtk::Window& parent, Glib::Re
|
|||||||
****
|
****
|
||||||
***/
|
***/
|
||||||
|
|
||||||
void TorrentUrlChooserDialog::onOpenURLResponse(int response, Glib::RefPtr<TrCore> const& core)
|
void TorrentUrlChooserDialog::onOpenURLResponse(int response, Glib::RefPtr<Session> const& core)
|
||||||
{
|
{
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
|
|
||||||
@@ -491,12 +492,12 @@ void TorrentUrlChooserDialog::onOpenURLResponse(int response, Glib::RefPtr<TrCor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<TorrentUrlChooserDialog> TorrentUrlChooserDialog::create(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core)
|
std::unique_ptr<TorrentUrlChooserDialog> TorrentUrlChooserDialog::create(Gtk::Window& parent, Glib::RefPtr<Session> const& core)
|
||||||
{
|
{
|
||||||
return std::unique_ptr<TorrentUrlChooserDialog>(new TorrentUrlChooserDialog(parent, core));
|
return std::unique_ptr<TorrentUrlChooserDialog>(new TorrentUrlChooserDialog(parent, core));
|
||||||
}
|
}
|
||||||
|
|
||||||
TorrentUrlChooserDialog::TorrentUrlChooserDialog(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core)
|
TorrentUrlChooserDialog::TorrentUrlChooserDialog(Gtk::Window& parent, Glib::RefPtr<Session> const& core)
|
||||||
: Gtk::Dialog(_("Open URL"), parent)
|
: Gtk::Dialog(_("Open URL"), parent)
|
||||||
{
|
{
|
||||||
guint row;
|
guint row;
|
||||||
@@ -12,31 +12,31 @@
|
|||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
|
||||||
class TrCore;
|
class Session;
|
||||||
typedef struct tr_ctor tr_ctor;
|
typedef struct tr_ctor tr_ctor;
|
||||||
|
|
||||||
class TorrentUrlChooserDialog : public Gtk::Dialog
|
class TorrentUrlChooserDialog : public Gtk::Dialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static std::unique_ptr<TorrentUrlChooserDialog> create(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core);
|
static std::unique_ptr<TorrentUrlChooserDialog> create(Gtk::Window& parent, Glib::RefPtr<Session> const& core);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TorrentUrlChooserDialog(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core);
|
TorrentUrlChooserDialog(Gtk::Window& parent, Glib::RefPtr<Session> const& core);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onOpenURLResponse(int response, Glib::RefPtr<TrCore> const& core);
|
void onOpenURLResponse(int response, Glib::RefPtr<Session> const& core);
|
||||||
};
|
};
|
||||||
|
|
||||||
class TorrentFileChooserDialog : public Gtk::FileChooserDialog
|
class TorrentFileChooserDialog : public Gtk::FileChooserDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static std::unique_ptr<TorrentFileChooserDialog> create(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core);
|
static std::unique_ptr<TorrentFileChooserDialog> create(Gtk::Window& parent, Glib::RefPtr<Session> const& core);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TorrentFileChooserDialog(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core);
|
TorrentFileChooserDialog(Gtk::Window& parent, Glib::RefPtr<Session> const& core);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onOpenDialogResponse(int response, Glib::RefPtr<TrCore> const& core);
|
void onOpenDialogResponse(int response, Glib::RefPtr<Session> const& core);
|
||||||
};
|
};
|
||||||
|
|
||||||
class OptionsDialog : public Gtk::Dialog
|
class OptionsDialog : public Gtk::Dialog
|
||||||
@@ -46,11 +46,11 @@ public:
|
|||||||
|
|
||||||
static std::unique_ptr<OptionsDialog> create(
|
static std::unique_ptr<OptionsDialog> create(
|
||||||
Gtk::Window& parent,
|
Gtk::Window& parent,
|
||||||
Glib::RefPtr<TrCore> const& core,
|
Glib::RefPtr<Session> const& core,
|
||||||
std::unique_ptr<tr_ctor, void (*)(tr_ctor*)> ctor);
|
std::unique_ptr<tr_ctor, void (*)(tr_ctor*)> ctor);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
OptionsDialog(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core, std::unique_ptr<tr_ctor, void (*)(tr_ctor*)> ctor);
|
OptionsDialog(Gtk::Window& parent, Glib::RefPtr<Session> const& core, std::unique_ptr<tr_ctor, void (*)(tr_ctor*)> ctor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Impl;
|
class Impl;
|
||||||
@@ -34,9 +34,9 @@
|
|||||||
#include <libtransmission/transmission.h>
|
#include <libtransmission/transmission.h>
|
||||||
#include <libtransmission/variant.h>
|
#include <libtransmission/variant.h>
|
||||||
|
|
||||||
#include "conf.h"
|
#include "Prefs.h"
|
||||||
#include "tr-prefs.h"
|
#include "PrefsDialog.h"
|
||||||
#include "util.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#define MY_CONFIG_NAME "transmission"
|
#define MY_CONFIG_NAME "transmission"
|
||||||
|
|
||||||
@@ -18,11 +18,12 @@
|
|||||||
#include <libtransmission/utils.h>
|
#include <libtransmission/utils.h>
|
||||||
#include <libtransmission/version.h>
|
#include <libtransmission/version.h>
|
||||||
|
|
||||||
#include "conf.h"
|
#include "FreeSpaceLabel.h"
|
||||||
#include "hig.h"
|
#include "HigWorkarea.h"
|
||||||
#include "tr-core.h"
|
#include "Prefs.h"
|
||||||
#include "tr-prefs.h"
|
#include "PrefsDialog.h"
|
||||||
#include "util.h"
|
#include "Session.h"
|
||||||
|
#include "Utils.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
***
|
***
|
||||||
@@ -31,7 +32,7 @@
|
|||||||
class PrefsDialog::Impl
|
class PrefsDialog::Impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Impl(PrefsDialog& dialog, Glib::RefPtr<TrCore> const& core);
|
Impl(PrefsDialog& dialog, Glib::RefPtr<Session> const& core);
|
||||||
~Impl();
|
~Impl();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -50,7 +51,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
PrefsDialog& dialog_;
|
PrefsDialog& dialog_;
|
||||||
|
|
||||||
Glib::RefPtr<TrCore> const core_;
|
Glib::RefPtr<Session> const core_;
|
||||||
sigc::connection core_prefs_tag_;
|
sigc::connection core_prefs_tag_;
|
||||||
|
|
||||||
FreeSpaceLabel* freespace_label_ = nullptr;
|
FreeSpaceLabel* freespace_label_ = nullptr;
|
||||||
@@ -82,7 +83,7 @@ void PrefsDialog::Impl::response_cb(int response)
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
Gtk::CheckButton* new_check_button(Glib::ustring const& mnemonic, tr_quark const key, Glib::RefPtr<TrCore> const& core)
|
Gtk::CheckButton* new_check_button(Glib::ustring const& mnemonic, tr_quark const key, Glib::RefPtr<Session> const& core)
|
||||||
{
|
{
|
||||||
auto* w = Gtk::make_managed<Gtk::CheckButton>(mnemonic, true);
|
auto* w = Gtk::make_managed<Gtk::CheckButton>(mnemonic, true);
|
||||||
w->set_active(gtr_pref_flag_get(key));
|
w->set_active(gtr_pref_flag_get(key));
|
||||||
@@ -92,7 +93,7 @@ Gtk::CheckButton* new_check_button(Glib::ustring const& mnemonic, tr_quark const
|
|||||||
|
|
||||||
#define IDLE_DATA "idle-data"
|
#define IDLE_DATA "idle-data"
|
||||||
|
|
||||||
bool spun_cb_idle(Gtk::SpinButton* spin, tr_quark const key, Glib::RefPtr<TrCore> const& core, bool isDouble)
|
bool spun_cb_idle(Gtk::SpinButton* spin, tr_quark const key, Glib::RefPtr<Session> const& core, bool isDouble)
|
||||||
{
|
{
|
||||||
bool keep_waiting = true;
|
bool keep_waiting = true;
|
||||||
auto* last_change = static_cast<Glib::Timer*>(spin->get_data(IDLE_DATA));
|
auto* last_change = static_cast<Glib::Timer*>(spin->get_data(IDLE_DATA));
|
||||||
@@ -121,7 +122,7 @@ bool spun_cb_idle(Gtk::SpinButton* spin, tr_quark const key, Glib::RefPtr<TrCore
|
|||||||
return keep_waiting;
|
return keep_waiting;
|
||||||
}
|
}
|
||||||
|
|
||||||
void spun_cb(Gtk::SpinButton* w, tr_quark const key, Glib::RefPtr<TrCore> const& core, bool isDouble)
|
void spun_cb(Gtk::SpinButton* w, tr_quark const key, Glib::RefPtr<Session> const& core, bool isDouble)
|
||||||
{
|
{
|
||||||
/* user may be spinning through many values, so let's hold off
|
/* user may be spinning through many values, so let's hold off
|
||||||
for a moment to keep from flooding the core with changes */
|
for a moment to keep from flooding the core with changes */
|
||||||
@@ -138,7 +139,7 @@ void spun_cb(Gtk::SpinButton* w, tr_quark const key, Glib::RefPtr<TrCore> const&
|
|||||||
last_change->start();
|
last_change->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
Gtk::SpinButton* new_spin_button(tr_quark const key, Glib::RefPtr<TrCore> const& core, int low, int high, int step)
|
Gtk::SpinButton* new_spin_button(tr_quark const key, Glib::RefPtr<Session> const& core, int low, int high, int step)
|
||||||
{
|
{
|
||||||
auto* w = Gtk::make_managed<Gtk::SpinButton>(Gtk::Adjustment::create(gtr_pref_int_get(key), low, high, step));
|
auto* w = Gtk::make_managed<Gtk::SpinButton>(Gtk::Adjustment::create(gtr_pref_int_get(key), low, high, step));
|
||||||
w->set_digits(0);
|
w->set_digits(0);
|
||||||
@@ -148,7 +149,7 @@ Gtk::SpinButton* new_spin_button(tr_quark const key, Glib::RefPtr<TrCore> const&
|
|||||||
|
|
||||||
Gtk::SpinButton* new_spin_button_double(
|
Gtk::SpinButton* new_spin_button_double(
|
||||||
tr_quark const key,
|
tr_quark const key,
|
||||||
Glib::RefPtr<TrCore> const& core,
|
Glib::RefPtr<Session> const& core,
|
||||||
double low,
|
double low,
|
||||||
double high,
|
double high,
|
||||||
double step)
|
double step)
|
||||||
@@ -159,12 +160,12 @@ Gtk::SpinButton* new_spin_button_double(
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void entry_changed_cb(Gtk::Entry* w, tr_quark const key, Glib::RefPtr<TrCore> const& core)
|
void entry_changed_cb(Gtk::Entry* w, tr_quark const key, Glib::RefPtr<Session> const& core)
|
||||||
{
|
{
|
||||||
core->set_pref(key, w->get_text());
|
core->set_pref(key, w->get_text());
|
||||||
}
|
}
|
||||||
|
|
||||||
Gtk::Entry* new_entry(tr_quark const key, Glib::RefPtr<TrCore> const& core)
|
Gtk::Entry* new_entry(tr_quark const key, Glib::RefPtr<Session> const& core)
|
||||||
{
|
{
|
||||||
auto* w = Gtk::make_managed<Gtk::Entry>();
|
auto* w = Gtk::make_managed<Gtk::Entry>();
|
||||||
|
|
||||||
@@ -177,12 +178,12 @@ Gtk::Entry* new_entry(tr_quark const key, Glib::RefPtr<TrCore> const& core)
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void chosen_cb(Gtk::FileChooser* w, tr_quark const key, Glib::RefPtr<TrCore> const& core)
|
void chosen_cb(Gtk::FileChooser* w, tr_quark const key, Glib::RefPtr<Session> const& core)
|
||||||
{
|
{
|
||||||
core->set_pref(key, w->get_filename());
|
core->set_pref(key, w->get_filename());
|
||||||
}
|
}
|
||||||
|
|
||||||
Gtk::FileChooserButton* new_path_chooser_button(tr_quark const key, Glib::RefPtr<TrCore> const& core)
|
Gtk::FileChooserButton* new_path_chooser_button(tr_quark const key, Glib::RefPtr<Session> const& core)
|
||||||
{
|
{
|
||||||
auto* w = Gtk::make_managed<Gtk::FileChooserButton>(Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
|
auto* w = Gtk::make_managed<Gtk::FileChooserButton>(Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
|
||||||
|
|
||||||
@@ -195,7 +196,7 @@ Gtk::FileChooserButton* new_path_chooser_button(tr_quark const key, Glib::RefPtr
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gtk::FileChooserButton* new_file_chooser_button(tr_quark const key, Glib::RefPtr<TrCore> const& core)
|
Gtk::FileChooserButton* new_file_chooser_button(tr_quark const key, Glib::RefPtr<Session> const& core)
|
||||||
{
|
{
|
||||||
auto* w = Gtk::make_managed<Gtk::FileChooserButton>(Gtk::FILE_CHOOSER_ACTION_OPEN);
|
auto* w = Gtk::make_managed<Gtk::FileChooserButton>(Gtk::FILE_CHOOSER_ACTION_OPEN);
|
||||||
|
|
||||||
@@ -368,10 +369,10 @@ struct blocklist_data
|
|||||||
std::unique_ptr<Gtk::MessageDialog> updateBlocklistDialog;
|
std::unique_ptr<Gtk::MessageDialog> updateBlocklistDialog;
|
||||||
Gtk::Label* label = nullptr;
|
Gtk::Label* label = nullptr;
|
||||||
Gtk::CheckButton* check = nullptr;
|
Gtk::CheckButton* check = nullptr;
|
||||||
Glib::RefPtr<TrCore> core;
|
Glib::RefPtr<Session> core;
|
||||||
};
|
};
|
||||||
|
|
||||||
void updateBlocklistText(Gtk::Label* w, Glib::RefPtr<TrCore> const& core)
|
void updateBlocklistText(Gtk::Label* w, Glib::RefPtr<Session> const& core)
|
||||||
{
|
{
|
||||||
int const n = tr_blocklistGetRuleCount(core->get_session());
|
int const n = tr_blocklistGetRuleCount(core->get_session());
|
||||||
w->set_markup(
|
w->set_markup(
|
||||||
@@ -396,7 +397,7 @@ void onBlocklistUpdateResponse(std::shared_ptr<blocklist_data> const& data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* core says the blocklist was updated */
|
/* core says the blocklist was updated */
|
||||||
void onBlocklistUpdated(Glib::RefPtr<TrCore> const& core, int n, blocklist_data* data)
|
void onBlocklistUpdated(Glib::RefPtr<Session> const& core, int n, blocklist_data* data)
|
||||||
{
|
{
|
||||||
bool const success = n >= 0;
|
bool const success = n >= 0;
|
||||||
int const count = n >= 0 ? n : tr_blocklistGetRuleCount(core->get_session());
|
int const count = n >= 0 ? n : tr_blocklistGetRuleCount(core->get_session());
|
||||||
@@ -432,12 +433,12 @@ void on_blocklist_url_changed(Gtk::Editable* e, Gtk::Button* button)
|
|||||||
button->set_sensitive(is_url_valid);
|
button->set_sensitive(is_url_valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onIntComboChanged(Gtk::ComboBox* combo_box, tr_quark const key, Glib::RefPtr<TrCore> const& core)
|
void onIntComboChanged(Gtk::ComboBox* combo_box, tr_quark const key, Glib::RefPtr<Session> const& core)
|
||||||
{
|
{
|
||||||
core->set_pref(key, gtr_combo_box_get_active_enum(*combo_box));
|
core->set_pref(key, gtr_combo_box_get_active_enum(*combo_box));
|
||||||
}
|
}
|
||||||
|
|
||||||
Gtk::ComboBox* new_encryption_combo(Glib::RefPtr<TrCore> const& core, tr_quark const key)
|
Gtk::ComboBox* new_encryption_combo(Glib::RefPtr<Session> const& core, tr_quark const key)
|
||||||
{
|
{
|
||||||
auto* w = gtr_combo_box_new_enum({
|
auto* w = gtr_combo_box_new_enum({
|
||||||
{ _("Allow encryption"), TR_CLEAR_PREFERRED },
|
{ _("Allow encryption"), TR_CLEAR_PREFERRED },
|
||||||
@@ -543,7 +544,7 @@ Glib::RefPtr<Gtk::ListStore> whitelist_tree_model_new(std::string const& whiteli
|
|||||||
|
|
||||||
struct remote_page
|
struct remote_page
|
||||||
{
|
{
|
||||||
Glib::RefPtr<TrCore> core;
|
Glib::RefPtr<Session> core;
|
||||||
Gtk::TreeView* view;
|
Gtk::TreeView* view;
|
||||||
Glib::RefPtr<Gtk::ListStore> store;
|
Glib::RefPtr<Gtk::ListStore> store;
|
||||||
Gtk::Button* remove_button;
|
Gtk::Button* remove_button;
|
||||||
@@ -760,7 +761,7 @@ void refreshSchedSensitivity(std::shared_ptr<BandwidthPage> const& p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Gtk::ComboBox* new_time_combo(Glib::RefPtr<TrCore> const& core, tr_quark const key)
|
Gtk::ComboBox* new_time_combo(Glib::RefPtr<Session> const& core, tr_quark const key)
|
||||||
{
|
{
|
||||||
class TimeModelColumns : public Gtk::TreeModelColumnRecord
|
class TimeModelColumns : public Gtk::TreeModelColumnRecord
|
||||||
{
|
{
|
||||||
@@ -806,7 +807,7 @@ Gtk::ComboBox* new_time_combo(Glib::RefPtr<TrCore> const& core, tr_quark const k
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gtk::ComboBox* new_week_combo(Glib::RefPtr<TrCore> const& core, tr_quark const key)
|
Gtk::ComboBox* new_week_combo(Glib::RefPtr<Session> const& core, tr_quark const key)
|
||||||
{
|
{
|
||||||
auto* w = gtr_combo_box_new_enum({
|
auto* w = gtr_combo_box_new_enum({
|
||||||
{ _("Every Day"), TR_SCHED_ALL },
|
{ _("Every Day"), TR_SCHED_ALL },
|
||||||
@@ -919,7 +920,7 @@ struct network_page_data
|
|||||||
{
|
{
|
||||||
~network_page_data();
|
~network_page_data();
|
||||||
|
|
||||||
Glib::RefPtr<TrCore> core;
|
Glib::RefPtr<Session> core;
|
||||||
Gtk::Label* portLabel = nullptr;
|
Gtk::Label* portLabel = nullptr;
|
||||||
Gtk::Button* portButton = nullptr;
|
Gtk::Button* portButton = nullptr;
|
||||||
Gtk::SpinButton* portSpin = nullptr;
|
Gtk::SpinButton* portSpin = nullptr;
|
||||||
@@ -1074,12 +1075,12 @@ void PrefsDialog::Impl::on_core_prefs_changed(tr_quark const key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<PrefsDialog> PrefsDialog::create(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core)
|
std::unique_ptr<PrefsDialog> PrefsDialog::create(Gtk::Window& parent, Glib::RefPtr<Session> const& core)
|
||||||
{
|
{
|
||||||
return std::unique_ptr<PrefsDialog>(new PrefsDialog(parent, core));
|
return std::unique_ptr<PrefsDialog>(new PrefsDialog(parent, core));
|
||||||
}
|
}
|
||||||
|
|
||||||
PrefsDialog::PrefsDialog(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core)
|
PrefsDialog::PrefsDialog(Gtk::Window& parent, Glib::RefPtr<Session> const& core)
|
||||||
: Gtk::Dialog(_("Transmission Preferences"), parent)
|
: Gtk::Dialog(_("Transmission Preferences"), parent)
|
||||||
, impl_(std::make_unique<Impl>(*this, core))
|
, impl_(std::make_unique<Impl>(*this, core))
|
||||||
{
|
{
|
||||||
@@ -1087,7 +1088,7 @@ PrefsDialog::PrefsDialog(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core)
|
|||||||
|
|
||||||
PrefsDialog::~PrefsDialog() = default;
|
PrefsDialog::~PrefsDialog() = default;
|
||||||
|
|
||||||
PrefsDialog::Impl::Impl(PrefsDialog& dialog, Glib::RefPtr<TrCore> const& core)
|
PrefsDialog::Impl::Impl(PrefsDialog& dialog, Glib::RefPtr<Session> const& core)
|
||||||
: dialog_(dialog)
|
: dialog_(dialog)
|
||||||
, core_(core)
|
, core_(core)
|
||||||
{
|
{
|
||||||
@@ -12,17 +12,17 @@
|
|||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
|
||||||
class TrCore;
|
class Session;
|
||||||
|
|
||||||
class PrefsDialog : public Gtk::Dialog
|
class PrefsDialog : public Gtk::Dialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~PrefsDialog() override;
|
~PrefsDialog() override;
|
||||||
|
|
||||||
static std::unique_ptr<PrefsDialog> create(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core);
|
static std::unique_ptr<PrefsDialog> create(Gtk::Window& parent, Glib::RefPtr<Session> const& core);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PrefsDialog(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core);
|
PrefsDialog(Gtk::Window& parent, Glib::RefPtr<Session> const& core);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Impl;
|
class Impl;
|
||||||
@@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
#include <libtransmission/transmission.h>
|
#include <libtransmission/transmission.h>
|
||||||
|
|
||||||
#include "conf.h" /* gtr_pref_string_get */
|
#include "HigWorkarea.h"
|
||||||
#include "hig.h"
|
#include "Prefs.h" /* gtr_pref_string_get */
|
||||||
#include "relocate.h"
|
#include "RelocateDialog.h"
|
||||||
#include "tr-core.h"
|
#include "Session.h"
|
||||||
#include "util.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -29,7 +29,7 @@ std::string previousLocation;
|
|||||||
class RelocateDialog::Impl
|
class RelocateDialog::Impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Impl(RelocateDialog& dialog, Glib::RefPtr<TrCore> const& core, std::vector<int> const& torrent_ids);
|
Impl(RelocateDialog& dialog, Glib::RefPtr<Session> const& core, std::vector<int> const& torrent_ids);
|
||||||
~Impl();
|
~Impl();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -40,7 +40,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
RelocateDialog& dialog_;
|
RelocateDialog& dialog_;
|
||||||
Glib::RefPtr<TrCore> const core_;
|
Glib::RefPtr<Session> const core_;
|
||||||
std::vector<int> torrent_ids_;
|
std::vector<int> torrent_ids_;
|
||||||
|
|
||||||
int done_ = 0;
|
int done_ = 0;
|
||||||
@@ -135,13 +135,13 @@ void RelocateDialog::Impl::onResponse(int response)
|
|||||||
|
|
||||||
std::unique_ptr<RelocateDialog> RelocateDialog::create(
|
std::unique_ptr<RelocateDialog> RelocateDialog::create(
|
||||||
Gtk::Window& parent,
|
Gtk::Window& parent,
|
||||||
Glib::RefPtr<TrCore> const& core,
|
Glib::RefPtr<Session> const& core,
|
||||||
std::vector<int> const& torrent_ids)
|
std::vector<int> const& torrent_ids)
|
||||||
{
|
{
|
||||||
return std::unique_ptr<RelocateDialog>(new RelocateDialog(parent, core, torrent_ids));
|
return std::unique_ptr<RelocateDialog>(new RelocateDialog(parent, core, torrent_ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
RelocateDialog::RelocateDialog(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core, std::vector<int> const& torrent_ids)
|
RelocateDialog::RelocateDialog(Gtk::Window& parent, Glib::RefPtr<Session> const& core, std::vector<int> const& torrent_ids)
|
||||||
: Gtk::Dialog(_("Set Torrent Location"), parent, true)
|
: Gtk::Dialog(_("Set Torrent Location"), parent, true)
|
||||||
, impl_(std::make_unique<Impl>(*this, core, torrent_ids))
|
, impl_(std::make_unique<Impl>(*this, core, torrent_ids))
|
||||||
{
|
{
|
||||||
@@ -149,7 +149,7 @@ RelocateDialog::RelocateDialog(Gtk::Window& parent, Glib::RefPtr<TrCore> const&
|
|||||||
|
|
||||||
RelocateDialog::~RelocateDialog() = default;
|
RelocateDialog::~RelocateDialog() = default;
|
||||||
|
|
||||||
RelocateDialog::Impl::Impl(RelocateDialog& dialog, Glib::RefPtr<TrCore> const& core, std::vector<int> const& torrent_ids)
|
RelocateDialog::Impl::Impl(RelocateDialog& dialog, Glib::RefPtr<Session> const& core, std::vector<int> const& torrent_ids)
|
||||||
: dialog_(dialog)
|
: dialog_(dialog)
|
||||||
, core_(core)
|
, core_(core)
|
||||||
, torrent_ids_(torrent_ids)
|
, torrent_ids_(torrent_ids)
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
|
||||||
class TrCore;
|
class Session;
|
||||||
|
|
||||||
class RelocateDialog : public Gtk::Dialog
|
class RelocateDialog : public Gtk::Dialog
|
||||||
{
|
{
|
||||||
@@ -22,11 +22,11 @@ public:
|
|||||||
|
|
||||||
static std::unique_ptr<RelocateDialog> create(
|
static std::unique_ptr<RelocateDialog> create(
|
||||||
Gtk::Window& parent,
|
Gtk::Window& parent,
|
||||||
Glib::RefPtr<TrCore> const& core,
|
Glib::RefPtr<Session> const& core,
|
||||||
std::vector<int> const& torrent_ids);
|
std::vector<int> const& torrent_ids);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RelocateDialog(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core, std::vector<int> const& torrent_ids);
|
RelocateDialog(Gtk::Window& parent, Glib::RefPtr<Session> const& core, std::vector<int> const& torrent_ids);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Impl;
|
class Impl;
|
||||||
@@ -37,12 +37,12 @@
|
|||||||
#include <libtransmission/utils.h> /* tr_free */
|
#include <libtransmission/utils.h> /* tr_free */
|
||||||
#include <libtransmission/variant.h>
|
#include <libtransmission/variant.h>
|
||||||
|
|
||||||
#include "actions.h"
|
#include "Actions.h"
|
||||||
#include "conf.h"
|
#include "Notify.h"
|
||||||
#include "notify.h"
|
#include "Prefs.h"
|
||||||
#include "tr-core.h"
|
#include "PrefsDialog.h"
|
||||||
#include "tr-prefs.h"
|
#include "Session.h"
|
||||||
#include "util.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -70,10 +70,10 @@ private:
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
class TrCore::Impl
|
class Session::Impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Impl(TrCore& core, tr_session* session);
|
Impl(Session& core, tr_session* session);
|
||||||
|
|
||||||
tr_session* close();
|
tr_session* close();
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ public:
|
|||||||
sigc::signal<void(bool)> signal_port_tested;
|
sigc::signal<void(bool)> signal_port_tested;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Glib::RefPtr<TrCore> get_core_ptr() const;
|
Glib::RefPtr<Session> get_core_ptr() const;
|
||||||
|
|
||||||
bool is_busy();
|
bool is_busy();
|
||||||
void add_to_busy(int addMe);
|
void add_to_busy(int addMe);
|
||||||
@@ -141,7 +141,7 @@ private:
|
|||||||
void on_torrent_metadata_changed(tr_torrent* tor);
|
void on_torrent_metadata_changed(tr_torrent* tor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TrCore& core_;
|
Session& core_;
|
||||||
|
|
||||||
Glib::RefPtr<Gio::FileMonitor> monitor_;
|
Glib::RefPtr<Gio::FileMonitor> monitor_;
|
||||||
sigc::connection monitor_tag_;
|
sigc::connection monitor_tag_;
|
||||||
@@ -182,37 +182,37 @@ TorrentModelColumns::TorrentModelColumns()
|
|||||||
|
|
||||||
TorrentModelColumns const torrent_cols;
|
TorrentModelColumns const torrent_cols;
|
||||||
|
|
||||||
Glib::RefPtr<TrCore> TrCore::Impl::get_core_ptr() const
|
Glib::RefPtr<Session> Session::Impl::get_core_ptr() const
|
||||||
{
|
{
|
||||||
core_.reference();
|
core_.reference();
|
||||||
return Glib::RefPtr<TrCore>(&core_);
|
return Glib::RefPtr<Session>(&core_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
****
|
****
|
||||||
***/
|
***/
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::ListStore> TrCore::Impl::get_raw_model() const
|
Glib::RefPtr<Gtk::ListStore> Session::Impl::get_raw_model() const
|
||||||
{
|
{
|
||||||
return raw_model_;
|
return raw_model_;
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::TreeModel> TrCore::get_model() const
|
Glib::RefPtr<Gtk::TreeModel> Session::get_model() const
|
||||||
{
|
{
|
||||||
return impl_->get_model();
|
return impl_->get_model();
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::TreeModelSort> TrCore::Impl::get_model() const
|
Glib::RefPtr<Gtk::TreeModelSort> Session::Impl::get_model() const
|
||||||
{
|
{
|
||||||
return sorted_model_;
|
return sorted_model_;
|
||||||
}
|
}
|
||||||
|
|
||||||
tr_session* TrCore::get_session() const
|
tr_session* Session::get_session() const
|
||||||
{
|
{
|
||||||
return impl_->get_session();
|
return impl_->get_session();
|
||||||
}
|
}
|
||||||
|
|
||||||
tr_session* TrCore::Impl::get_session() const
|
tr_session* Session::Impl::get_session() const
|
||||||
{
|
{
|
||||||
return session_;
|
return session_;
|
||||||
}
|
}
|
||||||
@@ -221,12 +221,12 @@ tr_session* TrCore::Impl::get_session() const
|
|||||||
**** BUSY
|
**** BUSY
|
||||||
***/
|
***/
|
||||||
|
|
||||||
bool TrCore::Impl::is_busy()
|
bool Session::Impl::is_busy()
|
||||||
{
|
{
|
||||||
return busy_count_ > 0;
|
return busy_count_ > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrCore::Impl::add_to_busy(int addMe)
|
void Session::Impl::add_to_busy(int addMe)
|
||||||
{
|
{
|
||||||
bool const wasBusy = is_busy();
|
bool const wasBusy = is_busy();
|
||||||
|
|
||||||
@@ -238,12 +238,12 @@ void TrCore::Impl::add_to_busy(int addMe)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrCore::Impl::inc_busy()
|
void Session::Impl::inc_busy()
|
||||||
{
|
{
|
||||||
add_to_busy(1);
|
add_to_busy(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrCore::Impl::dec_busy()
|
void Session::Impl::dec_busy()
|
||||||
{
|
{
|
||||||
add_to_busy(-1);
|
add_to_busy(-1);
|
||||||
}
|
}
|
||||||
@@ -561,7 +561,7 @@ int compare_by_state(Gtk::TreeModel::iterator const& a, Gtk::TreeModel::iterator
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void TrCore::Impl::set_sort_mode(std::string const& mode, bool is_reversed)
|
void Session::Impl::set_sort_mode(std::string const& mode, bool is_reversed)
|
||||||
{
|
{
|
||||||
auto const& col = torrent_cols.torrent;
|
auto const& col = torrent_cols.torrent;
|
||||||
Gtk::TreeSortable::SlotCompare sort_func;
|
Gtk::TreeSortable::SlotCompare sort_func;
|
||||||
@@ -647,7 +647,7 @@ void rename_torrent(Glib::RefPtr<Gio::File> const& file)
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
bool TrCore::Impl::watchdir_idle()
|
bool Session::Impl::watchdir_idle()
|
||||||
{
|
{
|
||||||
std::vector<Glib::RefPtr<Gio::File>> changing;
|
std::vector<Glib::RefPtr<Gio::File>> changing;
|
||||||
std::vector<Glib::RefPtr<Gio::File>> unchanging;
|
std::vector<Glib::RefPtr<Gio::File>> unchanging;
|
||||||
@@ -694,7 +694,7 @@ bool TrCore::Impl::watchdir_idle()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If this file is a torrent, add it to our list */
|
/* If this file is a torrent, add it to our list */
|
||||||
void TrCore::Impl::watchdir_monitor_file(Glib::RefPtr<Gio::File> const& file)
|
void Session::Impl::watchdir_monitor_file(Glib::RefPtr<Gio::File> const& file)
|
||||||
{
|
{
|
||||||
auto const filename = file->get_path();
|
auto const filename = file->get_path();
|
||||||
bool const is_torrent = Glib::str_has_suffix(filename, ".torrent");
|
bool const is_torrent = Glib::str_has_suffix(filename, ".torrent");
|
||||||
@@ -720,7 +720,7 @@ void TrCore::Impl::watchdir_monitor_file(Glib::RefPtr<Gio::File> const& file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* GFileMonitor noticed a file was created */
|
/* GFileMonitor noticed a file was created */
|
||||||
void TrCore::Impl::on_file_changed_in_watchdir(
|
void Session::Impl::on_file_changed_in_watchdir(
|
||||||
Glib::RefPtr<Gio::File> const& file,
|
Glib::RefPtr<Gio::File> const& file,
|
||||||
Glib::RefPtr<Gio::File> const& /*other_type*/,
|
Glib::RefPtr<Gio::File> const& /*other_type*/,
|
||||||
Gio::FileMonitorEvent event_type)
|
Gio::FileMonitorEvent event_type)
|
||||||
@@ -732,7 +732,7 @@ void TrCore::Impl::on_file_changed_in_watchdir(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* walk through the pre-existing files in the watchdir */
|
/* walk through the pre-existing files in the watchdir */
|
||||||
void TrCore::Impl::watchdir_scan()
|
void Session::Impl::watchdir_scan()
|
||||||
{
|
{
|
||||||
auto const dirname = gtr_pref_string_get(TR_KEY_watch_dir);
|
auto const dirname = gtr_pref_string_get(TR_KEY_watch_dir);
|
||||||
|
|
||||||
@@ -748,7 +748,7 @@ void TrCore::Impl::watchdir_scan()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrCore::Impl::watchdir_update()
|
void Session::Impl::watchdir_update()
|
||||||
{
|
{
|
||||||
bool const is_enabled = gtr_pref_flag_get(TR_KEY_watch_dir_enabled);
|
bool const is_enabled = gtr_pref_flag_get(TR_KEY_watch_dir_enabled);
|
||||||
auto const dir = Gio::File::create_for_path(gtr_pref_string_get(TR_KEY_watch_dir));
|
auto const dir = Gio::File::create_for_path(gtr_pref_string_get(TR_KEY_watch_dir));
|
||||||
@@ -777,7 +777,7 @@ void TrCore::Impl::watchdir_update()
|
|||||||
****
|
****
|
||||||
***/
|
***/
|
||||||
|
|
||||||
void TrCore::Impl::on_pref_changed(tr_quark const key)
|
void Session::Impl::on_pref_changed(tr_quark const key)
|
||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
@@ -816,20 +816,20 @@ void TrCore::Impl::on_pref_changed(tr_quark const key)
|
|||||||
***
|
***
|
||||||
**/
|
**/
|
||||||
|
|
||||||
Glib::RefPtr<TrCore> TrCore::create(tr_session* session)
|
Glib::RefPtr<Session> Session::create(tr_session* session)
|
||||||
{
|
{
|
||||||
return Glib::make_refptr_for_instance(new TrCore(session));
|
return Glib::make_refptr_for_instance(new Session(session));
|
||||||
}
|
}
|
||||||
|
|
||||||
TrCore::TrCore(tr_session* session)
|
Session::Session(tr_session* session)
|
||||||
: Glib::ObjectBase(typeid(TrCore))
|
: Glib::ObjectBase(typeid(Session))
|
||||||
, impl_(std::make_unique<Impl>(*this, session))
|
, impl_(std::make_unique<Impl>(*this, session))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
TrCore::~TrCore() = default;
|
Session::~Session() = default;
|
||||||
|
|
||||||
TrCore::Impl::Impl(TrCore& core, tr_session* session)
|
Session::Impl::Impl(Session& core, tr_session* session)
|
||||||
: core_(core)
|
: core_(core)
|
||||||
, session_(session)
|
, session_(session)
|
||||||
{
|
{
|
||||||
@@ -847,12 +847,12 @@ TrCore::Impl::Impl(TrCore& core, tr_session* session)
|
|||||||
signal_prefs_changed.connect([this](auto key) { on_pref_changed(key); });
|
signal_prefs_changed.connect([this](auto key) { on_pref_changed(key); });
|
||||||
}
|
}
|
||||||
|
|
||||||
tr_session* TrCore::close()
|
tr_session* Session::close()
|
||||||
{
|
{
|
||||||
return impl_->close();
|
return impl_->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
tr_session* TrCore::Impl::close()
|
tr_session* Session::Impl::close()
|
||||||
{
|
{
|
||||||
auto* session = session_;
|
auto* session = session_;
|
||||||
|
|
||||||
@@ -871,7 +871,7 @@ tr_session* TrCore::Impl::close()
|
|||||||
|
|
||||||
/* this is called in the libtransmission thread, *NOT* the GTK+ thread,
|
/* this is called in the libtransmission thread, *NOT* the GTK+ thread,
|
||||||
so delegate to the GTK+ thread before calling notify's dbus code... */
|
so delegate to the GTK+ thread before calling notify's dbus code... */
|
||||||
void TrCore::Impl::on_torrent_completeness_changed(tr_torrent* tor, tr_completeness completeness, bool was_running)
|
void Session::Impl::on_torrent_completeness_changed(tr_torrent* tor, tr_completeness completeness, bool was_running)
|
||||||
{
|
{
|
||||||
if (was_running && completeness != TR_LEECH && tr_torrentStat(tor)->sizeWhenDone != 0)
|
if (was_running && completeness != TR_LEECH && tr_torrentStat(tor)->sizeWhenDone != 0)
|
||||||
{
|
{
|
||||||
@@ -899,7 +899,7 @@ Glib::ustring get_collated_name(tr_torrent const* tor)
|
|||||||
|
|
||||||
struct metadata_callback_data
|
struct metadata_callback_data
|
||||||
{
|
{
|
||||||
TrCore* core;
|
Session* core;
|
||||||
int torrent_id;
|
int torrent_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -920,7 +920,7 @@ Gtk::TreeModel::iterator find_row_from_torrent_id(Glib::RefPtr<Gtk::TreeModel> c
|
|||||||
|
|
||||||
/* this is called in the libtransmission thread, *NOT* the GTK+ thread,
|
/* this is called in the libtransmission thread, *NOT* the GTK+ thread,
|
||||||
so delegate to the GTK+ thread before changing our list store... */
|
so delegate to the GTK+ thread before changing our list store... */
|
||||||
void TrCore::Impl::on_torrent_metadata_changed(tr_torrent* tor)
|
void Session::Impl::on_torrent_metadata_changed(tr_torrent* tor)
|
||||||
{
|
{
|
||||||
Glib::signal_idle().connect(
|
Glib::signal_idle().connect(
|
||||||
[this, core = get_core_ptr(), torrent_id = tr_torrentId(tor)]()
|
[this, core = get_core_ptr(), torrent_id = tr_torrentId(tor)]()
|
||||||
@@ -972,13 +972,13 @@ bool is_torrent_active(tr_stat const* st)
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void TrCore::add_torrent(tr_torrent* tor, bool do_notify)
|
void Session::add_torrent(tr_torrent* tor, bool do_notify)
|
||||||
{
|
{
|
||||||
ScopedModelSortBlocker disable_sort(*gtr_get_ptr(impl_->get_model()));
|
ScopedModelSortBlocker disable_sort(*gtr_get_ptr(impl_->get_model()));
|
||||||
impl_->add_torrent(tor, do_notify);
|
impl_->add_torrent(tor, do_notify);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrCore::Impl::add_torrent(tr_torrent* tor, bool do_notify)
|
void Session::Impl::add_torrent(tr_torrent* tor, bool do_notify)
|
||||||
{
|
{
|
||||||
if (tor != nullptr)
|
if (tor != nullptr)
|
||||||
{
|
{
|
||||||
@@ -1020,7 +1020,7 @@ void TrCore::Impl::add_torrent(tr_torrent* tor, bool do_notify)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tr_torrent* TrCore::Impl::create_new_torrent(tr_ctor* ctor)
|
tr_torrent* Session::Impl::create_new_torrent(tr_ctor* ctor)
|
||||||
{
|
{
|
||||||
bool do_trash = false;
|
bool do_trash = false;
|
||||||
|
|
||||||
@@ -1050,7 +1050,7 @@ tr_torrent* TrCore::Impl::create_new_torrent(tr_ctor* ctor)
|
|||||||
return tor;
|
return tor;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TrCore::Impl::add_ctor(tr_ctor* ctor, bool do_prompt, bool do_notify)
|
int Session::Impl::add_ctor(tr_ctor* ctor, bool do_prompt, bool do_notify)
|
||||||
{
|
{
|
||||||
tr_info inf;
|
tr_info inf;
|
||||||
auto err = tr_torrentParse(ctor, &inf);
|
auto err = tr_torrentParse(ctor, &inf);
|
||||||
@@ -1120,7 +1120,7 @@ void core_apply_defaults(tr_ctor* ctor)
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void TrCore::add_ctor(tr_ctor* ctor)
|
void Session::add_ctor(tr_ctor* ctor)
|
||||||
{
|
{
|
||||||
bool const do_notify = false;
|
bool const do_notify = false;
|
||||||
bool const do_prompt = gtr_pref_flag_get(TR_KEY_show_options_window);
|
bool const do_prompt = gtr_pref_flag_get(TR_KEY_show_options_window);
|
||||||
@@ -1132,7 +1132,7 @@ void TrCore::add_ctor(tr_ctor* ctor)
|
|||||||
****
|
****
|
||||||
***/
|
***/
|
||||||
|
|
||||||
void TrCore::Impl::add_file_async_callback(
|
void Session::Impl::add_file_async_callback(
|
||||||
Glib::RefPtr<Gio::File> const& file,
|
Glib::RefPtr<Gio::File> const& file,
|
||||||
Glib::RefPtr<Gio::AsyncResult>& result,
|
Glib::RefPtr<Gio::AsyncResult>& result,
|
||||||
tr_ctor* ctor,
|
tr_ctor* ctor,
|
||||||
@@ -1165,7 +1165,7 @@ void TrCore::Impl::add_file_async_callback(
|
|||||||
dec_busy();
|
dec_busy();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TrCore::Impl::add_file(Glib::RefPtr<Gio::File> const& file, bool do_start, bool do_prompt, bool do_notify)
|
bool Session::Impl::add_file(Glib::RefPtr<Gio::File> const& file, bool do_start, bool do_prompt, bool do_notify)
|
||||||
{
|
{
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
auto const* const session = get_session();
|
auto const* const session = get_session();
|
||||||
@@ -1236,12 +1236,12 @@ bool TrCore::Impl::add_file(Glib::RefPtr<Gio::File> const& file, bool do_start,
|
|||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TrCore::add_from_url(Glib::ustring const& uri)
|
bool Session::add_from_url(Glib::ustring const& uri)
|
||||||
{
|
{
|
||||||
return impl_->add_from_url(uri);
|
return impl_->add_from_url(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TrCore::Impl::add_from_url(Glib::ustring const& uri)
|
bool Session::Impl::add_from_url(Glib::ustring const& uri)
|
||||||
{
|
{
|
||||||
bool handled;
|
bool handled;
|
||||||
bool const do_start = gtr_pref_flag_get(TR_KEY_start_added_torrents);
|
bool const do_start = gtr_pref_flag_get(TR_KEY_start_added_torrents);
|
||||||
@@ -1255,12 +1255,12 @@ bool TrCore::Impl::add_from_url(Glib::ustring const& uri)
|
|||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrCore::add_files(std::vector<Glib::RefPtr<Gio::File>> const& files, bool do_start, bool do_prompt, bool do_notify)
|
void Session::add_files(std::vector<Glib::RefPtr<Gio::File>> const& files, bool do_start, bool do_prompt, bool do_notify)
|
||||||
{
|
{
|
||||||
impl_->add_files(files, do_start, do_prompt, do_notify);
|
impl_->add_files(files, do_start, do_prompt, do_notify);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrCore::Impl::add_files(std::vector<Glib::RefPtr<Gio::File>> const& files, bool do_start, bool do_prompt, bool do_notify)
|
void Session::Impl::add_files(std::vector<Glib::RefPtr<Gio::File>> const& files, bool do_start, bool do_prompt, bool do_notify)
|
||||||
{
|
{
|
||||||
for (auto const& file : files)
|
for (auto const& file : files)
|
||||||
{
|
{
|
||||||
@@ -1270,18 +1270,18 @@ void TrCore::Impl::add_files(std::vector<Glib::RefPtr<Gio::File>> const& files,
|
|||||||
torrents_added();
|
torrents_added();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrCore::torrents_added()
|
void Session::torrents_added()
|
||||||
{
|
{
|
||||||
impl_->torrents_added();
|
impl_->torrents_added();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrCore::Impl::torrents_added()
|
void Session::Impl::torrents_added()
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
signal_add_error.emit(ERR_NO_MORE_TORRENTS, {});
|
signal_add_error.emit(ERR_NO_MORE_TORRENTS, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrCore::torrent_changed(int id)
|
void Session::torrent_changed(int id)
|
||||||
{
|
{
|
||||||
auto const model = impl_->get_raw_model();
|
auto const model = impl_->get_raw_model();
|
||||||
|
|
||||||
@@ -1291,7 +1291,7 @@ void TrCore::torrent_changed(int id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrCore::remove_torrent(int id, bool delete_local_data)
|
void Session::remove_torrent(int id, bool delete_local_data)
|
||||||
{
|
{
|
||||||
auto* tor = find_torrent(id);
|
auto* tor = find_torrent(id);
|
||||||
|
|
||||||
@@ -1313,7 +1313,7 @@ void TrCore::remove_torrent(int id, bool delete_local_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrCore::load(bool forcePaused)
|
void Session::load(bool forcePaused)
|
||||||
{
|
{
|
||||||
tr_ctor* ctor;
|
tr_ctor* ctor;
|
||||||
tr_torrent** torrents;
|
tr_torrent** torrents;
|
||||||
@@ -1341,7 +1341,7 @@ void TrCore::load(bool forcePaused)
|
|||||||
tr_ctorFree(ctor);
|
tr_ctorFree(ctor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrCore::clear()
|
void Session::clear()
|
||||||
{
|
{
|
||||||
impl_->get_raw_model()->clear();
|
impl_->get_raw_model()->clear();
|
||||||
}
|
}
|
||||||
@@ -1436,12 +1436,12 @@ void update_foreach(Gtk::TreeModel::Row const& row)
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void TrCore::update()
|
void Session::update()
|
||||||
{
|
{
|
||||||
impl_->update();
|
impl_->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrCore::Impl::update()
|
void Session::Impl::update()
|
||||||
{
|
{
|
||||||
/* update the model */
|
/* update the model */
|
||||||
for (auto const& row : raw_model_->children())
|
for (auto const& row : raw_model_->children())
|
||||||
@@ -1529,7 +1529,7 @@ void gtr_uninhibit_hibernation(guint inhibit_cookie)
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void TrCore::Impl::set_hibernation_allowed(bool allowed)
|
void Session::Impl::set_hibernation_allowed(bool allowed)
|
||||||
{
|
{
|
||||||
inhibit_allowed_ = allowed;
|
inhibit_allowed_ = allowed;
|
||||||
|
|
||||||
@@ -1552,7 +1552,7 @@ void TrCore::Impl::set_hibernation_allowed(bool allowed)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrCore::Impl::maybe_inhibit_hibernation()
|
void Session::Impl::maybe_inhibit_hibernation()
|
||||||
{
|
{
|
||||||
/* hibernation is allowed if EITHER
|
/* hibernation is allowed if EITHER
|
||||||
* (a) the "inhibit" pref is turned off OR
|
* (a) the "inhibit" pref is turned off OR
|
||||||
@@ -1565,13 +1565,13 @@ void TrCore::Impl::maybe_inhibit_hibernation()
|
|||||||
*** Prefs
|
*** Prefs
|
||||||
**/
|
**/
|
||||||
|
|
||||||
void TrCore::Impl::commit_prefs_change(tr_quark const key)
|
void Session::Impl::commit_prefs_change(tr_quark const key)
|
||||||
{
|
{
|
||||||
signal_prefs_changed.emit(key);
|
signal_prefs_changed.emit(key);
|
||||||
gtr_pref_save(session_);
|
gtr_pref_save(session_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrCore::set_pref(tr_quark const key, std::string const& newval)
|
void Session::set_pref(tr_quark const key, std::string const& newval)
|
||||||
{
|
{
|
||||||
if (newval != gtr_pref_string_get(key))
|
if (newval != gtr_pref_string_get(key))
|
||||||
{
|
{
|
||||||
@@ -1580,7 +1580,7 @@ void TrCore::set_pref(tr_quark const key, std::string const& newval)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrCore::set_pref(tr_quark const key, bool newval)
|
void Session::set_pref(tr_quark const key, bool newval)
|
||||||
{
|
{
|
||||||
if (newval != gtr_pref_flag_get(key))
|
if (newval != gtr_pref_flag_get(key))
|
||||||
{
|
{
|
||||||
@@ -1589,7 +1589,7 @@ void TrCore::set_pref(tr_quark const key, bool newval)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrCore::set_pref(tr_quark const key, int newval)
|
void Session::set_pref(tr_quark const key, int newval)
|
||||||
{
|
{
|
||||||
if (newval != gtr_pref_int_get(key))
|
if (newval != gtr_pref_int_get(key))
|
||||||
{
|
{
|
||||||
@@ -1598,7 +1598,7 @@ void TrCore::set_pref(tr_quark const key, int newval)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrCore::set_pref(tr_quark const key, double newval)
|
void Session::set_pref(tr_quark const key, double newval)
|
||||||
{
|
{
|
||||||
if (gtr_compare_double(newval, gtr_pref_double_get(key), 4))
|
if (gtr_compare_double(newval, gtr_pref_double_get(key), 4))
|
||||||
{
|
{
|
||||||
@@ -1620,7 +1620,7 @@ namespace
|
|||||||
|
|
||||||
int nextTag = 1;
|
int nextTag = 1;
|
||||||
|
|
||||||
typedef void (*server_response_func)(TrCore* core, tr_variant* response, gpointer user_data);
|
typedef void (*server_response_func)(Session* core, tr_variant* response, gpointer user_data);
|
||||||
|
|
||||||
struct pending_request_data
|
struct pending_request_data
|
||||||
{
|
{
|
||||||
@@ -1666,7 +1666,7 @@ void core_read_rpc_response(tr_session* /*session*/, tr_variant* response, void*
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void TrCore::Impl::send_rpc_request(tr_variant const* request, int tag, std::function<void(tr_variant*)> const& response_func)
|
void Session::Impl::send_rpc_request(tr_variant const* request, int tag, std::function<void(tr_variant*)> const& response_func)
|
||||||
{
|
{
|
||||||
if (session_ == nullptr)
|
if (session_ == nullptr)
|
||||||
{
|
{
|
||||||
@@ -1698,7 +1698,7 @@ void TrCore::Impl::send_rpc_request(tr_variant const* request, int tag, std::fun
|
|||||||
**** Sending a test-port request via RPC
|
**** Sending a test-port request via RPC
|
||||||
***/
|
***/
|
||||||
|
|
||||||
void TrCore::port_test()
|
void Session::port_test()
|
||||||
{
|
{
|
||||||
int const tag = nextTag;
|
int const tag = nextTag;
|
||||||
++nextTag;
|
++nextTag;
|
||||||
@@ -1730,7 +1730,7 @@ void TrCore::port_test()
|
|||||||
**** Updating a blocklist via RPC
|
**** Updating a blocklist via RPC
|
||||||
***/
|
***/
|
||||||
|
|
||||||
void TrCore::blocklist_update()
|
void Session::blocklist_update()
|
||||||
{
|
{
|
||||||
int const tag = nextTag;
|
int const tag = nextTag;
|
||||||
++nextTag;
|
++nextTag;
|
||||||
@@ -1767,7 +1767,7 @@ void TrCore::blocklist_update()
|
|||||||
****
|
****
|
||||||
***/
|
***/
|
||||||
|
|
||||||
void TrCore::exec(tr_variant const* top)
|
void Session::exec(tr_variant const* top)
|
||||||
{
|
{
|
||||||
int const tag = nextTag;
|
int const tag = nextTag;
|
||||||
++nextTag;
|
++nextTag;
|
||||||
@@ -1779,17 +1779,17 @@ void TrCore::exec(tr_variant const* top)
|
|||||||
****
|
****
|
||||||
***/
|
***/
|
||||||
|
|
||||||
size_t TrCore::get_torrent_count() const
|
size_t Session::get_torrent_count() const
|
||||||
{
|
{
|
||||||
return impl_->get_raw_model()->children().size();
|
return impl_->get_raw_model()->children().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t TrCore::get_active_torrent_count() const
|
size_t Session::get_active_torrent_count() const
|
||||||
{
|
{
|
||||||
return impl_->get_active_torrent_count();
|
return impl_->get_active_torrent_count();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t TrCore::Impl::get_active_torrent_count() const
|
size_t Session::Impl::get_active_torrent_count() const
|
||||||
{
|
{
|
||||||
size_t activeCount = 0;
|
size_t activeCount = 0;
|
||||||
|
|
||||||
@@ -1804,7 +1804,7 @@ size_t TrCore::Impl::get_active_torrent_count() const
|
|||||||
return activeCount;
|
return activeCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
tr_torrent* TrCore::find_torrent(int id) const
|
tr_torrent* Session::find_torrent(int id) const
|
||||||
{
|
{
|
||||||
tr_torrent* tor = nullptr;
|
tr_torrent* tor = nullptr;
|
||||||
|
|
||||||
@@ -1816,7 +1816,7 @@ tr_torrent* TrCore::find_torrent(int id) const
|
|||||||
return tor;
|
return tor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrCore::open_folder(int torrent_id)
|
void Session::open_folder(int torrent_id)
|
||||||
{
|
{
|
||||||
auto const* tor = find_torrent(torrent_id);
|
auto const* tor = find_torrent(torrent_id);
|
||||||
|
|
||||||
@@ -1836,32 +1836,32 @@ void TrCore::open_folder(int torrent_id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sigc::signal<void(TrCore::ErrorCode, Glib::ustring const&)>& TrCore::signal_add_error()
|
sigc::signal<void(Session::ErrorCode, Glib::ustring const&)>& Session::signal_add_error()
|
||||||
{
|
{
|
||||||
return impl_->signal_add_error;
|
return impl_->signal_add_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
sigc::signal<void(tr_ctor*)>& TrCore::signal_add_prompt()
|
sigc::signal<void(tr_ctor*)>& Session::signal_add_prompt()
|
||||||
{
|
{
|
||||||
return impl_->signal_add_prompt;
|
return impl_->signal_add_prompt;
|
||||||
}
|
}
|
||||||
|
|
||||||
sigc::signal<void(int)>& TrCore::signal_blocklist_updated()
|
sigc::signal<void(int)>& Session::signal_blocklist_updated()
|
||||||
{
|
{
|
||||||
return impl_->signal_blocklist_updated;
|
return impl_->signal_blocklist_updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
sigc::signal<void(bool)>& TrCore::signal_busy()
|
sigc::signal<void(bool)>& Session::signal_busy()
|
||||||
{
|
{
|
||||||
return impl_->signal_busy;
|
return impl_->signal_busy;
|
||||||
}
|
}
|
||||||
|
|
||||||
sigc::signal<void(tr_quark)>& TrCore::signal_prefs_changed()
|
sigc::signal<void(tr_quark)>& Session::signal_prefs_changed()
|
||||||
{
|
{
|
||||||
return impl_->signal_prefs_changed;
|
return impl_->signal_prefs_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
sigc::signal<void(bool)>& TrCore::signal_port_tested()
|
sigc::signal<void(bool)>& Session::signal_port_tested()
|
||||||
{
|
{
|
||||||
return impl_->signal_port_tested;
|
return impl_->signal_port_tested;
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
#define TR_RESOURCE_PATH "/com/transmissionbt/transmission/"
|
#define TR_RESOURCE_PATH "/com/transmissionbt/transmission/"
|
||||||
|
|
||||||
class TrCore : public Glib::Object
|
class Session : public Glib::Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum ErrorCode
|
enum ErrorCode
|
||||||
@@ -45,9 +45,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~TrCore() override;
|
~Session() override;
|
||||||
|
|
||||||
static Glib::RefPtr<TrCore> create(tr_session* session);
|
static Glib::RefPtr<Session> create(tr_session* session);
|
||||||
|
|
||||||
tr_session* close();
|
tr_session* close();
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ public:
|
|||||||
sigc::signal<void(bool)>& signal_port_tested();
|
sigc::signal<void(bool)>& signal_port_tested();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TrCore(tr_session* session);
|
Session(tr_session* session);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Impl;
|
class Impl;
|
||||||
@@ -9,11 +9,11 @@
|
|||||||
#include <glibmm.h>
|
#include <glibmm.h>
|
||||||
#include <glibmm/i18n.h>
|
#include <glibmm/i18n.h>
|
||||||
|
|
||||||
#include "hig.h"
|
#include "HigWorkarea.h"
|
||||||
#include "stats.h"
|
#include "PrefsDialog.h"
|
||||||
#include "tr-core.h"
|
#include "Session.h"
|
||||||
#include "tr-prefs.h"
|
#include "StatsDialog.h"
|
||||||
#include "util.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@@ -23,7 +23,7 @@ enum
|
|||||||
class StatsDialog::Impl
|
class StatsDialog::Impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Impl(StatsDialog& dialog, Glib::RefPtr<TrCore> const& core);
|
Impl(StatsDialog& dialog, Glib::RefPtr<Session> const& core);
|
||||||
~Impl();
|
~Impl();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -32,7 +32,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
StatsDialog& dialog_;
|
StatsDialog& dialog_;
|
||||||
Glib::RefPtr<TrCore> const core_;
|
Glib::RefPtr<Session> const core_;
|
||||||
|
|
||||||
Gtk::Label* one_up_lb_;
|
Gtk::Label* one_up_lb_;
|
||||||
Gtk::Label* one_down_lb_;
|
Gtk::Label* one_down_lb_;
|
||||||
@@ -118,12 +118,12 @@ void StatsDialog::Impl::dialogResponse(int response)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<StatsDialog> StatsDialog::create(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core)
|
std::unique_ptr<StatsDialog> StatsDialog::create(Gtk::Window& parent, Glib::RefPtr<Session> const& core)
|
||||||
{
|
{
|
||||||
return std::unique_ptr<StatsDialog>(new StatsDialog(parent, core));
|
return std::unique_ptr<StatsDialog>(new StatsDialog(parent, core));
|
||||||
}
|
}
|
||||||
|
|
||||||
StatsDialog::StatsDialog(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core)
|
StatsDialog::StatsDialog(Gtk::Window& parent, Glib::RefPtr<Session> const& core)
|
||||||
: Gtk::Dialog(_("Statistics"), parent)
|
: Gtk::Dialog(_("Statistics"), parent)
|
||||||
, impl_(std::make_unique<Impl>(*this, core))
|
, impl_(std::make_unique<Impl>(*this, core))
|
||||||
{
|
{
|
||||||
@@ -131,7 +131,7 @@ StatsDialog::StatsDialog(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core)
|
|||||||
|
|
||||||
StatsDialog::~StatsDialog() = default;
|
StatsDialog::~StatsDialog() = default;
|
||||||
|
|
||||||
StatsDialog::Impl::Impl(StatsDialog& dialog, Glib::RefPtr<TrCore> const& core)
|
StatsDialog::Impl::Impl(StatsDialog& dialog, Glib::RefPtr<Session> const& core)
|
||||||
: dialog_(dialog)
|
: dialog_(dialog)
|
||||||
, core_(core)
|
, core_(core)
|
||||||
{
|
{
|
||||||
@@ -12,17 +12,17 @@
|
|||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
|
||||||
class TrCore;
|
class Session;
|
||||||
|
|
||||||
class StatsDialog : public Gtk::Dialog
|
class StatsDialog : public Gtk::Dialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~StatsDialog() override;
|
~StatsDialog() override;
|
||||||
|
|
||||||
static std::unique_ptr<StatsDialog> create(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core);
|
static std::unique_ptr<StatsDialog> create(Gtk::Window& parent, Glib::RefPtr<Session> const& core);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
StatsDialog(Gtk::Window& parent, Glib::RefPtr<TrCore> const& core);
|
StatsDialog(Gtk::Window& parent, Glib::RefPtr<Session> const& core);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Impl;
|
class Impl;
|
||||||
@@ -17,17 +17,17 @@
|
|||||||
#include <libtransmission/transmission.h>
|
#include <libtransmission/transmission.h>
|
||||||
#include <libtransmission/utils.h>
|
#include <libtransmission/utils.h>
|
||||||
|
|
||||||
#include "actions.h"
|
#include "Actions.h"
|
||||||
#include "tr-core.h"
|
#include "Session.h"
|
||||||
#include "tr-icon.h"
|
#include "SystemTrayIcon.h"
|
||||||
#include "util.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#define ICON_NAME "transmission"
|
#define ICON_NAME "transmission"
|
||||||
|
|
||||||
class SystemTrayIcon::Impl
|
class SystemTrayIcon::Impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Impl(Glib::RefPtr<TrCore> const& core);
|
Impl(Glib::RefPtr<Session> const& core);
|
||||||
~Impl();
|
~Impl();
|
||||||
|
|
||||||
void refresh();
|
void refresh();
|
||||||
@@ -37,7 +37,7 @@ private:
|
|||||||
void popup(guint button, guint when);
|
void popup(guint button, guint when);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Glib::RefPtr<TrCore> const core_;
|
Glib::RefPtr<Session> const core_;
|
||||||
|
|
||||||
Gtk::Menu* menu_;
|
Gtk::Menu* menu_;
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ std::string getIconName()
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
SystemTrayIcon::SystemTrayIcon(Glib::RefPtr<TrCore> const& core)
|
SystemTrayIcon::SystemTrayIcon(Glib::RefPtr<Session> const& core)
|
||||||
: impl_(std::make_unique<Impl>(core))
|
: impl_(std::make_unique<Impl>(core))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -179,7 +179,7 @@ void SystemTrayIcon::refresh()
|
|||||||
impl_->refresh();
|
impl_->refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemTrayIcon::Impl::Impl(Glib::RefPtr<TrCore> const& core)
|
SystemTrayIcon::Impl::Impl(Glib::RefPtr<Session> const& core)
|
||||||
: core_(core)
|
: core_(core)
|
||||||
{
|
{
|
||||||
auto const icon_name = getIconName();
|
auto const icon_name = getIconName();
|
||||||
@@ -10,10 +10,12 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
class Session;
|
||||||
|
|
||||||
class SystemTrayIcon
|
class SystemTrayIcon
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SystemTrayIcon(Glib::RefPtr<TrCore> const& core);
|
SystemTrayIcon(Glib::RefPtr<Session> const& core);
|
||||||
~SystemTrayIcon();
|
~SystemTrayIcon();
|
||||||
|
|
||||||
void refresh();
|
void refresh();
|
||||||
@@ -14,10 +14,10 @@
|
|||||||
#include <libtransmission/transmission.h>
|
#include <libtransmission/transmission.h>
|
||||||
#include <libtransmission/utils.h> /* tr_truncd() */
|
#include <libtransmission/utils.h> /* tr_truncd() */
|
||||||
|
|
||||||
#include "hig.h"
|
#include "HigWorkarea.h"
|
||||||
#include "icons.h"
|
#include "IconCache.h"
|
||||||
#include "torrent-cell-renderer.h"
|
#include "TorrentCellRenderer.h"
|
||||||
#include "util.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
/* #define TEST_RTL */
|
/* #define TEST_RTL */
|
||||||
|
|
||||||
@@ -22,11 +22,11 @@
|
|||||||
#include <libtransmission/web.h> /* tr_webResponseStr() */
|
#include <libtransmission/web.h> /* tr_webResponseStr() */
|
||||||
#include <libtransmission/version.h> /* SHORT_VERSION_STRING */
|
#include <libtransmission/version.h> /* SHORT_VERSION_STRING */
|
||||||
|
|
||||||
#include "conf.h"
|
#include "HigWorkarea.h"
|
||||||
#include "hig.h"
|
#include "Prefs.h"
|
||||||
#include "tr-core.h"
|
#include "PrefsDialog.h"
|
||||||
#include "tr-prefs.h"
|
#include "Session.h"
|
||||||
#include "util.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
/***
|
/***
|
||||||
**** UNITS
|
**** UNITS
|
||||||
@@ -574,74 +574,3 @@ void gtr_label_set_text(Gtk::Label& lb, Glib::ustring const& newstr)
|
|||||||
lb.set_text(newstr);
|
lb.set_text(newstr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
|
||||||
****
|
|
||||||
***/
|
|
||||||
|
|
||||||
class FreeSpaceLabel::Impl
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Impl(FreeSpaceLabel& label, Glib::RefPtr<TrCore> const& core, std::string const& dir);
|
|
||||||
~Impl();
|
|
||||||
|
|
||||||
void set_dir(std::string const& dir);
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool on_freespace_timer();
|
|
||||||
|
|
||||||
private:
|
|
||||||
FreeSpaceLabel& label_;
|
|
||||||
Glib::RefPtr<TrCore> const core_;
|
|
||||||
std::string dir_;
|
|
||||||
sigc::connection timer_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
FreeSpaceLabel::Impl::~Impl()
|
|
||||||
{
|
|
||||||
timer_id_.disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FreeSpaceLabel::Impl::on_freespace_timer()
|
|
||||||
{
|
|
||||||
auto* const session = core_->get_session();
|
|
||||||
if (session == nullptr)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto const bytes = tr_sessionGetDirFreeSpace(session, dir_.c_str());
|
|
||||||
auto const text = bytes < 0 ? _("Error") : gtr_sprintf(_("%s free"), tr_strlsize(bytes));
|
|
||||||
auto const markup = gtr_sprintf("<i>%s</i>", text);
|
|
||||||
label_.set_markup(markup);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
FreeSpaceLabel::FreeSpaceLabel(Glib::RefPtr<TrCore> const& core, std::string const& dir)
|
|
||||||
: Gtk::Label()
|
|
||||||
, impl_(std::make_unique<Impl>(*this, core, dir))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
FreeSpaceLabel::~FreeSpaceLabel() = default;
|
|
||||||
|
|
||||||
FreeSpaceLabel::Impl::Impl(FreeSpaceLabel& label, Glib::RefPtr<TrCore> const& core, std::string const& dir)
|
|
||||||
: label_(label)
|
|
||||||
, core_(core)
|
|
||||||
, dir_(dir)
|
|
||||||
{
|
|
||||||
timer_id_ = Glib::signal_timeout().connect_seconds(sigc::mem_fun(this, &Impl::on_freespace_timer), 3);
|
|
||||||
on_freespace_timer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FreeSpaceLabel::set_dir(std::string const& dir)
|
|
||||||
{
|
|
||||||
impl_->set_dir(dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FreeSpaceLabel::Impl::set_dir(std::string const& dir)
|
|
||||||
{
|
|
||||||
dir_ = dir;
|
|
||||||
on_freespace_timer();
|
|
||||||
}
|
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <glibmm.h>
|
#include <glibmm.h>
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
|
||||||
@@ -102,25 +103,6 @@ void gtr_combo_box_set_active_enum(Gtk::ComboBox&, int value);
|
|||||||
****
|
****
|
||||||
***/
|
***/
|
||||||
|
|
||||||
class TrCore;
|
|
||||||
|
|
||||||
class FreeSpaceLabel : public Gtk::Label
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
FreeSpaceLabel(Glib::RefPtr<TrCore> const& core, std::string const& dir = {});
|
|
||||||
~FreeSpaceLabel() override;
|
|
||||||
|
|
||||||
void set_dir(std::string const& dir);
|
|
||||||
|
|
||||||
private:
|
|
||||||
class Impl;
|
|
||||||
std::unique_ptr<Impl> const impl_;
|
|
||||||
};
|
|
||||||
|
|
||||||
/***
|
|
||||||
****
|
|
||||||
***/
|
|
||||||
|
|
||||||
void gtr_unrecognized_url_dialog(Gtk::Widget& parent, Glib::ustring const& url);
|
void gtr_unrecognized_url_dialog(Gtk::Widget& parent, Glib::ustring const& url);
|
||||||
|
|
||||||
void gtr_add_torrent_error_dialog(
|
void gtr_add_torrent_error_dialog(
|
||||||
@@ -30,10 +30,10 @@
|
|||||||
#include <libtransmission/utils.h>
|
#include <libtransmission/utils.h>
|
||||||
#include <libtransmission/version.h>
|
#include <libtransmission/version.h>
|
||||||
|
|
||||||
#include "application.h"
|
#include "Application.h"
|
||||||
#include "conf.h"
|
#include "Notify.h"
|
||||||
#include "notify.h"
|
#include "Prefs.h"
|
||||||
#include "util.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#define MY_CONFIG_NAME "transmission"
|
#define MY_CONFIG_NAME "transmission"
|
||||||
#define MY_READABLE_NAME "transmission-gtk"
|
#define MY_READABLE_NAME "transmission-gtk"
|
||||||
|
|||||||
Reference in New Issue
Block a user