pidgin/pidginabout.c

changeset 38673
743b0df28288
parent 38672
df4a6635745a
child 38679
5a3c432dee1d
equal deleted inserted replaced
38672:df4a6635745a 38673:743b0df28288
37 GtkWidget *application_name; 37 GtkWidget *application_name;
38 GtkWidget *stack; 38 GtkWidget *stack;
39 39
40 GtkWidget *main_scrolled_window; 40 GtkWidget *main_scrolled_window;
41 41
42 GtkWidget *developers_button;
43 GtkWidget *developers_page; 42 GtkWidget *developers_page;
44 GtkWidget *developers_treeview; 43 GtkWidget *developers_treeview;
45 GtkTreeStore *developers_store; 44 GtkTreeStore *developers_store;
46 45
47 GtkWidget *translators_button;
48 GtkWidget *translators_page; 46 GtkWidget *translators_page;
49 GtkWidget *translators_treeview; 47 GtkWidget *translators_treeview;
50 GtkTreeStore *translators_store; 48 GtkTreeStore *translators_store;
51 49
52 GtkWidget *build_info_button;
53 GtkWidget *build_info_page; 50 GtkWidget *build_info_page;
54 GtkWidget *build_info_treeview; 51 GtkWidget *build_info_treeview;
55 GtkTreeStore *build_info_store; 52 GtkTreeStore *build_info_store;
56
57 gboolean switching_pages;
58 }; 53 };
59 54
60 /****************************************************************************** 55 /******************************************************************************
61 * Helpers 56 * Helpers
62 *****************************************************************************/ 57 *****************************************************************************/
63 static void
64 _pidgin_about_dialog_switch_page(PidginAboutDialog *about, const gchar *name) {
65 about->priv->switching_pages = TRUE;
66
67 gtk_stack_set_visible_child_name(GTK_STACK(about->priv->stack), name);
68
69 /* now figure out if developers button is active */
70 gtk_toggle_button_set_active(
71 GTK_TOGGLE_BUTTON(about->priv->developers_button),
72 g_str_equal("developers", name)
73 );
74
75 /* is the translators button active? */
76 gtk_toggle_button_set_active(
77 GTK_TOGGLE_BUTTON(about->priv->translators_button),
78 g_str_equal("translators", name)
79 );
80
81 /* is the build info button active? */
82 gtk_toggle_button_set_active(
83 GTK_TOGGLE_BUTTON(about->priv->build_info_button),
84 g_str_equal("build-info", name)
85 );
86
87 about->priv->switching_pages = FALSE;
88 }
89
90 static void 58 static void
91 _pidgin_about_dialog_load_application_name(PidginAboutDialog *about) { 59 _pidgin_about_dialog_load_application_name(PidginAboutDialog *about) {
92 gchar *label = g_strdup_printf( 60 gchar *label = g_strdup_printf(
93 "%s %s", 61 "%s %s",
94 PIDGIN_NAME, 62 PIDGIN_NAME,
490 static void 458 static void
491 _pidgin_about_dialog_close(GtkWidget *b, gpointer data) { 459 _pidgin_about_dialog_close(GtkWidget *b, gpointer data) {
492 gtk_widget_destroy(GTK_WIDGET(data)); 460 gtk_widget_destroy(GTK_WIDGET(data));
493 } 461 }
494 462
495 static void
496 _pidgin_about_dialog_toggle_developers(GtkToggleButton *b, gpointer d) {
497 PidginAboutDialog *about = d;
498 gboolean show = FALSE;
499
500 if(about->priv->switching_pages)
501 return;
502
503 show = gtk_toggle_button_get_active(b);
504
505 _pidgin_about_dialog_switch_page(d, show ? "developers" : "main");
506 }
507
508 static void
509 _pidgin_about_dialog_toggle_translators(GtkToggleButton *b, gpointer d) {
510 PidginAboutDialog *about = d;
511 gboolean show = FALSE;
512
513 if(about->priv->switching_pages)
514 return;
515
516 show = gtk_toggle_button_get_active(b);
517
518 _pidgin_about_dialog_switch_page(d, show ? "translators" : "main");
519 }
520
521 static void
522 _pidgin_about_dialog_toggle_build_info(GtkToggleButton *b, gpointer d) {
523 PidginAboutDialog *about = d;
524 gboolean show = FALSE;
525
526 if(about->priv->switching_pages)
527 return;
528
529 show = gtk_toggle_button_get_active(b);
530
531 _pidgin_about_dialog_switch_page(d, show ? "build-info" : "main");
532 }
533
534 /****************************************************************************** 463 /******************************************************************************
535 * GObject Stuff 464 * GObject Stuff
536 *****************************************************************************/ 465 *****************************************************************************/
537 G_DEFINE_TYPE_WITH_PRIVATE(PidginAboutDialog, pidgin_about_dialog, GTK_TYPE_DIALOG); 466 G_DEFINE_TYPE_WITH_PRIVATE(PidginAboutDialog, pidgin_about_dialog, GTK_TYPE_DIALOG);
538 467
549 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, application_name); 478 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, application_name);
550 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, stack); 479 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, stack);
551 480
552 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, main_scrolled_window); 481 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, main_scrolled_window);
553 482
554 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, developers_button);
555 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, developers_page); 483 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, developers_page);
556 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, developers_store); 484 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, developers_store);
557 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, developers_treeview); 485 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, developers_treeview);
558 486
559 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, translators_button);
560 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, translators_page); 487 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, translators_page);
561 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, translators_store); 488 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, translators_store);
562 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, translators_treeview); 489 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, translators_treeview);
563 490
564 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, build_info_button);
565 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, build_info_page); 491 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, build_info_page);
566 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, build_info_store); 492 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, build_info_store);
567 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, build_info_treeview); 493 gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, build_info_treeview);
568 } 494 }
569 495
570 static void 496 static void
571 pidgin_about_dialog_init(PidginAboutDialog *about) { 497 pidgin_about_dialog_init(PidginAboutDialog *about) {
572 about->priv = pidgin_about_dialog_get_instance_private(about); 498 about->priv = pidgin_about_dialog_get_instance_private(about);
573
574 about->priv->switching_pages = FALSE;
575 499
576 gtk_widget_init_template(GTK_WIDGET(about)); 500 gtk_widget_init_template(GTK_WIDGET(about));
577 501
578 /* wire up the close button */ 502 /* wire up the close button */
579 g_signal_connect( 503 g_signal_connect(
588 512
589 /* setup the main page */ 513 /* setup the main page */
590 _pidgin_about_dialog_load_main_page(about); 514 _pidgin_about_dialog_load_main_page(about);
591 515
592 /* setup the developers stuff */ 516 /* setup the developers stuff */
593 g_signal_connect(
594 about->priv->developers_button,
595 "toggled",
596 G_CALLBACK(_pidgin_about_dialog_toggle_developers),
597 about
598 );
599
600 _pidgin_about_dialog_load_developers(about); 517 _pidgin_about_dialog_load_developers(about);
601 gtk_tree_view_expand_all(GTK_TREE_VIEW(about->priv->developers_treeview)); 518 gtk_tree_view_expand_all(GTK_TREE_VIEW(about->priv->developers_treeview));
602 519
603 /* setup the translators stuff */ 520 /* setup the translators stuff */
604 g_signal_connect(
605 about->priv->translators_button,
606 "toggled",
607 G_CALLBACK(_pidgin_about_dialog_toggle_translators),
608 about
609 );
610
611 _pidgin_about_dialog_load_translators(about); 521 _pidgin_about_dialog_load_translators(about);
612 gtk_tree_view_expand_all(GTK_TREE_VIEW(about->priv->translators_treeview)); 522 gtk_tree_view_expand_all(GTK_TREE_VIEW(about->priv->translators_treeview));
613 523
614 /* setup the build info page */ 524 /* setup the build info page */
615 g_signal_connect(
616 about->priv->build_info_button,
617 "toggled",
618 G_CALLBACK(_pidgin_about_dialog_toggle_build_info),
619 about
620 );
621
622 _pidgin_about_dialog_load_build_configuration(about); 525 _pidgin_about_dialog_load_build_configuration(about);
623 gtk_tree_view_expand_all(GTK_TREE_VIEW(about->priv->build_info_treeview)); 526 gtk_tree_view_expand_all(GTK_TREE_VIEW(about->priv->build_info_treeview));
624 } 527 }
625 528
626 GtkWidget * 529 GtkWidget *

mercurial