Mercurial > pidgin.yaz
diff src/gtkconn.c @ 10400:6a043ae92db6
[gaim-migrate @ 11631]
I'm about to go home for the holidays, so I figured I'd commit this before
I left so someone else could pick up on it while I'm gone.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sun, 19 Dec 2004 20:32:32 +0000 |
parents | 61852117568f |
children | ce098e226486 |
line wrap: on
line diff
--- a/src/gtkconn.c Sun Dec 19 17:35:59 2004 +0000 +++ b/src/gtkconn.c Sun Dec 19 20:32:32 2004 +0000 @@ -36,227 +36,29 @@ #include "gtkdialogs.h" #include "gtkutils.h" -/* - * The next couple of functions deal with the connection dialog - */ -struct login_meter { - GaimAccount *account; - GtkWidget *button; - GtkWidget *progress; - GtkWidget *status; -}; - -struct meter_window { - GtkWidget *window; - GtkWidget *table; - gint rows; - gint active_count; - GSList *meters; -}; -struct meter_window *meter_win = NULL; - -static void kill_meter(struct login_meter *meter, const char *text) -{ - if(gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(meter->progress)) == 1) - return; - - gtk_widget_set_sensitive(meter->button, FALSE); - gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(meter->progress), 1); - gtk_label_set_text(GTK_LABEL(meter->status), text); - meter_win->active_count--; - - if (meter_win->active_count == 0) { - gtk_widget_destroy(meter_win->window); - g_free(meter_win); - meter_win = NULL; - } -} - -static void cancel_login(GtkWidget *button, struct login_meter *meter) -{ - if (meter->account->gc != NULL) { - meter->account->gc->wants_to_die = TRUE; - gaim_connection_destroy(meter->account->gc); - } else { - kill_meter(meter, _("Done.")); - - if (gaim_connections_get_all() == NULL) { - gaim_gtkdialogs_destroy_all(); - } - } -} - -static void cancel_all () -{ - GSList *m = meter_win ? meter_win->meters : NULL; - struct login_meter *meter; - - while (m) { - meter = m->data; - if (gaim_connection_get_state(meter->account->gc) != GAIM_CONNECTED) - cancel_login(NULL, meter); - m = m->next; - } -} - -static gint meter_destroy(GtkWidget *window, GdkEvent *evt, struct login_meter *meter) -{ - return TRUE; -} - -static struct login_meter *find_login_meter(GaimConnection *gc) -{ - GSList *m = meter_win ? meter_win->meters : NULL; - struct login_meter *meter; - - while (m) { - meter = m->data; - if (meter->account == gaim_connection_get_account(gc)) - return m->data; - m = m->next; - } - - return NULL; -} - -static GtkWidget* create_meter_pixmap (GaimConnection *gc) -{ - GdkPixbuf *pb = create_prpl_icon(gc->account); - GdkPixbuf *scale = gdk_pixbuf_scale_simple(pb, 30,30,GDK_INTERP_BILINEAR); - GtkWidget *image = - gtk_image_new_from_pixbuf(scale); - g_object_unref(G_OBJECT(pb)); - g_object_unref(G_OBJECT(scale)); - return image; -} - -static struct login_meter * -new_meter(GaimConnection *gc, GtkWidget *widget, - GtkWidget *table, gint *rows) -{ - GtkWidget *graphic; - GtkWidget *label; - GtkWidget *nest_vbox; - GString *name_to_print; - struct login_meter *meter; - - - meter = g_new0(struct login_meter, 1); - - meter->account = gaim_connection_get_account(gc); - name_to_print = g_string_new(gaim_account_get_username(meter->account)); - - (*rows)++; - gtk_table_resize (GTK_TABLE(table), *rows, 4); - - graphic = create_meter_pixmap(gc); - - nest_vbox = gtk_vbox_new (FALSE, 0); - - g_string_prepend(name_to_print, _("Logging in: ")); - label = gtk_label_new (name_to_print->str); - g_string_free(name_to_print, TRUE); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - - meter->status = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(meter->status), 0, 0.5); - gtk_widget_set_size_request(meter->status, 250, -1); - - meter->progress = gtk_progress_bar_new (); - - meter->button = gaim_pixbuf_button_from_stock (_("Cancel"), GTK_STOCK_CANCEL, GAIM_BUTTON_HORIZONTAL); - g_signal_connect(G_OBJECT (meter->button), "clicked", - G_CALLBACK (cancel_login), meter); - - gtk_table_attach (GTK_TABLE (table), graphic, 0, 1, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); - gtk_table_attach (GTK_TABLE (table), nest_vbox, 1, 2, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); - gtk_box_pack_start (GTK_BOX (nest_vbox), GTK_WIDGET (label), FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (nest_vbox), GTK_WIDGET (meter->status), FALSE, FALSE, 0); - gtk_table_attach (GTK_TABLE (table), meter->progress, 2, 3, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); - gtk_table_attach (GTK_TABLE (table), meter->button, 3, 4, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); - - gtk_widget_show_all (GTK_WIDGET (meter_win->window)); - - meter_win->active_count++; - - return meter; -} - static void gaim_gtk_connection_connect_progress(GaimConnection *gc, const char *text, size_t step, size_t step_count) { - struct login_meter *meter; - - if(!meter_win) { - GtkWidget *vbox; - GtkWidget *cancel_button; - - meter_win = g_new0(struct meter_window, 1); - meter_win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_resizable(GTK_WINDOW(meter_win->window), FALSE); - gtk_window_set_role(GTK_WINDOW(meter_win->window), "logging_in"); - gtk_container_set_border_width(GTK_CONTAINER(meter_win->window), 5); - gtk_window_set_title(GTK_WINDOW(meter_win->window), _("Logging In")); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add(GTK_CONTAINER(meter_win->window), vbox); - - meter_win->table = gtk_table_new(1, 4, FALSE); - gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(meter_win->table), - FALSE, FALSE, 0); - gtk_container_set_border_width(GTK_CONTAINER(meter_win->table), 5); - gtk_table_set_row_spacings(GTK_TABLE(meter_win->table), 5); - gtk_table_set_col_spacings(GTK_TABLE(meter_win->table), 10); - - cancel_button = gaim_pixbuf_button_from_stock(_("Cancel All"), - GTK_STOCK_QUIT, GAIM_BUTTON_HORIZONTAL); - g_signal_connect_swapped(G_OBJECT(cancel_button), "clicked", - G_CALLBACK(cancel_all), NULL); - gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(cancel_button), - FALSE, FALSE, 0); - - g_signal_connect(G_OBJECT(meter_win->window), "delete_event", - G_CALLBACK(meter_destroy), NULL); - } - - meter = find_login_meter(gc); - if(!meter) { - meter = new_meter(gc, meter_win->window, meter_win->table, - &meter_win->rows); - - meter_win->meters = g_slist_append(meter_win->meters, meter); - } - - gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(meter->progress), - (float)step / (float)step_count); - gtk_label_set_text(GTK_LABEL(meter->status), text); + /* SME - Pulse the statusselector */ } static void gaim_gtk_connection_connected(GaimConnection *gc) { - struct login_meter *meter = find_login_meter(gc); #if 0 /* XXX CORE/UI */ do_away_menu(); #endif gaim_gtk_blist_update_protocol_actions(); - if (meter) - kill_meter(meter, _("Done.")); } static void gaim_gtk_connection_disconnected(GaimConnection *gc) { - struct login_meter *meter = find_login_meter(gc); - #if 0 /* XXX CORE/UI */ do_away_menu(); #endif gaim_gtk_blist_update_protocol_actions(); - if (meter) - kill_meter(meter, _("Done.")); - if (gaim_connections_get_all() != NULL) return; @@ -409,7 +211,7 @@ l_accts_iter = l_accts; while (l_accts_iter != NULL) { account = l_accts_iter->data; - gaim_account_connect(account); + /* gaim_account_connect(account); */ l_accts_iter = l_accts_iter->next; } g_list_free(l_accts); @@ -466,7 +268,7 @@ g_list_free(l_del); } - gaim_account_connect(account); + /* gaim_account_connect(account); */ disconnect_window_update_buttons(model); break;