cpw.darkrain42.xmpp.disco: e71d8d11: Handle expanding disco lists on the UI s...
paul at darkrain42.org
paul at darkrain42.org
Sat Apr 25 16:17:51 EDT 2009
-----------------------------------------------------------------
Revision: e71d8d116185912f6e845d1215b78566accf6b16
Ancestor: 6547ef6c33adb394b4cef59ffbf0975cd346962b
Author: paul at darkrain42.org
Date: 2009-04-15T02:51:48
Branch: im.pidgin.cpw.darkrain42.xmpp.disco
URL: http://d.pidgin.im/viewmtn/revision/info/e71d8d116185912f6e845d1215b78566accf6b16
Modified files:
pidgin/gtkdisco.c
ChangeLog:
Handle expanding disco lists on the UI side
-------------- next part --------------
============================================================
--- pidgin/gtkdisco.c cc66500943c2753c0377c7ec1c28bca49745d23a
+++ pidgin/gtkdisco.c 9b4f34e0d3c1bd6e263a8a85b7bd4b745ff81ff6
@@ -173,6 +173,23 @@ selection_changed_cb(GtkTreeSelection *s
}
}
+static void
+row_expanded_cb(GtkTreeView *tree, GtkTreeIter *arg1, GtkTreePath *rg2,
+ gpointer user_data)
+{
+ PidginDiscoList *pdl;
+ PurpleDiscoService *service;
+ GValue val;
+
+ pdl = user_data;
+
+ val.g_type = 0;
+ gtk_tree_model_get_value(GTK_TREE_MODEL(pdl->model), arg1, SERVICE_COLUMN,
+ &val);
+ service = g_value_get_pointer(&val);
+ purple_disco_service_expand(service);
+}
+
static gint
delete_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d)
{
@@ -295,6 +312,8 @@ static void pidgin_disco_create_tree(Pid
gtk_tree_view_column_set_sort_column_id(GTK_TREE_VIEW_COLUMN(column), DESCRIPTION_COLUMN);
gtk_tree_view_column_set_reorderable(GTK_TREE_VIEW_COLUMN(column), TRUE);
gtk_tree_view_append_column(GTK_TREE_VIEW(pdl->tree), column);
+
+ g_signal_connect(G_OBJECT(pdl->tree), "row-expanded", G_CALLBACK(row_expanded_cb), pdl);
}
static PidginDiscoDialog*
@@ -441,7 +460,6 @@ static void pidgin_disco_in_progress(Pur
return;
if (in_progress) {
- gtk_tree_store_clear(pdl->model);
if (dialog->account_widget)
gtk_widget_set_sensitive(dialog->account_widget, FALSE);
gtk_widget_set_sensitive(dialog->stop_button, TRUE);
@@ -461,11 +479,10 @@ static void pidgin_disco_add_service(Pur
PidginDiscoDialog *dialog;
PurpleDiscoServiceType type;
const char *gateway_type;
- GtkTreeIter iter, parent_iter;
- GtkTreeRowReference *rr;
- GtkTreePath *path;
+ GtkTreeIter iter, parent_iter, child;
char *filename = NULL;
GdkPixbuf *pixbuf = NULL;
+ gboolean append = TRUE;
pdl = purple_disco_list_get_ui_data(list);
dialog = pdl->dialog;
@@ -475,16 +492,43 @@ static void pidgin_disco_add_service(Pur
gtk_progress_bar_pulse(GTK_PROGRESS_BAR(dialog->progress));
if (parent) {
+ GtkTreeRowReference *rr;
+ GtkTreePath *path;
+
rr = g_hash_table_lookup(pdl->cats, parent);
path = gtk_tree_row_reference_get_path(rr);
if (path) {
gtk_tree_model_get_iter(GTK_TREE_MODEL(pdl->model), &parent_iter, path);
gtk_tree_path_free(path);
+
+ if (gtk_tree_model_iter_children(GTK_TREE_MODEL(pdl->model), &child,
+ &parent_iter)) {
+ PurpleDiscoList *tmp;
+ gtk_tree_model_get(GTK_TREE_MODEL(pdl->model), &child,
+ SERVICE_COLUMN, &tmp, -1);
+ if (!tmp)
+ append = FALSE;
+ }
}
}
- gtk_tree_store_append(pdl->model, &iter, (parent ? &parent_iter : NULL));
+ if (append)
+ gtk_tree_store_append(pdl->model, &iter, (parent ? &parent_iter : NULL));
+ else
+ iter = child;
+ if (purple_disco_service_get_flags(service) & PURPLE_DISCO_BROWSE) {
+ GtkTreeRowReference *rr;
+ GtkTreePath *path;
+
+ gtk_tree_store_append(pdl->model, &child, &iter);
+
+ path = gtk_tree_model_get_path(GTK_TREE_MODEL(pdl->model), &iter);
+ rr = gtk_tree_row_reference_new(GTK_TREE_MODEL(pdl->model), path);
+ g_hash_table_insert(pdl->cats, service, rr);
+ gtk_tree_path_free(path);
+ }
+
type = purple_disco_service_get_type(service);
gateway_type = purple_disco_service_get_gateway_type(service);
@@ -511,13 +555,6 @@ static void pidgin_disco_add_service(Pur
SERVICE_COLUMN, service,
-1);
- path = gtk_tree_model_get_path(GTK_TREE_MODEL(pdl->model), &iter);
-
- rr = gtk_tree_row_reference_new(GTK_TREE_MODEL(pdl->model), path);
- g_hash_table_insert(pdl->cats, service, rr);
-
- gtk_tree_path_free(path);
-
if (pixbuf)
g_object_unref(pixbuf);
}
More information about the Commits
mailing list