X-Git-Url: http://git.dolda2000.com/gitweb/?a=blobdiff_plain;f=clients%2Fgnome-trans-applet%2Fdolcon-trans-applet.c;h=dc949320720fdf450ce277f94e7d35c40d7dc3f0;hb=302a260054ea38d3cb97be6d1a3010082c09265d;hp=b09e52959d4ccdcd2dee1e1fda5a95d521eb4e94;hpb=d3372da97568d5e1f35fa19787c8ec8af93a0435;p=doldaconnect.git diff --git a/clients/gnome-trans-applet/dolcon-trans-applet.c b/clients/gnome-trans-applet/dolcon-trans-applet.c index b09e529..dc94932 100644 --- a/clients/gnome-trans-applet/dolcon-trans-applet.c +++ b/clients/gnome-trans-applet/dolcon-trans-applet.c @@ -1,3 +1,22 @@ +/* + * Dolda Connect - Modular multiuser Direct Connect-style client + * Copyright (C) 2005 Fredrik Tolf + * + * 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 +*/ + #ifdef HAVE_CONFIG_H #include #endif @@ -23,17 +42,24 @@ struct appletdata static char *ctxtmenu = "" -" " -" " +" " +" " ""; static void run_pref_dialog(BonoboUIComponent *uic, gpointer data, const char *cname) { } +static void cancel_transfer(BonoboUIComponent *uic, struct appletdata *data, const char *cname) +{ + if(data->conduit->iface->cancel != NULL) + data->conduit->iface->cancel(data->conduit, data->curdisplay); +} + static BonoboUIVerb ctxtmenuverbs[] = { BONOBO_UI_VERB("dca_pref", run_pref_dialog), + BONOBO_UI_VERB("dca_cancel", cancel_transfer), BONOBO_UI_VERB_END }; @@ -73,6 +99,7 @@ static gboolean updatetip(struct appletdata *data) static void update(struct appletdata *data) { char buf[256]; + size_t l; switch(data->conduit->state) { @@ -104,7 +131,15 @@ static void update(struct appletdata *data) gtk_progress_bar_set_fraction(data->pbar, 0); gtk_progress_bar_set_text(data->pbar, _("Initializing")); } - gtk_label_set_text(data->label, data->curdisplay->tag); + if((l = strlen(data->curdisplay->tag)) > 50) { + memcpy(buf, data->curdisplay->tag, 20); + memcpy(buf + 20, "...", 3); + memcpy(buf + 23 , data->curdisplay->tag + l - 20, 20); + buf[43] = 0; + gtk_label_set_text(data->label, buf); + } else { + gtk_label_set_text(data->label, data->curdisplay->tag); + } } break; } @@ -171,6 +206,34 @@ static gboolean trview_applet_button_press(GtkWidget *widget, GdkEventButton *ev return(FALSE); } +static gboolean trview_applet_scroll(GtkWidget *widget, GdkEventScroll *event, struct appletdata *data) +{ + struct transfer *tr; + + if(event->direction == GDK_SCROLL_DOWN) + { + if(data->curdisplay == NULL) + data->curdisplay = data->conduit->transfers; + else if(data->curdisplay->next == NULL) + data->curdisplay = data->conduit->transfers; + else + data->curdisplay = data->curdisplay->next; + update(data); + } else if(event->direction == GDK_SCROLL_UP) { + if(data->curdisplay == NULL) + { + data->curdisplay = data->conduit->transfers; + } else if(data->curdisplay->prev == NULL) { + for(tr = data->conduit->transfers; tr->next != NULL; tr = tr->next); + data->curdisplay = tr; + } else { + data->curdisplay = data->curdisplay->prev; + } + update(data); + } + return(TRUE); +} + static void trview_applet_destroy(GtkWidget *widget, struct appletdata *data) { freeconduit(data->conduit); @@ -189,8 +252,6 @@ static gboolean trview_applet_fill(PanelApplet *applet, const gchar *iid, gpoint if(strcmp(iid, "OAFIID:Dolcon_Transferapplet")) return(FALSE); - panel_applet_setup_menu(applet, ctxtmenu, ctxtmenuverbs, NULL); - hbox = gtk_hbox_new(FALSE, 0); label = gtk_label_new(""); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); @@ -208,7 +269,10 @@ static gboolean trview_applet_fill(PanelApplet *applet, const gchar *iid, gpoint data->tiptimeout = g_timeout_add(500, (gboolean (*)(gpointer))updatetip, data); data->label = GTK_LABEL(label); + panel_applet_setup_menu(applet, ctxtmenu, ctxtmenuverbs, data); + g_signal_connect(applet, "button-press-event", (GCallback)trview_applet_button_press, data); + g_signal_connect(applet, "scroll-event", (GCallback)trview_applet_scroll, data); g_signal_connect(applet, "destroy", (GCallback)trview_applet_destroy, data); condtryconn(data->conduit);