2009-07-22 15:55:48 +00:00
|
|
|
/*
|
2014-01-19 01:09:44 +00:00
|
|
|
* This file Copyright (C) 2008-2014 Mnemosyne LLC
|
2006-08-13 00:26:52 +00:00
|
|
|
*
|
2014-01-21 03:10:30 +00:00
|
|
|
* It may be used under the GNU GPL versions 2 or 3
|
2014-01-19 01:09:44 +00:00
|
|
|
* or any future license endorsed by Mnemosyne LLC.
|
2006-08-13 00:26:52 +00:00
|
|
|
*
|
2009-07-22 15:55:48 +00:00
|
|
|
*/
|
|
|
|
|
2016-03-29 16:37:21 +00:00
|
|
|
#pragma once
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
2010-04-21 19:23:27 +00:00
|
|
|
#include <glib.h>
|
2009-08-14 12:53:08 +00:00
|
|
|
#include <gtk/gtk.h>
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2010-07-03 00:25:22 +00:00
|
|
|
#include <libtransmission/transmission.h>
|
2021-08-15 09:41:48 +00:00
|
|
|
#include <libtransmission/tr-macros.h>
|
2010-07-03 00:25:22 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
extern int const mem_K;
|
|
|
|
extern char const* mem_K_str;
|
|
|
|
extern char const* mem_M_str;
|
|
|
|
extern char const* mem_G_str;
|
|
|
|
extern char const* mem_T_str;
|
|
|
|
|
|
|
|
extern int const disk_K;
|
|
|
|
extern char const* disk_K_str;
|
|
|
|
extern char const* disk_M_str;
|
|
|
|
extern char const* disk_G_str;
|
|
|
|
extern char const* disk_T_str;
|
|
|
|
|
|
|
|
extern int const speed_K;
|
|
|
|
extern char const* speed_K_str;
|
|
|
|
extern char const* speed_M_str;
|
|
|
|
extern char const* speed_G_str;
|
|
|
|
extern char const* speed_T_str;
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
#if GLIB_CHECK_VERSION(2, 33, 12)
|
|
|
|
|
|
|
|
#define TR_DEFINE_QUARK G_DEFINE_QUARK
|
2010-07-03 00:25:22 +00:00
|
|
|
|
2013-07-24 00:13:31 +00:00
|
|
|
#else
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
#define TR_DEFINE_QUARK(QN, q_n) \
|
2021-08-15 09:41:48 +00:00
|
|
|
GQuark q_n##_quark(void) \
|
2017-04-19 12:04:45 +00:00
|
|
|
{ \
|
|
|
|
static GQuark q; \
|
2021-08-15 09:41:48 +00:00
|
|
|
\
|
2020-09-14 02:41:32 +00:00
|
|
|
if (G_UNLIKELY(q == 0)) \
|
2017-04-19 12:04:45 +00:00
|
|
|
{ \
|
|
|
|
q = g_quark_from_static_string(#QN); \
|
|
|
|
} \
|
2021-08-15 09:41:48 +00:00
|
|
|
\
|
2017-04-19 12:04:45 +00:00
|
|
|
return q; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2013-07-24 00:13:31 +00:00
|
|
|
|
2010-03-20 14:53:08 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
GTR_UNICODE_UP,
|
|
|
|
GTR_UNICODE_DOWN,
|
2010-12-22 07:00:25 +00:00
|
|
|
GTR_UNICODE_INF,
|
|
|
|
GTR_UNICODE_BULLET
|
2010-03-20 14:53:08 +00:00
|
|
|
};
|
2017-04-19 12:04:45 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
char const* gtr_get_unicode_string(int);
|
2010-03-20 14:53:08 +00:00
|
|
|
|
2010-06-22 22:30:58 +00:00
|
|
|
/* return a percent formatted string of either x.xx, xx.x or xxx */
|
2017-04-19 12:04:45 +00:00
|
|
|
char* tr_strlpercent(char* buf, double x, size_t buflen);
|
2010-03-20 14:53:08 +00:00
|
|
|
|
2007-12-19 02:46:30 +00:00
|
|
|
/* return a human-readable string for the size given in bytes. */
|
2017-04-21 07:40:57 +00:00
|
|
|
char* tr_strlsize(char* buf, guint64 size, size_t buflen);
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2008-01-04 18:52:39 +00:00
|
|
|
/* return a human-readable string for the given ratio. */
|
2017-04-19 12:04:45 +00:00
|
|
|
char* tr_strlratio(char* buf, double ratio, size_t buflen);
|
2008-01-04 18:52:39 +00:00
|
|
|
|
2007-12-26 06:38:33 +00:00
|
|
|
/* return a human-readable string for the time given in seconds. */
|
2020-11-05 22:46:21 +00:00
|
|
|
char* tr_strltime(char* buf, time_t secs, size_t buflen);
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2009-07-22 15:55:48 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2010-04-23 01:46:02 +00:00
|
|
|
/* http://www.legaltorrents.com/some/announce/url --> legaltorrents.com */
|
2017-04-20 16:02:19 +00:00
|
|
|
void gtr_get_host_from_url(char* buf, size_t buflen, char const* url);
|
2010-04-23 01:46:02 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
gboolean gtr_is_magnet_link(char const* str);
|
2009-11-22 16:20:22 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
gboolean gtr_is_hex_hashcode(char const* str);
|
2009-11-29 07:42:39 +00:00
|
|
|
|
2009-07-22 15:55:48 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
void gtr_open_uri(char const* uri);
|
2010-09-22 16:44:38 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
void gtr_open_file(char const* path);
|
2008-04-11 02:21:33 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
char const* gtr_get_help_uri(void);
|
2008-05-18 16:44:30 +00:00
|
|
|
|
2009-07-22 15:55:48 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2017-04-21 07:40:57 +00:00
|
|
|
/* backwards-compatible wrapper around gtk_widget_set_visible() */
|
2017-04-19 12:04:45 +00:00
|
|
|
void gtr_widget_set_visible(GtkWidget*, gboolean);
|
2010-07-24 03:07:04 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void gtr_dialog_set_content(GtkDialog* dialog, GtkWidget* content);
|
2010-12-22 03:12:47 +00:00
|
|
|
|
2010-02-02 07:51:45 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
GtkWidget* gtr_priority_combo_new(void);
|
|
|
|
#define gtr_priority_combo_get_value(w) gtr_combo_box_get_active_enum(w)
|
2017-04-21 07:40:57 +00:00
|
|
|
#define gtr_priority_combo_set_value(w, val) gtr_combo_box_set_active_enum(w, val)
|
2010-07-23 06:54:49 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
GtkWidget* gtr_combo_box_new_enum(char const* text_1, ...);
|
2017-04-19 12:04:45 +00:00
|
|
|
int gtr_combo_box_get_active_enum(GtkComboBox*);
|
|
|
|
void gtr_combo_box_set_active_enum(GtkComboBox*, int value);
|
2010-02-02 07:51:45 +00:00
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2013-02-09 04:05:03 +00:00
|
|
|
struct _TrCore;
|
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
GtkWidget* gtr_freespace_label_new(struct _TrCore* core, char const* dir);
|
2013-02-09 04:05:03 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
void gtr_freespace_label_set_dir(GtkWidget* label, char const* dir);
|
2013-02-09 04:05:03 +00:00
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
void gtr_unrecognized_url_dialog(GtkWidget* parent, char const* url);
|
2010-02-05 13:59:44 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
void gtr_add_torrent_error_dialog(GtkWidget* window_or_child, int err, tr_torrent* duplicate_torrent, char const* filename);
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
/* pop up the context menu if a user right-clicks.
|
|
|
|
if the row they right-click on isn't selected, select it. */
|
2017-04-19 12:04:45 +00:00
|
|
|
gboolean on_tree_view_button_pressed(GtkWidget* view, GdkEventButton* event, gpointer unused);
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2008-09-27 18:01:31 +00:00
|
|
|
/* if the click didn't specify a row, clear the selection */
|
2017-04-19 12:04:45 +00:00
|
|
|
gboolean on_tree_view_button_released(GtkWidget* view, GdkEventButton* event, gpointer unused);
|
2008-01-15 17:55:09 +00:00
|
|
|
|
2009-07-22 15:55:48 +00:00
|
|
|
/* move a file to the trashcan if GIO is available; otherwise, delete it */
|
2017-04-20 16:02:19 +00:00
|
|
|
bool gtr_file_trash_or_remove(char const* filename, struct tr_error** error);
|
2008-03-09 15:27:08 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void gtr_paste_clipboard_url_into_entry(GtkWidget* entry);
|
2011-01-14 21:57:20 +00:00
|
|
|
|
2017-04-21 07:40:57 +00:00
|
|
|
/* Only call gtk_label_set_text() if the new text differs from the old.
|
2011-01-21 16:32:27 +00:00
|
|
|
* This prevents the label from having to recalculate its size
|
|
|
|
* and prevents selected text in the label from being deselected */
|
2017-04-20 16:02:19 +00:00
|
|
|
void gtr_label_set_text(GtkLabel* lb, char const* text);
|