summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/trg-cell-renderer-wanted.c6
-rw-r--r--src/trg-files-model-common.c4
-rw-r--r--src/trg-files-model.c39
-rw-r--r--src/trg-menu-bar.c2
4 files changed, 28 insertions, 23 deletions
diff --git a/src/trg-cell-renderer-wanted.c b/src/trg-cell-renderer-wanted.c
index aeb4ab9..168db34 100644
--- a/src/trg-cell-renderer-wanted.c
+++ b/src/trg-cell-renderer-wanted.c
@@ -39,7 +39,7 @@ typedef struct _TrgCellRendererWantedPrivate
TrgCellRendererWantedPrivate;
struct _TrgCellRendererWantedPrivate {
- gint64 wanted_value;
+ gint wanted_value;
};
static void
@@ -51,7 +51,7 @@ trg_cell_renderer_wanted_get_property(GObject * object,
TRG_CELL_RENDERER_WANTED_GET_PRIVATE(object);
switch (property_id) {
case PROP_WANTED_VALUE:
- g_value_set_int64(value, priv->wanted_value);
+ g_value_set_int(value, priv->wanted_value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
@@ -91,7 +91,7 @@ trg_cell_renderer_wanted_class_init(TrgCellRendererWantedClass * klass)
("wanted-value",
"Wanted Value",
"Wanted Value", TR_PRI_UNSET,
- TR_PRI_HIGH, TR_PRI_NORMAL,
+ TRUE, TRUE,
G_PARAM_READWRITE |
G_PARAM_STATIC_NAME |
G_PARAM_STATIC_NICK |
diff --git a/src/trg-files-model-common.c b/src/trg-files-model-common.c
index 5cf16a3..5468142 100644
--- a/src/trg-files-model-common.c
+++ b/src/trg-files-model-common.c
@@ -103,7 +103,7 @@ static gboolean setSubtreeForeach(GtkTreeModel * model, GtkTreePath * path,
void trg_files_tree_model_propogateChangeUp(GtkTreeModel * model,
GtkTreeIter * iter, gint column, gint new_value) {
GtkTreeIter back_iter = *iter;
- gint result;
+ gint result = new_value;
while (1) {
GtkTreeIter tmp_iter;
@@ -141,14 +141,12 @@ void trg_files_tree_model_setSubtree(GtkTreeModel * model, GtkTreePath * path,
if (gtk_tree_model_iter_has_child(model, iter)) {
struct SubtreeForeachData tmp;
- GtkTreeIter parent;
tmp.column = column;
tmp.new_value = new_value;
tmp.path = path;
gtk_tree_model_foreach(model, setSubtreeForeach, &tmp);
- gtk_tree_model_iter_parent(model, &parent, iter);
} else {
gtk_tree_store_set(GTK_TREE_STORE(model), &back_iter, column, new_value,
-1);
diff --git a/src/trg-files-model.c b/src/trg-files-model.c
index 6390b61..d6770bf 100644
--- a/src/trg-files-model.c
+++ b/src/trg-files-model.c
@@ -62,14 +62,14 @@ static void rowref_to_iter(GtkTreeModel *model, GtkTreeRowReference *rr,
gtk_tree_path_free(path);
}
-struct updateAllArgs {
+struct UpdateParentProgressForeachData {
GtkTreeIter *descendentIter;
gint64 increment;
};
-static gboolean trg_files_update_all_parents(GtkTreeModel *model,
+static gboolean trg_files_update_parent_progress_foreachfunc(GtkTreeModel *model,
GtkTreePath *path, GtkTreeIter *iter, gpointer data) {
- struct updateAllArgs *args = (struct updateAllArgs*) data;
+ struct UpdateParentProgressForeachData *args = (struct UpdateParentProgressForeachData*) data;
GtkTreePath *descendentPath = gtk_tree_model_get_path(model,
args->descendentIter);
@@ -92,6 +92,18 @@ static gboolean trg_files_update_all_parents(GtkTreeModel *model,
return FALSE;
}
+static void trg_files_update_parent_progress(GtkTreeModel *model, GtkTreeIter *iter, gint64 increment)
+{
+ if (increment > 0) {
+ struct UpdateParentProgressForeachData args;
+ args.descendentIter = iter;
+ args.increment = increment;
+
+ gtk_tree_model_foreach(GTK_TREE_MODEL(model),
+ trg_files_update_parent_progress_foreachfunc, &args);
+ }
+}
+
static void trg_files_model_iter_new(TrgFilesModel * model, GtkTreeIter * iter,
JsonObject * file, gint id) {
TrgFilesModelPrivate *priv = TRG_FILES_MODEL_GET_PRIVATE(model);
@@ -187,6 +199,7 @@ static void trg_files_model_iter_update(TrgFilesModel * model,
gint64 fileLength = file_get_length(file);
gint64 fileCompleted = file_get_bytes_completed(file);
+ gint64 increment;
gboolean wanted = json_node_get_int(json_array_get_element(wantedArray, id))
== 1;
@@ -194,34 +207,28 @@ static void trg_files_model_iter_update(TrgFilesModel * model,
json_array_get_element(prioritiesArray, id));
gdouble progress = file_get_progress(fileLength, fileCompleted);
- struct updateAllArgs args;
-
if (isFirst) {
- args.increment = fileCompleted;
+ increment = fileCompleted;
} else {
gint64 lastCompleted;
gtk_tree_model_get(GTK_TREE_MODEL(model), filesIter,
FILESCOL_BYTESCOMPLETED, &lastCompleted, -1);
- args.increment = fileCompleted - lastCompleted;
+ increment = fileCompleted - lastCompleted;
}
gtk_tree_store_set(GTK_TREE_STORE(model), filesIter, FILESCOL_PROGRESS,
progress, FILESCOL_BYTESCOMPLETED, fileCompleted, -1);
- if (args.increment > 0) {
- args.descendentIter = filesIter;
- gtk_tree_model_foreach(GTK_TREE_MODEL(model),
- trg_files_update_all_parents, &args);
- }
+ trg_files_update_parent_progress(GTK_TREE_MODEL(model), filesIter, increment);
+
+ if (priv->accept)
+ gtk_tree_store_set(GTK_TREE_STORE(model), filesIter, FILESCOL_WANTED,
+ wanted, FILESCOL_PRIORITY, priority, -1);
if (isFirst) {
trg_files_tree_model_propogateChangeUp(GTK_TREE_MODEL(model), filesIter, FILESCOL_PRIORITY, priority);
trg_files_tree_model_propogateChangeUp(GTK_TREE_MODEL(model), filesIter, FILESCOL_WANTED, wanted);
}
-
- if (priv->accept)
- gtk_tree_store_set(GTK_TREE_STORE(model), filesIter, FILESCOL_WANTED,
- wanted, FILESCOL_PRIORITY, priority, -1);
}
static void trg_files_model_class_init(TrgFilesModelClass * klass) {
diff --git a/src/trg-menu-bar.c b/src/trg-menu-bar.c
index e7c2cf0..a9e4f08 100644
--- a/src/trg-menu-bar.c
+++ b/src/trg-menu-bar.c
@@ -517,7 +517,7 @@ GtkWidget *trg_menu_bar_file_file_menu_new(TrgMenuBar * menu)
priv->mb_add =
trg_menu_bar_item_new(GTK_MENU_SHELL(fileMenu), _("_Add"),
GTK_STOCK_ADD, FALSE);
- trg_menu_bar_accel_add(menu, priv->mb_add, GDK_a, GDK_CONTROL_MASK);
+ trg_menu_bar_accel_add(menu, priv->mb_add, GDK_o, GDK_CONTROL_MASK);
priv->mb_add_url =
trg_menu_bar_item_new(GTK_MENU_SHELL(fileMenu), _("Add from _URL"),