~qwertitis-deactivatedaccount/linuxdcpp/individ-branch

« back to all changes in this revision

Viewing changes to linux/mainwindow.cc

  • Committer: David Grundberg
  • Date: 2008-11-23 15:58:59 UTC
  • Revision ID: individ@acc.umu.se-20081123155859-l0ou4f8rbwvtagg0
Statusbar patch (Fixes lp bug #283407)

Show diffs side-by-side

added added

removed removed

Lines of Context:
224
224
        gtk_widget_destroy(dummy);
225
225
        emptyStatusWidth = req.width;
226
226
 
 
227
        // Create extra frames in the statusbar for connection stats.
 
228
        for (int i = 0; i < 6; i++)
 
229
        {
 
230
                GtkShadowType shadow_type;
 
231
                GtkFrame *frame;
 
232
  
 
233
                gtk_widget_style_get(getWidget("statusbar"), "shadow-type", &shadow_type, NULL);
 
234
  
 
235
                frame = GTK_FRAME(gtk_frame_new(NULL));
 
236
                gtk_frame_set_shadow_type (frame, shadow_type);
 
237
                gtk_box_pack_start(GTK_BOX(getWidget("statusbar")), GTK_WIDGET(frame), FALSE, TRUE, 0);
 
238
                gtk_widget_show(GTK_WIDGET(frame));
 
239
 
 
240
                statLabels[i] = GTK_LABEL(gtk_label_new(""));
 
241
                gtk_label_set_single_line_mode(statLabels[i], TRUE);
 
242
                gtk_misc_set_alignment(GTK_MISC(statLabels[i]), 0.0, 0.5);
 
243
                gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(statLabels[i]));
 
244
                gtk_widget_show(GTK_WIDGET(statLabels[i]));
 
245
        }
 
246
 
227
247
        setMainStatus_gui(_("Welcome to LinuxDC++"));
228
248
 
229
249
        // Putting this after all the resizing and moving makes the window appear
493
513
        {
494
514
                text = "[" + Util::getShortTimeString(t) + "] " + text;
495
515
 
496
 
                setStatus_gui("status1", text);
497
 
        }
498
 
}
499
 
 
500
 
void MainWindow::setStatus_gui(string statusBar, std::string text)
501
 
{
502
 
        if (statusBar != "status1")
503
 
        {
504
 
                PangoLayout *pango;
505
 
                int width;
506
 
                GtkRequisition req;
507
 
 
508
 
                pango = gtk_widget_create_pango_layout(GTK_WIDGET(window), text.c_str());
509
 
                pango_layout_get_pixel_size(pango, &width, NULL);
510
 
                g_object_unref(G_OBJECT(pango));
511
 
                gtk_widget_size_request(getWidget(statusBar), &req);
512
 
                if (width > req.width - emptyStatusWidth)
513
 
                        gtk_widget_set_size_request(getWidget(statusBar), width + emptyStatusWidth, -1);
514
 
        }
515
 
 
516
 
        gtk_statusbar_pop(GTK_STATUSBAR(getWidget(statusBar)), 0);
517
 
        gtk_statusbar_push(GTK_STATUSBAR(getWidget(statusBar)), 0, text.c_str());
 
516
                gtk_statusbar_pop(GTK_STATUSBAR(getWidget("statusbar")), 0);
 
517
                gtk_statusbar_push(GTK_STATUSBAR(getWidget("statusbar")), 0, text.c_str());
 
518
        }
518
519
}
519
520
 
520
521
void MainWindow::setStats_gui(std::string hub, std::string slot,
521
522
        std::string dTot, std::string uTot, std::string dl, std::string ul)
522
523
{
523
 
        setStatus_gui("status2", hub);
524
 
        setStatus_gui("status3", slot);
525
 
        setStatus_gui("status4", dTot);
526
 
        setStatus_gui("status5", uTot);
527
 
        setStatus_gui("status6", ul);
528
 
        setStatus_gui("status7", dl);
 
524
        gtk_label_set_text(statLabels[0], hub.c_str());
 
525
        gtk_label_set_text(statLabels[1], slot.c_str());
 
526
        gtk_label_set_text(statLabels[2], dTot.c_str());
 
527
        gtk_label_set_text(statLabels[3], uTot.c_str());
 
528
        gtk_label_set_text(statLabels[4], dl.c_str());
 
529
        gtk_label_set_text(statLabels[5], ul.c_str());
529
530
}
530
531
 
531
532
BookEntry* MainWindow::findBookEntry(const EntryType type, const string &id)