2009-06-06 04:40:24 +00:00
|
|
|
/*
|
2014-01-19 01:09:44 +00:00
|
|
|
* This file Copyright (C) 2009-2014 Mnemosyne LLC
|
2008-02-10 22:25:42 +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.
|
2008-02-10 22:25:42 +00:00
|
|
|
*
|
2009-06-06 04:40:24 +00:00
|
|
|
*/
|
2008-02-10 22:25:42 +00:00
|
|
|
|
2013-08-24 17:53:45 +00:00
|
|
|
#include <limits.h> /* INT_MAX */
|
2008-02-10 22:25:42 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdio.h>
|
2008-08-21 14:57:59 +00:00
|
|
|
#include <string.h>
|
2008-02-10 22:25:42 +00:00
|
|
|
#include <glib/gi18n.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include <libtransmission/transmission.h>
|
2011-03-03 01:59:25 +00:00
|
|
|
#include <libtransmission/utils.h>
|
2008-02-10 22:25:42 +00:00
|
|
|
|
2008-02-12 18:53:31 +00:00
|
|
|
#include "file-list.h"
|
2008-02-10 22:25:42 +00:00
|
|
|
#include "hig.h"
|
2009-03-02 23:31:01 +00:00
|
|
|
#include "icons.h"
|
2010-02-01 04:54:10 +00:00
|
|
|
#include "tr-prefs.h"
|
2011-03-03 01:59:25 +00:00
|
|
|
#include "util.h"
|
2008-02-10 22:25:42 +00:00
|
|
|
|
2011-01-05 07:08:34 +00:00
|
|
|
#define TR_COLUMN_ID_KEY "tr-model-column-id-key"
|
|
|
|
|
2008-05-29 02:59:22 +00:00
|
|
|
enum
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
/* these two fields could be any number at all so long as they're not
|
|
|
|
* TR_PRI_LOW, TR_PRI_NORMAL, TR_PRI_HIGH, TRUE, or FALSE */
|
|
|
|
NOT_SET = 1000,
|
|
|
|
MIXED = 1001
|
2008-05-29 02:59:22 +00:00
|
|
|
};
|
|
|
|
|
2008-02-10 22:25:42 +00:00
|
|
|
enum
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
FC_ICON,
|
|
|
|
FC_LABEL,
|
|
|
|
FC_LABEL_ESC,
|
|
|
|
FC_PROG,
|
|
|
|
FC_INDEX,
|
|
|
|
FC_SIZE,
|
|
|
|
FC_SIZE_STR,
|
|
|
|
FC_HAVE,
|
|
|
|
FC_PRIORITY,
|
|
|
|
FC_ENABLED,
|
|
|
|
N_FILE_COLS
|
2008-02-10 22:25:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
TrCore* core;
|
|
|
|
GtkWidget* top;
|
|
|
|
GtkWidget* view;
|
|
|
|
GtkTreeModel* model; /* same object as store, but recast */
|
|
|
|
GtkTreeStore* store; /* same object as model, but recast */
|
|
|
|
int torrentId;
|
|
|
|
guint timeout_tag;
|
2021-08-15 09:41:48 +00:00
|
|
|
} FileData;
|
2008-02-10 22:25:42 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
static void clearData(FileData* data)
|
2008-02-10 22:25:42 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
data->torrentId = -1;
|
2008-05-29 02:59:22 +00:00
|
|
|
|
2017-04-30 16:25:26 +00:00
|
|
|
if (data->timeout_tag != 0)
|
2013-07-20 16:19:15 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
g_source_remove(data->timeout_tag);
|
|
|
|
data->timeout_tag = 0;
|
2008-02-10 22:25:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
static void freeData(gpointer data)
|
2008-02-10 22:25:42 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
clearData(data);
|
|
|
|
g_free(data);
|
2008-02-10 22:25:42 +00:00
|
|
|
}
|
|
|
|
|
2008-05-29 02:59:22 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2010-09-17 13:23:20 +00:00
|
|
|
struct RefreshData
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
int sort_column_id;
|
|
|
|
gboolean resort_needed;
|
2010-09-17 13:23:20 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
tr_file_stat* refresh_file_stat;
|
|
|
|
tr_torrent* tor;
|
2010-09-17 13:23:20 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
FileData* file_data;
|
2010-09-17 13:23:20 +00:00
|
|
|
};
|
|
|
|
|
2020-08-18 10:36:10 +00:00
|
|
|
static gboolean refreshFilesForeach(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer gdata)
|
2008-05-29 02:59:22 +00:00
|
|
|
{
|
2020-08-18 10:36:10 +00:00
|
|
|
TR_UNUSED(path);
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
struct RefreshData* refresh_data = gdata;
|
|
|
|
FileData* data = refresh_data->file_data;
|
|
|
|
unsigned int index;
|
|
|
|
uint64_t size;
|
|
|
|
uint64_t old_have;
|
|
|
|
int old_prog;
|
|
|
|
int old_priority;
|
|
|
|
int old_enabled;
|
2017-04-20 16:02:19 +00:00
|
|
|
gboolean const is_file = !gtk_tree_model_iter_has_child(model, iter);
|
2017-04-19 12:04:45 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
gtk_tree_model_get(
|
|
|
|
model,
|
|
|
|
iter,
|
|
|
|
TR_ARG_TUPLE(FC_ENABLED, &old_enabled),
|
|
|
|
TR_ARG_TUPLE(FC_PRIORITY, &old_priority),
|
|
|
|
TR_ARG_TUPLE(FC_INDEX, &index),
|
|
|
|
TR_ARG_TUPLE(FC_HAVE, &old_have),
|
|
|
|
TR_ARG_TUPLE(FC_SIZE, &size),
|
|
|
|
TR_ARG_TUPLE(FC_PROG, &old_prog),
|
2017-04-19 12:04:45 +00:00
|
|
|
-1);
|
|
|
|
|
|
|
|
if (is_file)
|
2008-09-23 19:11:04 +00:00
|
|
|
{
|
2020-11-05 22:46:21 +00:00
|
|
|
tr_torrent const* tor = refresh_data->tor;
|
2017-04-20 16:02:19 +00:00
|
|
|
tr_info const* inf = tr_torrentInfo(tor);
|
2017-05-01 15:47:49 +00:00
|
|
|
int const enabled = inf->files[index].dnd ? 0 : 1;
|
2017-04-20 16:02:19 +00:00
|
|
|
int const priority = inf->files[index].priority;
|
|
|
|
uint64_t const have = refresh_data->refresh_file_stat[index].bytesCompleted;
|
2017-05-01 15:47:49 +00:00
|
|
|
int const prog = size != 0 ? (int)(100.0 * have / size) : 1;
|
2017-04-19 12:04:45 +00:00
|
|
|
|
2017-04-30 16:25:26 +00:00
|
|
|
if (priority != old_priority || enabled != old_enabled || have != old_have || prog != old_prog)
|
2010-09-17 13:23:20 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
/* Changing a value in the sort column can trigger a resort
|
|
|
|
* which breaks this foreach () call. (See #3529)
|
|
|
|
* As a workaround: if that's about to happen, temporarily disable
|
|
|
|
* sorting until we finish walking the tree. */
|
2020-11-01 21:47:57 +00:00
|
|
|
if (!refresh_data->resort_needed &&
|
|
|
|
(((refresh_data->sort_column_id == FC_PRIORITY) && (priority != old_priority)) ||
|
2021-08-15 09:41:48 +00:00
|
|
|
((refresh_data->sort_column_id == FC_ENABLED) && (enabled != old_enabled))))
|
2010-09-17 13:23:20 +00:00
|
|
|
{
|
2020-11-01 21:47:57 +00:00
|
|
|
refresh_data->resort_needed = TRUE;
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
gtk_tree_sortable_set_sort_column_id(
|
|
|
|
GTK_TREE_SORTABLE(data->model),
|
|
|
|
GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID,
|
|
|
|
GTK_SORT_ASCENDING);
|
2010-09-17 13:23:20 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
gtk_tree_store_set(
|
|
|
|
data->store,
|
|
|
|
iter,
|
|
|
|
TR_ARG_TUPLE(FC_PRIORITY, priority),
|
|
|
|
TR_ARG_TUPLE(FC_ENABLED, enabled),
|
|
|
|
TR_ARG_TUPLE(FC_HAVE, have),
|
|
|
|
TR_ARG_TUPLE(FC_PROG, prog),
|
2017-04-19 12:04:45 +00:00
|
|
|
-1);
|
2010-09-17 13:23:20 +00:00
|
|
|
}
|
2009-06-06 04:29:08 +00:00
|
|
|
}
|
2017-04-19 12:04:45 +00:00
|
|
|
else
|
2009-06-06 04:29:08 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
GtkTreeIter child;
|
|
|
|
uint64_t sub_size = 0;
|
|
|
|
uint64_t have = 0;
|
|
|
|
int prog;
|
|
|
|
int enabled = NOT_SET;
|
|
|
|
int priority = NOT_SET;
|
2009-06-06 04:29:08 +00:00
|
|
|
|
2017-04-21 07:40:57 +00:00
|
|
|
/* since gtk_tree_model_foreach() is depth-first, we can
|
2017-04-19 12:04:45 +00:00
|
|
|
* get the `sub' info by walking the immediate children */
|
2009-06-06 04:29:08 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
if (gtk_tree_model_iter_children(model, &child, iter))
|
2009-06-06 04:29:08 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
do
|
2013-02-09 19:28:38 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
int child_enabled;
|
|
|
|
int child_priority;
|
2017-05-01 15:46:41 +00:00
|
|
|
int64_t child_have;
|
|
|
|
int64_t child_size;
|
2017-04-19 12:04:45 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
gtk_tree_model_get(
|
|
|
|
model,
|
|
|
|
&child,
|
|
|
|
TR_ARG_TUPLE(FC_SIZE, &child_size),
|
|
|
|
TR_ARG_TUPLE(FC_HAVE, &child_have),
|
|
|
|
TR_ARG_TUPLE(FC_PRIORITY, &child_priority),
|
|
|
|
TR_ARG_TUPLE(FC_ENABLED, &child_enabled),
|
2017-04-19 12:04:45 +00:00
|
|
|
-1);
|
|
|
|
|
|
|
|
if ((child_enabled != FALSE) && (child_enabled != NOT_SET))
|
|
|
|
{
|
|
|
|
sub_size += child_size;
|
|
|
|
have += child_have;
|
|
|
|
}
|
2009-06-10 00:04:43 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
if (enabled == NOT_SET)
|
|
|
|
{
|
|
|
|
enabled = child_enabled;
|
|
|
|
}
|
|
|
|
else if (enabled != child_enabled)
|
|
|
|
{
|
|
|
|
enabled = MIXED;
|
|
|
|
}
|
2009-06-10 00:04:43 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
if (priority == NOT_SET)
|
|
|
|
{
|
|
|
|
priority = child_priority;
|
|
|
|
}
|
|
|
|
else if (priority != child_priority)
|
|
|
|
{
|
|
|
|
priority = MIXED;
|
|
|
|
}
|
2021-08-15 09:41:48 +00:00
|
|
|
} while (gtk_tree_model_iter_next(model, &child));
|
2009-06-06 04:29:08 +00:00
|
|
|
}
|
|
|
|
|
2017-04-30 16:25:26 +00:00
|
|
|
prog = sub_size != 0 ? (int)(100.0 * have / sub_size) : 1;
|
2009-06-06 04:29:08 +00:00
|
|
|
|
2017-04-30 16:25:26 +00:00
|
|
|
if (size != sub_size || have != old_have || priority != old_priority || enabled != old_enabled || prog != old_prog)
|
2011-01-06 17:21:55 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
char size_str[64];
|
2017-05-20 16:29:23 +00:00
|
|
|
tr_strlsize(size_str, sub_size, sizeof(size_str));
|
2021-08-15 09:41:48 +00:00
|
|
|
gtk_tree_store_set(
|
|
|
|
data->store,
|
|
|
|
iter,
|
|
|
|
TR_ARG_TUPLE(FC_SIZE, sub_size),
|
|
|
|
TR_ARG_TUPLE(FC_SIZE_STR, size_str),
|
|
|
|
TR_ARG_TUPLE(FC_HAVE, have),
|
|
|
|
TR_ARG_TUPLE(FC_PRIORITY, priority),
|
|
|
|
TR_ARG_TUPLE(FC_ENABLED, enabled),
|
|
|
|
TR_ARG_TUPLE(FC_PROG, prog),
|
2017-04-19 12:04:45 +00:00
|
|
|
-1);
|
2011-01-06 17:21:55 +00:00
|
|
|
}
|
2008-05-29 02:59:22 +00:00
|
|
|
}
|
2009-06-06 04:29:08 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
return FALSE; /* keep walking */
|
2008-02-10 22:25:42 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
static void gtr_tree_model_foreach_postorder_subtree(
|
|
|
|
GtkTreeModel* model,
|
|
|
|
GtkTreeIter* parent,
|
|
|
|
GtkTreeModelForeachFunc func,
|
2017-04-19 12:04:45 +00:00
|
|
|
gpointer data)
|
2008-02-10 22:25:42 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
GtkTreeIter child;
|
|
|
|
|
|
|
|
if (gtk_tree_model_iter_children(model, &child, parent))
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
gtr_tree_model_foreach_postorder_subtree(model, &child, func, data);
|
2021-08-15 09:41:48 +00:00
|
|
|
} while (gtk_tree_model_iter_next(model, &child));
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
|
|
|
|
2017-04-30 16:25:26 +00:00
|
|
|
if (parent != NULL)
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
|
|
|
func(model, NULL, parent, data);
|
|
|
|
}
|
2008-05-29 02:59:22 +00:00
|
|
|
}
|
2008-02-10 22:25:42 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
static void gtr_tree_model_foreach_postorder(GtkTreeModel* model, GtkTreeModelForeachFunc func, gpointer data)
|
2008-05-29 02:59:22 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
if (gtk_tree_model_iter_nth_child(model, &iter, NULL, 0))
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
gtr_tree_model_foreach_postorder_subtree(model, &iter, func, data);
|
2021-08-15 09:41:48 +00:00
|
|
|
} while (gtk_tree_model_iter_next(model, &iter));
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
2008-05-29 02:59:22 +00:00
|
|
|
}
|
2008-02-10 22:25:42 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
static void refresh(FileData* data)
|
2008-05-29 02:59:22 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
tr_torrent* tor = gtr_core_find_torrent(data->core, data->torrentId);
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
if (tor == NULL)
|
2009-04-24 01:37:04 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
gtr_file_list_clear(data->top);
|
2009-04-24 01:37:04 +00:00
|
|
|
}
|
2017-04-19 12:04:45 +00:00
|
|
|
else
|
2009-04-24 01:37:04 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
GtkSortType order;
|
|
|
|
int sort_column_id;
|
|
|
|
tr_file_index_t fileCount;
|
|
|
|
struct RefreshData refresh_data;
|
|
|
|
GtkTreeSortable* sortable = GTK_TREE_SORTABLE(data->model);
|
|
|
|
gtk_tree_sortable_get_sort_column_id(sortable, &sort_column_id, &order);
|
|
|
|
|
|
|
|
refresh_data.sort_column_id = sort_column_id;
|
|
|
|
refresh_data.resort_needed = FALSE;
|
|
|
|
refresh_data.refresh_file_stat = tr_torrentFiles(tor, &fileCount);
|
|
|
|
refresh_data.tor = tor;
|
|
|
|
refresh_data.file_data = data;
|
|
|
|
|
|
|
|
gtr_tree_model_foreach_postorder(data->model, refreshFilesForeach, &refresh_data);
|
|
|
|
|
|
|
|
if (refresh_data.resort_needed)
|
|
|
|
{
|
|
|
|
gtk_tree_sortable_set_sort_column_id(sortable, sort_column_id, order);
|
|
|
|
}
|
2009-04-24 01:37:04 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
tr_torrentFilesFree(refresh_data.refresh_file_stat, fileCount);
|
2009-04-24 01:37:04 +00:00
|
|
|
}
|
2008-02-10 22:25:42 +00:00
|
|
|
}
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
static gboolean refreshModel(gpointer file_data)
|
2008-02-10 22:25:42 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
refresh(file_data);
|
2013-01-04 16:36:52 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
return G_SOURCE_CONTINUE;
|
2008-02-10 22:25:42 +00:00
|
|
|
}
|
|
|
|
|
2008-05-29 02:59:22 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
|
|
|
struct ActiveData
|
2008-02-10 22:25:42 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
GtkTreeSelection* sel;
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
tr_file_index_t* indexBuf;
|
|
|
|
size_t indexCount;
|
2008-05-29 02:59:22 +00:00
|
|
|
};
|
|
|
|
|
2020-08-18 10:36:10 +00:00
|
|
|
static gboolean getSelectedFilesForeach(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer gdata)
|
2008-05-29 02:59:22 +00:00
|
|
|
{
|
2020-08-18 10:36:10 +00:00
|
|
|
TR_UNUSED(path);
|
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
gboolean const is_file = !gtk_tree_model_iter_has_child(model, iter);
|
2010-05-12 01:34:08 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
if (is_file)
|
2008-09-23 19:11:04 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
struct ActiveData* data = gdata;
|
2010-05-12 01:34:08 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
/* active means: if it's selected or any ancestor is selected */
|
|
|
|
gboolean is_active = gtk_tree_selection_iter_is_selected(data->sel, iter);
|
2010-05-12 01:34:08 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
if (!is_active)
|
2008-09-23 19:11:04 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
GtkTreeIter walk = *iter;
|
|
|
|
GtkTreeIter parent;
|
|
|
|
|
|
|
|
while (!is_active && gtk_tree_model_iter_parent(model, &parent, &walk))
|
2008-09-23 19:11:04 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
is_active = gtk_tree_selection_iter_is_selected(data->sel, &parent);
|
|
|
|
walk = parent;
|
2008-05-29 02:59:22 +00:00
|
|
|
}
|
|
|
|
}
|
2008-02-10 22:25:42 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
if (is_active)
|
2010-05-12 01:34:08 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
unsigned int i;
|
|
|
|
gtk_tree_model_get(model, iter, FC_INDEX, &i, -1);
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
data->indexBuf[data->indexCount++] = i;
|
2010-05-12 01:34:08 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-29 02:59:22 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
return FALSE; /* keep walking */
|
2008-02-10 22:25:42 +00:00
|
|
|
}
|
|
|
|
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
static size_t getSelectedFilesAndDescendants(GtkTreeView* view, tr_file_index_t* indexBuf)
|
2008-02-10 22:25:42 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
struct ActiveData data;
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
data.sel = gtk_tree_view_get_selection(view);
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
data.indexBuf = indexBuf;
|
|
|
|
data.indexCount = 0;
|
2017-04-19 12:04:45 +00:00
|
|
|
gtk_tree_model_foreach(gtk_tree_view_get_model(view), getSelectedFilesForeach, &data);
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
return data.indexCount;
|
2008-10-26 22:58:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct SubtreeForeachData
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
GtkTreePath* path;
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
tr_file_index_t* indexBuf;
|
|
|
|
size_t indexCount;
|
2008-10-26 22:58:57 +00:00
|
|
|
};
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
static gboolean getSubtreeForeach(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer gdata)
|
2008-10-26 22:58:57 +00:00
|
|
|
{
|
2017-04-20 16:02:19 +00:00
|
|
|
gboolean const is_file = !gtk_tree_model_iter_has_child(model, iter);
|
2008-10-26 22:58:57 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
if (is_file)
|
2010-05-12 01:34:08 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
struct SubtreeForeachData* data = gdata;
|
2010-05-12 01:34:08 +00:00
|
|
|
|
2017-04-30 16:25:26 +00:00
|
|
|
if (gtk_tree_path_compare(path, data->path) == 0 || gtk_tree_path_is_descendant(path, data->path))
|
2010-05-12 01:34:08 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
unsigned int i;
|
|
|
|
gtk_tree_model_get(model, iter, FC_INDEX, &i, -1);
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
data->indexBuf[data->indexCount++] = i;
|
2010-05-12 01:34:08 +00:00
|
|
|
}
|
|
|
|
}
|
2008-10-26 22:58:57 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
return FALSE; /* keep walking */
|
2008-10-26 22:58:57 +00:00
|
|
|
}
|
|
|
|
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
static size_t getSubtree(GtkTreeView* view, GtkTreePath* path, tr_file_index_t* indexBuf)
|
2008-10-26 22:58:57 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
struct SubtreeForeachData tmp;
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
tmp.indexBuf = indexBuf;
|
|
|
|
tmp.indexCount = 0;
|
2017-04-19 12:04:45 +00:00
|
|
|
tmp.path = path;
|
|
|
|
gtk_tree_model_foreach(gtk_tree_view_get_model(view), getSubtreeForeach, &tmp);
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
return tmp.indexCount;
|
2008-02-10 22:25:42 +00:00
|
|
|
}
|
2008-09-05 21:01:00 +00:00
|
|
|
|
2008-09-06 01:52:47 +00:00
|
|
|
/* if `path' is a selected row, all selected rows are returned.
|
|
|
|
* otherwise, only the row indicated by `path' is returned.
|
|
|
|
* this is for toggling all the selected rows' states in a batch.
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
*
|
|
|
|
* indexBuf should be large enough to hold tr_inf.fileCount files.
|
2008-09-06 01:52:47 +00:00
|
|
|
*/
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
static size_t getActiveFilesForPath(GtkTreeView* view, GtkTreePath* path, tr_file_index_t* indexBuf)
|
2008-02-15 18:20:56 +00:00
|
|
|
{
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
size_t indexCount;
|
2017-04-19 12:04:45 +00:00
|
|
|
GtkTreeSelection* sel = gtk_tree_view_get_selection(view);
|
2008-09-05 21:01:00 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
if (gtk_tree_selection_path_is_selected(sel, path))
|
2008-09-05 21:01:00 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
/* clicked in a selected row... use the current selection */
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
indexCount = getSelectedFilesAndDescendants(view, indexBuf);
|
2008-09-05 21:01:00 +00:00
|
|
|
}
|
2017-04-19 12:04:45 +00:00
|
|
|
else
|
2008-09-05 21:01:00 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
/* clicked OUTSIDE of the selected row... just use the clicked row */
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
indexCount = getSubtree(view, path, indexBuf);
|
2008-09-05 21:01:00 +00:00
|
|
|
}
|
|
|
|
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
return indexCount;
|
2008-02-15 18:20:56 +00:00
|
|
|
}
|
|
|
|
|
2008-05-29 02:59:22 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void gtr_file_list_clear(GtkWidget* w)
|
2008-02-10 22:25:42 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
gtr_file_list_set_torrent(w, -1);
|
2009-04-24 01:37:04 +00:00
|
|
|
}
|
2008-02-12 18:53:31 +00:00
|
|
|
|
2009-06-06 04:29:08 +00:00
|
|
|
struct build_data
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
GtkWidget* w;
|
|
|
|
tr_torrent* tor;
|
|
|
|
GtkTreeIter* iter;
|
|
|
|
GtkTreeStore* store;
|
2009-06-06 04:29:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct row_struct
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
uint64_t length;
|
|
|
|
char* name;
|
|
|
|
int index;
|
2009-06-06 04:29:08 +00:00
|
|
|
};
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
static void buildTree(GNode* node, gpointer gdata)
|
2009-06-06 04:29:08 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
char size_str[64];
|
|
|
|
GtkTreeIter child_iter;
|
|
|
|
struct build_data* build = gdata;
|
|
|
|
struct row_struct* child_data = node->data;
|
2017-04-20 16:02:19 +00:00
|
|
|
gboolean const isLeaf = node->children == NULL;
|
2017-04-19 12:04:45 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
char const* mime_type = isLeaf ? gtr_get_mime_type_from_filename(child_data->name) : DIRECTORY_MIME_TYPE;
|
2017-04-19 12:04:45 +00:00
|
|
|
GdkPixbuf* icon = gtr_get_mime_type_icon(mime_type, GTK_ICON_SIZE_MENU, build->w);
|
2017-04-20 16:02:19 +00:00
|
|
|
tr_info const* inf = tr_torrentInfo(build->tor);
|
2017-04-21 07:40:57 +00:00
|
|
|
int const priority = isLeaf ? inf->files[child_data->index].priority : 0;
|
|
|
|
gboolean const enabled = isLeaf ? !inf->files[child_data->index].dnd : TRUE;
|
2017-04-19 12:04:45 +00:00
|
|
|
char* name_esc = g_markup_escape_text(child_data->name, -1);
|
|
|
|
|
2017-05-20 16:29:23 +00:00
|
|
|
tr_strlsize(size_str, child_data->length, sizeof(size_str));
|
2017-04-19 12:04:45 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
gtk_tree_store_insert_with_values(
|
|
|
|
build->store,
|
|
|
|
&child_iter,
|
|
|
|
build->iter,
|
|
|
|
INT_MAX,
|
|
|
|
TR_ARG_TUPLE(FC_INDEX, child_data->index),
|
|
|
|
TR_ARG_TUPLE(FC_LABEL, child_data->name),
|
|
|
|
TR_ARG_TUPLE(FC_LABEL_ESC, name_esc),
|
|
|
|
TR_ARG_TUPLE(FC_SIZE, child_data->length),
|
|
|
|
TR_ARG_TUPLE(FC_SIZE_STR, size_str),
|
|
|
|
TR_ARG_TUPLE(FC_ICON, icon),
|
|
|
|
TR_ARG_TUPLE(FC_PRIORITY, priority),
|
|
|
|
TR_ARG_TUPLE(FC_ENABLED, enabled),
|
2017-04-19 12:04:45 +00:00
|
|
|
-1);
|
|
|
|
|
|
|
|
if (!isLeaf)
|
2009-06-06 04:29:08 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
struct build_data b = *build;
|
|
|
|
b.iter = &child_iter;
|
|
|
|
g_node_children_foreach(node, G_TRAVERSE_ALL, buildTree, &b);
|
2009-06-06 04:29:08 +00:00
|
|
|
}
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
g_free(name_esc);
|
|
|
|
g_object_unref(icon);
|
2009-08-10 20:04:08 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
/* we're done with this node */
|
|
|
|
g_free(child_data->name);
|
|
|
|
g_free(child_data);
|
2009-06-06 04:29:08 +00:00
|
|
|
}
|
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
static GNode* find_child(GNode* parent, char const* name)
|
2009-06-06 04:29:08 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
GNode* child = parent->children;
|
2013-07-20 16:19:15 +00:00
|
|
|
|
2017-05-01 15:47:49 +00:00
|
|
|
while (child != NULL)
|
2013-07-20 16:19:15 +00:00
|
|
|
{
|
2017-04-20 16:02:19 +00:00
|
|
|
struct row_struct const* child_data = child->data;
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
if (*child_data->name == *name && g_strcmp0(child_data->name, name) == 0)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
child = child->next;
|
2009-06-06 04:29:08 +00:00
|
|
|
}
|
2013-07-20 16:19:15 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
return child;
|
2009-06-06 04:29:08 +00:00
|
|
|
}
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void gtr_file_list_set_torrent(GtkWidget* w, int torrentId)
|
2009-04-24 01:37:04 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
/* unset the old fields */
|
2020-11-08 19:54:40 +00:00
|
|
|
FileData* const data = g_object_get_data(G_OBJECT(w), "file-data");
|
2017-04-19 12:04:45 +00:00
|
|
|
clearData(data);
|
|
|
|
|
|
|
|
/* instantiate the model */
|
2021-08-15 09:41:48 +00:00
|
|
|
GtkTreeStore* const store = gtk_tree_store_new(
|
|
|
|
N_FILE_COLS,
|
2017-04-21 07:40:57 +00:00
|
|
|
GDK_TYPE_PIXBUF, /* icon */
|
|
|
|
G_TYPE_STRING, /* label */
|
|
|
|
G_TYPE_STRING, /* label esc */
|
|
|
|
G_TYPE_INT, /* prog [0..100] */
|
|
|
|
G_TYPE_UINT, /* index */
|
|
|
|
G_TYPE_UINT64, /* size */
|
|
|
|
G_TYPE_STRING, /* size str */
|
|
|
|
G_TYPE_UINT64, /* have */
|
|
|
|
G_TYPE_INT, /* priority */
|
|
|
|
G_TYPE_INT); /* dl enabled */
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
data->store = store;
|
|
|
|
data->model = GTK_TREE_MODEL(store);
|
|
|
|
data->torrentId = torrentId;
|
|
|
|
|
|
|
|
/* populate the model */
|
2021-08-15 09:41:48 +00:00
|
|
|
tr_torrent* const tor = torrentId > 0 ? gtr_core_find_torrent(data->core, torrentId) : NULL;
|
2020-11-08 19:54:40 +00:00
|
|
|
if (tor != NULL)
|
2008-02-10 22:25:42 +00:00
|
|
|
{
|
2020-11-08 19:54:40 +00:00
|
|
|
// build a GNode tree of the files
|
|
|
|
struct row_struct* const root_data = g_new0(struct row_struct, 1);
|
|
|
|
root_data->name = g_strdup(tr_torrentName(tor));
|
|
|
|
root_data->index = -1;
|
|
|
|
root_data->length = 0;
|
2017-04-19 12:04:45 +00:00
|
|
|
|
2020-11-08 19:54:40 +00:00
|
|
|
GNode* const root = g_node_new(root_data);
|
|
|
|
|
|
|
|
tr_info const* inf = tr_torrentInfo(tor);
|
|
|
|
for (tr_file_index_t i = 0; i < inf->fileCount; ++i)
|
2008-02-12 18:53:31 +00:00
|
|
|
{
|
2020-11-08 19:54:40 +00:00
|
|
|
GNode* parent = root;
|
|
|
|
tr_file const* const file = &inf->files[i];
|
|
|
|
char** const tokens = g_strsplit(file->name, G_DIR_SEPARATOR_S, 0);
|
|
|
|
|
|
|
|
for (int j = 0; tokens[j] != NULL; ++j)
|
2013-07-20 16:19:15 +00:00
|
|
|
{
|
2020-11-08 19:54:40 +00:00
|
|
|
gboolean const isLeaf = tokens[j + 1] == NULL;
|
|
|
|
char const* const name = tokens[j];
|
|
|
|
GNode* node = find_child(parent, name);
|
2017-04-19 12:04:45 +00:00
|
|
|
|
2020-11-08 19:54:40 +00:00
|
|
|
if (node == NULL)
|
2013-07-20 16:19:15 +00:00
|
|
|
{
|
2020-11-08 19:54:40 +00:00
|
|
|
struct row_struct* row = g_new(struct row_struct, 1);
|
|
|
|
row->name = g_strdup(name);
|
|
|
|
row->index = isLeaf ? (int)i : -1;
|
|
|
|
row->length = isLeaf ? file->length : 0;
|
|
|
|
node = g_node_new(row);
|
|
|
|
g_node_append(parent, node);
|
2009-06-06 04:29:08 +00:00
|
|
|
}
|
2017-04-19 12:04:45 +00:00
|
|
|
|
2020-11-08 19:54:40 +00:00
|
|
|
parent = node;
|
2009-04-24 01:37:04 +00:00
|
|
|
}
|
2009-06-06 04:29:08 +00:00
|
|
|
|
2020-11-08 19:54:40 +00:00
|
|
|
g_strfreev(tokens);
|
2008-02-12 18:53:31 +00:00
|
|
|
}
|
|
|
|
|
2020-11-08 19:54:40 +00:00
|
|
|
// now, add them to the model
|
|
|
|
struct build_data build;
|
|
|
|
build.w = w;
|
|
|
|
build.tor = tor;
|
|
|
|
build.store = data->store;
|
|
|
|
build.iter = NULL;
|
|
|
|
g_node_children_foreach(root, G_TRAVERSE_ALL, buildTree, &build);
|
|
|
|
|
|
|
|
// cleanup
|
|
|
|
g_node_destroy(root);
|
|
|
|
g_free(root_data->name);
|
|
|
|
g_free(root_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (torrentId > 0)
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
refresh(data);
|
|
|
|
data->timeout_tag = gdk_threads_add_timeout_seconds(SECONDARY_WINDOW_REFRESH_INTERVAL_SECONDS, refreshModel, data);
|
2008-02-10 22:25:42 +00:00
|
|
|
}
|
2008-02-12 18:53:31 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(data->view), data->model);
|
2020-04-27 21:34:02 +00:00
|
|
|
|
|
|
|
/* set default sort by label */
|
2020-07-30 19:45:11 +00:00
|
|
|
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(data->store), FC_LABEL, GTK_SORT_ASCENDING);
|
2020-04-27 21:34:02 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
gtk_tree_view_expand_all(GTK_TREE_VIEW(data->view));
|
|
|
|
g_object_unref(data->model);
|
2008-02-12 18:53:31 +00:00
|
|
|
}
|
|
|
|
|
2008-05-29 02:59:22 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
static void renderDownload(
|
|
|
|
GtkTreeViewColumn* column,
|
|
|
|
GtkCellRenderer* renderer,
|
|
|
|
GtkTreeModel* model,
|
|
|
|
GtkTreeIter* iter,
|
2020-08-18 10:36:10 +00:00
|
|
|
gpointer data)
|
2008-05-29 02:59:22 +00:00
|
|
|
{
|
2020-08-18 10:36:10 +00:00
|
|
|
TR_UNUSED(column);
|
|
|
|
TR_UNUSED(data);
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
gboolean enabled;
|
|
|
|
gtk_tree_model_get(model, iter, FC_ENABLED, &enabled, -1);
|
2017-04-30 16:25:26 +00:00
|
|
|
g_object_set(renderer, "inconsistent", enabled == MIXED, "active", enabled == TRUE, NULL);
|
2008-05-29 02:59:22 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
static void renderPriority(
|
|
|
|
GtkTreeViewColumn* column,
|
|
|
|
GtkCellRenderer* renderer,
|
|
|
|
GtkTreeModel* model,
|
|
|
|
GtkTreeIter* iter,
|
2020-08-18 10:36:10 +00:00
|
|
|
gpointer data)
|
2008-05-29 02:59:22 +00:00
|
|
|
{
|
2020-08-18 10:36:10 +00:00
|
|
|
TR_UNUSED(column);
|
|
|
|
TR_UNUSED(data);
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
int priority;
|
2017-04-20 16:02:19 +00:00
|
|
|
char const* text;
|
2017-04-19 12:04:45 +00:00
|
|
|
gtk_tree_model_get(model, iter, FC_PRIORITY, &priority, -1);
|
|
|
|
|
|
|
|
switch (priority)
|
2013-07-20 16:19:15 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
case TR_PRI_HIGH:
|
|
|
|
text = _("High");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TR_PRI_NORMAL:
|
|
|
|
text = _("Normal");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TR_PRI_LOW:
|
|
|
|
text = _("Low");
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
text = _("Mixed");
|
|
|
|
break;
|
2008-05-29 02:59:22 +00:00
|
|
|
}
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
g_object_set(renderer, "text", text, NULL);
|
2008-02-15 18:20:56 +00:00
|
|
|
}
|
|
|
|
|
2017-04-21 07:40:57 +00:00
|
|
|
/* build a filename from tr_torrentGetCurrentDir() + the model's FC_LABELs */
|
2020-11-05 22:46:21 +00:00
|
|
|
static char* buildFilename(tr_torrent const* tor, GtkTreeModel* model, GtkTreePath* path, GtkTreeIter const* iter)
|
2010-07-11 17:56:58 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
GtkTreeIter child;
|
|
|
|
GtkTreeIter parent = *iter;
|
|
|
|
int n = gtk_tree_path_get_depth(path);
|
|
|
|
char** tokens = g_new0(char*, n + 2);
|
|
|
|
tokens[0] = g_strdup(tr_torrentGetCurrentDir(tor));
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
child = parent;
|
|
|
|
gtk_tree_model_get(model, &child, FC_LABEL, &tokens[n--], -1);
|
2021-08-15 09:41:48 +00:00
|
|
|
} while (gtk_tree_model_iter_parent(model, &parent, &child));
|
2017-04-19 12:04:45 +00:00
|
|
|
|
2020-11-05 22:46:21 +00:00
|
|
|
char* const ret = g_build_filenamev(tokens);
|
2017-04-19 12:04:45 +00:00
|
|
|
g_strfreev(tokens);
|
|
|
|
return ret;
|
2010-07-11 17:56:58 +00:00
|
|
|
}
|
|
|
|
|
2020-11-08 19:54:40 +00:00
|
|
|
static gboolean onRowActivated(GtkTreeView* view, GtkTreePath* path, GtkTreeViewColumn const* col, gpointer gdata)
|
2010-07-11 17:56:58 +00:00
|
|
|
{
|
2020-08-18 10:36:10 +00:00
|
|
|
TR_UNUSED(col);
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
gboolean handled = FALSE;
|
|
|
|
FileData* data = gdata;
|
2020-11-05 22:46:21 +00:00
|
|
|
tr_torrent const* tor = gtr_core_find_torrent(data->core, data->torrentId);
|
2010-07-11 17:56:58 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
if (tor != NULL)
|
2010-07-11 17:56:58 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeModel* model = gtk_tree_view_get_model(view);
|
2010-07-11 17:56:58 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
if (gtk_tree_model_get_iter(model, &iter, path))
|
2010-07-11 17:56:58 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
int prog;
|
|
|
|
char* filename = buildFilename(tor, model, path, &iter);
|
|
|
|
gtk_tree_model_get(model, &iter, FC_PROG, &prog, -1);
|
2010-07-11 17:56:58 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
/* if the file's not done, walk up the directory tree until we find
|
|
|
|
* an ancestor that exists, and open that instead */
|
2017-04-30 16:25:26 +00:00
|
|
|
if (filename != NULL && (prog < 100 || !g_file_test(filename, G_FILE_TEST_EXISTS)))
|
2010-07-11 17:56:58 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
char* tmp = g_path_get_dirname(filename);
|
|
|
|
g_free(filename);
|
|
|
|
filename = tmp;
|
2021-08-15 09:41:48 +00:00
|
|
|
} while (!tr_str_is_empty(filename) && !g_file_test(filename, G_FILE_TEST_EXISTS));
|
2010-07-11 17:56:58 +00:00
|
|
|
}
|
|
|
|
|
2019-07-13 08:52:44 +00:00
|
|
|
if ((handled = !tr_str_is_empty(filename)))
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
|
|
|
gtr_open_file(filename);
|
|
|
|
}
|
2010-07-11 17:56:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
return handled;
|
2010-07-11 17:56:58 +00:00
|
|
|
}
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
static gboolean onViewPathToggled(GtkTreeView* view, GtkTreeViewColumn* col, GtkTreePath* path, FileData* data)
|
2011-01-05 07:08:34 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
int cid;
|
|
|
|
tr_torrent* tor;
|
|
|
|
gboolean handled = FALSE;
|
2008-09-06 01:52:47 +00:00
|
|
|
|
2017-04-30 16:25:26 +00:00
|
|
|
if (col == NULL || path == NULL)
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
cid = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(col), TR_COLUMN_ID_KEY));
|
|
|
|
tor = gtr_core_find_torrent(data->core, data->torrentId);
|
2008-09-06 01:52:47 +00:00
|
|
|
|
2017-04-30 16:25:26 +00:00
|
|
|
if (tor != NULL && (cid == FC_PRIORITY || cid == FC_ENABLED))
|
2011-01-05 07:08:34 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
GtkTreeIter iter;
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
tr_file_index_t* const indexBuf = g_new0(tr_file_index_t, tr_torrentInfo(tor)->fileCount);
|
|
|
|
size_t const indexCount = getActiveFilesForPath(view, path, indexBuf);
|
2017-04-19 12:04:45 +00:00
|
|
|
GtkTreeModel* model = data->model;
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
gtk_tree_model_get_iter(model, &iter, path);
|
2008-09-06 01:52:47 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
if (cid == FC_PRIORITY)
|
2011-01-05 07:08:34 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
int priority;
|
|
|
|
gtk_tree_model_get(model, &iter, FC_PRIORITY, &priority, -1);
|
|
|
|
|
|
|
|
switch (priority)
|
2013-07-20 16:19:15 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
case TR_PRI_NORMAL:
|
|
|
|
priority = TR_PRI_HIGH;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TR_PRI_HIGH:
|
|
|
|
priority = TR_PRI_LOW;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
priority = TR_PRI_NORMAL;
|
|
|
|
break;
|
2011-01-05 07:08:34 +00:00
|
|
|
}
|
2017-04-19 12:04:45 +00:00
|
|
|
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
tr_torrentSetFilePriorities(tor, indexBuf, indexCount, priority);
|
2011-01-05 07:08:34 +00:00
|
|
|
}
|
2017-04-19 12:04:45 +00:00
|
|
|
else
|
2011-01-05 07:08:34 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
int enabled;
|
|
|
|
gtk_tree_model_get(model, &iter, FC_ENABLED, &enabled, -1);
|
|
|
|
enabled = !enabled;
|
|
|
|
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
tr_torrentSetFileDLs(tor, indexBuf, indexCount, enabled);
|
2011-01-05 07:08:34 +00:00
|
|
|
}
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
refresh(data);
|
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: https://pagure.io/SSSD/sssd/blob/90ac46f71068d131391492360a8553bdd005b5a7/f/src/util/util_safealign.h#_35
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 17:27:03 +00:00
|
|
|
g_free(indexBuf);
|
2017-04-19 12:04:45 +00:00
|
|
|
handled = TRUE;
|
2011-01-05 07:08:34 +00:00
|
|
|
}
|
2008-09-06 01:52:47 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
return handled;
|
2011-01-05 07:08:34 +00:00
|
|
|
}
|
2008-09-06 01:52:47 +00:00
|
|
|
|
2011-01-05 07:08:34 +00:00
|
|
|
/**
|
|
|
|
* @note 'col' and 'path' are assumed not to be NULL.
|
|
|
|
*/
|
2021-08-15 09:41:48 +00:00
|
|
|
static gboolean getAndSelectEventPath(
|
|
|
|
GtkTreeView* treeview,
|
|
|
|
GdkEventButton const* event,
|
|
|
|
GtkTreeViewColumn** col,
|
2020-11-05 22:46:21 +00:00
|
|
|
GtkTreePath** path)
|
2011-01-05 07:08:34 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
GtkTreeSelection* sel;
|
2008-09-06 01:52:47 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
if (gtk_tree_view_get_path_at_pos(treeview, event->x, event->y, path, col, NULL, NULL))
|
2011-01-05 07:08:34 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
sel = gtk_tree_view_get_selection(treeview);
|
|
|
|
|
|
|
|
if (!gtk_tree_selection_path_is_selected(sel, *path))
|
2011-01-05 07:08:34 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
gtk_tree_selection_unselect_all(sel);
|
|
|
|
gtk_tree_selection_select_path(sel, *path);
|
2011-01-05 07:08:34 +00:00
|
|
|
}
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2011-01-05 07:08:34 +00:00
|
|
|
}
|
2008-09-08 15:17:18 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
return FALSE;
|
2011-01-05 07:08:34 +00:00
|
|
|
}
|
2008-09-06 01:52:47 +00:00
|
|
|
|
2020-11-05 22:46:21 +00:00
|
|
|
static gboolean onViewButtonPressed(GtkWidget* w, GdkEventButton const* event, gpointer gdata)
|
2011-01-05 07:08:34 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
GtkTreeViewColumn* col;
|
|
|
|
GtkTreePath* path = NULL;
|
|
|
|
gboolean handled = FALSE;
|
|
|
|
GtkTreeView* treeview = GTK_TREE_VIEW(w);
|
|
|
|
FileData* data = gdata;
|
|
|
|
|
2017-04-30 16:25:26 +00:00
|
|
|
if (event->type == GDK_BUTTON_PRESS && event->button == 1 && (event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) == 0 &&
|
2017-04-19 12:04:45 +00:00
|
|
|
getAndSelectEventPath(treeview, event, &col, &path))
|
2011-01-05 07:08:34 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
handled = onViewPathToggled(treeview, col, path, data);
|
2011-03-03 01:59:25 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
if (path != NULL)
|
|
|
|
{
|
|
|
|
gtk_tree_path_free(path);
|
|
|
|
}
|
2011-01-05 07:08:34 +00:00
|
|
|
}
|
2008-09-05 21:01:00 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
return handled;
|
2008-09-05 21:01:00 +00:00
|
|
|
}
|
|
|
|
|
2013-01-19 08:44:23 +00:00
|
|
|
struct rename_data
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
int error;
|
|
|
|
char* newname;
|
|
|
|
char* path_string;
|
|
|
|
FileData* file_data;
|
2013-01-19 08:44:23 +00:00
|
|
|
};
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
static int on_rename_done_idle(struct rename_data* data)
|
2013-01-19 08:44:23 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
if (data->error == 0)
|
2013-01-19 08:44:23 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
GtkTreeIter iter;
|
2013-01-19 08:44:23 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
if (gtk_tree_model_get_iter_from_string(data->file_data->model, &iter, data->path_string))
|
2017-02-21 20:18:52 +00:00
|
|
|
{
|
2017-04-20 16:02:19 +00:00
|
|
|
gboolean const isLeaf = !gtk_tree_model_iter_has_child(data->file_data->model, &iter);
|
|
|
|
char const* mime_type = isLeaf ? gtr_get_mime_type_from_filename(data->newname) : DIRECTORY_MIME_TYPE;
|
2017-04-19 12:04:45 +00:00
|
|
|
GdkPixbuf* icon = gtr_get_mime_type_icon(mime_type, GTK_ICON_SIZE_MENU, data->file_data->view);
|
|
|
|
|
|
|
|
gtk_tree_store_set(data->file_data->store, &iter, FC_LABEL, data->newname, FC_ICON, icon, -1);
|
2017-02-21 20:18:52 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
GtkTreeIter parent;
|
2017-02-21 20:18:52 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
if (!gtk_tree_model_iter_parent(data->file_data->model, &parent, &iter))
|
|
|
|
{
|
|
|
|
gtr_core_torrent_changed(data->file_data->core, data->file_data->torrentId);
|
|
|
|
}
|
2017-02-21 20:18:52 +00:00
|
|
|
}
|
2013-01-19 08:44:23 +00:00
|
|
|
}
|
2017-04-19 12:04:45 +00:00
|
|
|
else
|
2013-01-19 08:44:23 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
GtkWidget* w = gtk_message_dialog_new(
|
|
|
|
GTK_WINDOW(gtk_widget_get_toplevel(data->file_data->top)),
|
|
|
|
GTK_DIALOG_MODAL,
|
|
|
|
GTK_MESSAGE_ERROR,
|
|
|
|
GTK_BUTTONS_CLOSE,
|
|
|
|
_("Unable to rename file as \"%s\": %s"),
|
|
|
|
data->newname,
|
2017-04-21 07:40:57 +00:00
|
|
|
tr_strerror(data->error));
|
2017-04-19 12:04:45 +00:00
|
|
|
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(w), "%s", _("Please correct the errors and try again."));
|
|
|
|
gtk_dialog_run(GTK_DIALOG(w));
|
|
|
|
gtk_widget_destroy(w);
|
2013-01-19 08:44:23 +00:00
|
|
|
}
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
/* cleanup */
|
|
|
|
g_free(data->path_string);
|
|
|
|
g_free(data->newname);
|
|
|
|
g_free(data);
|
|
|
|
return G_SOURCE_REMOVE;
|
2013-01-19 08:44:23 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
static void on_rename_done(
|
|
|
|
tr_torrent const* tor G_GNUC_UNUSED,
|
|
|
|
char const* oldpath G_GNUC_UNUSED,
|
|
|
|
char const* newname G_GNUC_UNUSED,
|
|
|
|
int error,
|
|
|
|
struct rename_data* rename_data)
|
2013-01-19 08:44:23 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
rename_data->error = error;
|
|
|
|
gdk_threads_add_idle((GSourceFunc)on_rename_done_idle, rename_data);
|
2013-01-19 08:44:23 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
static void cell_edited_callback(
|
|
|
|
GtkCellRendererText const* cell G_GNUC_UNUSED,
|
|
|
|
gchar const* path_string,
|
|
|
|
gchar const* newname,
|
2020-11-05 22:46:21 +00:00
|
|
|
FileData* data)
|
2013-01-19 08:44:23 +00:00
|
|
|
{
|
2020-11-05 22:46:21 +00:00
|
|
|
tr_torrent* const tor = gtr_core_find_torrent(data->core, data->torrentId);
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
if (tor == NULL)
|
2013-01-19 08:44:23 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-11-05 22:46:21 +00:00
|
|
|
GtkTreeIter iter;
|
2017-04-19 12:04:45 +00:00
|
|
|
if (!gtk_tree_model_get_iter_from_string(data->model, &iter, path_string))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* build oldpath */
|
2020-11-05 22:46:21 +00:00
|
|
|
GString* oldpath = g_string_new(NULL);
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
char* token = NULL;
|
|
|
|
GtkTreeIter child;
|
|
|
|
gtk_tree_model_get(data->model, &iter, FC_LABEL, &token, -1);
|
|
|
|
g_string_prepend(oldpath, token);
|
|
|
|
g_free(token);
|
|
|
|
|
|
|
|
child = iter;
|
|
|
|
|
|
|
|
if (!gtk_tree_model_iter_parent(data->model, &iter, &child))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2013-01-19 08:44:23 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
g_string_prepend_c(oldpath, G_DIR_SEPARATOR);
|
2013-01-19 08:44:23 +00:00
|
|
|
}
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
/* do the renaming */
|
2020-11-05 22:46:21 +00:00
|
|
|
struct rename_data* rename_data = g_new0(struct rename_data, 1);
|
2017-04-19 12:04:45 +00:00
|
|
|
rename_data->newname = g_strdup(newname);
|
|
|
|
rename_data->file_data = data;
|
|
|
|
rename_data->path_string = g_strdup(path_string);
|
|
|
|
tr_torrentRenamePath(tor, oldpath->str, newname, (tr_torrent_rename_done_func)on_rename_done, rename_data);
|
2013-01-19 08:44:23 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
/* cleanup */
|
|
|
|
g_string_free(oldpath, TRUE);
|
2013-01-19 08:44:23 +00:00
|
|
|
}
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
GtkWidget* gtr_file_list_new(TrCore* core, int torrentId)
|
2008-02-12 18:53:31 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
int size;
|
|
|
|
int width;
|
|
|
|
GtkWidget* ret;
|
|
|
|
GtkWidget* view;
|
|
|
|
GtkWidget* scroll;
|
|
|
|
GtkCellRenderer* rend;
|
|
|
|
GtkTreeSelection* sel;
|
|
|
|
GtkTreeViewColumn* col;
|
|
|
|
GtkTreeView* tree_view;
|
2017-04-20 16:02:19 +00:00
|
|
|
char const* title;
|
2017-04-19 12:04:45 +00:00
|
|
|
PangoLayout* pango_layout;
|
|
|
|
PangoContext* pango_context;
|
|
|
|
PangoFontDescription* pango_font_description;
|
|
|
|
FileData* data = g_new0(FileData, 1);
|
|
|
|
|
|
|
|
data->core = core;
|
|
|
|
|
|
|
|
/* create the view */
|
|
|
|
view = gtk_tree_view_new();
|
|
|
|
tree_view = GTK_TREE_VIEW(view);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(view), GUI_PAD_BIG);
|
|
|
|
g_signal_connect(view, "button-press-event", G_CALLBACK(onViewButtonPressed), data);
|
|
|
|
g_signal_connect(view, "row_activated", G_CALLBACK(onRowActivated), data);
|
|
|
|
g_signal_connect(view, "button-release-event", G_CALLBACK(on_tree_view_button_released), NULL);
|
|
|
|
|
|
|
|
pango_context = gtk_widget_create_pango_context(view);
|
|
|
|
pango_font_description = pango_font_description_copy(pango_context_get_font_description(pango_context));
|
|
|
|
size = pango_font_description_get_size(pango_font_description);
|
|
|
|
pango_font_description_set_size(pango_font_description, size * 0.8);
|
|
|
|
g_object_unref(G_OBJECT(pango_context));
|
|
|
|
|
|
|
|
/* set up view */
|
|
|
|
sel = gtk_tree_view_get_selection(tree_view);
|
|
|
|
gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
|
|
|
|
gtk_tree_view_expand_all(tree_view);
|
|
|
|
gtk_tree_view_set_search_column(tree_view, FC_LABEL);
|
|
|
|
|
|
|
|
/* add file column */
|
|
|
|
col = GTK_TREE_VIEW_COLUMN(g_object_new(GTK_TYPE_TREE_VIEW_COLUMN, "expand", TRUE, "title", _("Name"), NULL));
|
|
|
|
gtk_tree_view_column_set_resizable(col, TRUE);
|
|
|
|
rend = gtk_cell_renderer_pixbuf_new();
|
|
|
|
gtk_tree_view_column_pack_start(col, rend, FALSE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, rend, "pixbuf", FC_ICON);
|
|
|
|
/* add text renderer */
|
|
|
|
rend = gtk_cell_renderer_text_new();
|
|
|
|
g_object_set(rend, "editable", TRUE, NULL);
|
|
|
|
g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, "font-desc", pango_font_description, NULL);
|
|
|
|
g_signal_connect(rend, "edited", (GCallback)cell_edited_callback, data);
|
|
|
|
gtk_tree_view_column_pack_start(col, rend, TRUE);
|
|
|
|
gtk_tree_view_column_set_attributes(col, rend, "text", FC_LABEL, NULL);
|
|
|
|
gtk_tree_view_column_set_sort_column_id(col, FC_LABEL);
|
|
|
|
gtk_tree_view_append_column(tree_view, col);
|
|
|
|
|
|
|
|
/* add "size" column */
|
|
|
|
title = _("Size");
|
|
|
|
rend = gtk_cell_renderer_text_new();
|
2021-08-15 09:41:48 +00:00
|
|
|
g_object_set(
|
|
|
|
rend,
|
|
|
|
TR_ARG_TUPLE("alignment", PANGO_ALIGN_RIGHT),
|
|
|
|
TR_ARG_TUPLE("font-desc", pango_font_description),
|
|
|
|
TR_ARG_TUPLE("xpad", GUI_PAD),
|
|
|
|
TR_ARG_TUPLE("xalign", 1.0F),
|
|
|
|
TR_ARG_TUPLE("yalign", 0.5F),
|
|
|
|
NULL);
|
2017-04-19 12:04:45 +00:00
|
|
|
col = gtk_tree_view_column_new_with_attributes(title, rend, NULL);
|
|
|
|
gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
|
|
|
|
gtk_tree_view_column_set_sort_column_id(col, FC_SIZE);
|
|
|
|
gtk_tree_view_column_set_attributes(col, rend, "text", FC_SIZE_STR, NULL);
|
|
|
|
gtk_tree_view_append_column(tree_view, col);
|
|
|
|
|
|
|
|
/* add "progress" column */
|
|
|
|
title = _("Have");
|
|
|
|
pango_layout = gtk_widget_create_pango_layout(view, title);
|
|
|
|
pango_layout_get_pixel_size(pango_layout, &width, NULL);
|
|
|
|
width += 30; /* room for the sort indicator */
|
|
|
|
g_object_unref(G_OBJECT(pango_layout));
|
|
|
|
rend = gtk_cell_renderer_progress_new();
|
|
|
|
col = gtk_tree_view_column_new_with_attributes(title, rend, "value", FC_PROG, NULL);
|
|
|
|
gtk_tree_view_column_set_fixed_width(col, width);
|
|
|
|
gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_sort_column_id(col, FC_PROG);
|
|
|
|
gtk_tree_view_append_column(tree_view, col);
|
|
|
|
|
|
|
|
/* add "enabled" column */
|
|
|
|
title = _("Download");
|
|
|
|
pango_layout = gtk_widget_create_pango_layout(view, title);
|
|
|
|
pango_layout_get_pixel_size(pango_layout, &width, NULL);
|
|
|
|
width += 30; /* room for the sort indicator */
|
|
|
|
g_object_unref(G_OBJECT(pango_layout));
|
|
|
|
rend = gtk_cell_renderer_toggle_new();
|
|
|
|
col = gtk_tree_view_column_new_with_attributes(title, rend, NULL);
|
|
|
|
g_object_set_data(G_OBJECT(col), TR_COLUMN_ID_KEY, GINT_TO_POINTER(FC_ENABLED));
|
|
|
|
gtk_tree_view_column_set_fixed_width(col, width);
|
|
|
|
gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_cell_data_func(col, rend, renderDownload, NULL, NULL);
|
|
|
|
gtk_tree_view_column_set_sort_column_id(col, FC_ENABLED);
|
|
|
|
gtk_tree_view_append_column(tree_view, col);
|
|
|
|
|
|
|
|
/* add priority column */
|
|
|
|
title = _("Priority");
|
|
|
|
pango_layout = gtk_widget_create_pango_layout(view, title);
|
|
|
|
pango_layout_get_pixel_size(pango_layout, &width, NULL);
|
|
|
|
width += 30; /* room for the sort indicator */
|
|
|
|
g_object_unref(G_OBJECT(pango_layout));
|
|
|
|
rend = gtk_cell_renderer_text_new();
|
|
|
|
g_object_set(rend, "xalign", (gfloat)0.5, "yalign", (gfloat)0.5, NULL);
|
|
|
|
col = gtk_tree_view_column_new_with_attributes(title, rend, NULL);
|
|
|
|
g_object_set_data(G_OBJECT(col), TR_COLUMN_ID_KEY, GINT_TO_POINTER(FC_PRIORITY));
|
|
|
|
gtk_tree_view_column_set_fixed_width(col, width);
|
|
|
|
gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_sort_column_id(col, FC_PRIORITY);
|
|
|
|
gtk_tree_view_column_set_cell_data_func(col, rend, renderPriority, NULL, NULL);
|
|
|
|
gtk_tree_view_append_column(tree_view, col);
|
|
|
|
|
|
|
|
/* add tooltip to tree */
|
|
|
|
gtk_tree_view_set_tooltip_column(tree_view, FC_LABEL_ESC);
|
|
|
|
|
|
|
|
/* create the scrolled window and stick the view in it */
|
|
|
|
scroll = gtk_scrolled_window_new(NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll), GTK_SHADOW_IN);
|
|
|
|
gtk_container_add(GTK_CONTAINER(scroll), view);
|
|
|
|
gtk_widget_set_size_request(scroll, -1, 200);
|
|
|
|
|
|
|
|
ret = scroll;
|
|
|
|
data->view = view;
|
|
|
|
data->top = scroll;
|
|
|
|
g_object_set_data_full(G_OBJECT(ret), "file-data", data, freeData);
|
|
|
|
gtr_file_list_set_torrent(ret, torrentId);
|
|
|
|
|
|
|
|
pango_font_description_free(pango_font_description);
|
|
|
|
return ret;
|
2008-02-10 22:25:42 +00:00
|
|
|
}
|