Logo Search packages:      
Sourcecode: dcgui version File versions  Download package

upload_clist.c

/* dc_gui2 - a GTK+2 GUI for DCTC
 * Copyright (C) 2002 Eric Prevoteau
 *
 * upload_clist.c: Copyright (C) Eric Prevoteau <www@a2pb.gotdns.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
/*
$Id: upload_clist.c,v 1.8 2003/12/29 09:59:01 uid68112 Exp $
*/

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <db.h>
#include <gnome.h>

#include "gtkcellrenderertextx.h"
#include "misc_gtk.h"
#include "upload_clist.h"
#include "main.h"
#include "gui_define.h"
#include "macro.h"
#include "unode.h"
#include "global_user.h"

/************************************************/
/* update user information using GLOB_USER data */
/************************************************/
static void upload_clist_user_info_update_row(GtkTreeModel *gtm, GtkTreePath *gtp, GtkTreeIter *gti, gpointer user_data)
{
      GLOB_USER *gu;

      /* get GLOB_USER entry to use */
      gtk_tree_model_get(gtm,gti,ULC_USER_POINTER,&gu,-1);

      /* block the update signal on this function */
      g_signal_handlers_block_matched (G_OBJECT(gtm),G_SIGNAL_MATCH_FUNC,0,0,NULL,upload_clist_user_info_update_row,NULL);

      /* update user info */
      gtk_list_store_set(GTK_LIST_STORE(gtm),gti,
                                                                        ULC_NICK_COL,gu->fmt_nick,
                                                                        ULC_LINE_BACKGROUND,gu->back_present_color,
                                                                        ULC_LINE_FOREGROUND,gu->front_color,
                                                                        -1);

      /* unblock the update signal on this function */
      g_signal_handlers_unblock_matched (G_OBJECT(gtm),G_SIGNAL_MATCH_FUNC,0,0,NULL,upload_clist_user_info_update_row,NULL);
}

/*********************************************/
/* build model and view for the upload clist */
/*********************************************/
void bmav4_upload_clist(void)
{
      GtkListStore *model;
      GtkWidget *view;
      GtkCellRenderer *rend;
      GtkTreeSelection *slc;

      model=gtk_list_store_new(NB_ULC_COL,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,
                                                                              G_TYPE_STRING,G_TYPE_ULONG,G_TYPE_FLOAT,
                                                                              G_TYPE_STRING,G_TYPE_STRING,G_TYPE_ULONG,
                                                                              G_TYPE_POINTER);
      g_signal_connect_after(G_OBJECT(model),"row-changed",G_CALLBACK(upload_clist_user_info_update_row),NULL);

      view=get_widget_by_widget_name(main_window,"upload_clist");

      gtk_tree_view_set_model(GTK_TREE_VIEW(view),GTK_TREE_MODEL(model));
      gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view),TRUE);

      slc=gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
      gtk_tree_selection_set_mode(slc,GTK_SELECTION_MULTIPLE);
      
      /* the first column of the view display the first column of the model, and so on. The 4th entry of the model is not displayed */
      rend=gtk_cell_renderer_textx_new();
      g_object_set(rend,"rowspacing",TRUE,NULL);
      MY_RS_gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),ULC_NICK_COL,_("Nick"),rend,"text",ULC_NICK_COL,"background",ULC_LINE_BACKGROUND,"foreground",ULC_LINE_FOREGROUND,NULL);

      rend=gtk_cell_renderer_textx_new();
      g_object_set(rend,"rowspacing",TRUE,NULL);
      MY_RS2_gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),ULC_SIZE_COL,ULC_SIZE_AS_VAL,_("Size"),rend,"text",ULC_SIZE_COL,"background",ULC_LINE_BACKGROUND,"foreground",ULC_LINE_FOREGROUND,"xalign",ULC_SIZE_RIGHT_ALIGN,NULL);

      rend=gtk_cell_renderer_textx_new();
      g_object_set(rend,"rowspacing",TRUE,NULL);
      MY_RS_gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),ULC_SPEED_COL,_("Sent"),rend,"text",ULC_SPEED_COL,"background",ULC_LINE_BACKGROUND,"foreground",ULC_LINE_FOREGROUND,"xalign",ULC_SIZE_RIGHT_ALIGN,NULL);

      rend=gtk_cell_renderer_textx_new();
      g_object_set(rend,"rowspacing",TRUE,NULL);
      MY_RS_gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),ULC_FNAME_COL,_("Filename"),rend,"text",ULC_FNAME_COL,"background",ULC_LINE_BACKGROUND,"foreground",ULC_LINE_FOREGROUND,NULL);

      /* The view now holds a reference.  We can get rid of our own
       * reference */
      g_object_unref (G_OBJECT (model));
}


Generated by  Doxygen 1.6.0   Back to index