File: about.c

package info (click to toggle)
gmp3 0.080-3
  • links: PTS
  • area: contrib
  • in suites: potato
  • size: 576 kB
  • ctags: 514
  • sloc: ansic: 5,441; makefile: 139; perl: 28; sh: 18
file content (82 lines) | stat: -rw-r--r-- 2,776 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* GMP3 - A front end for mpg123
 * Copyright (C) 1998 Brett Kosinski
 *
 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <gtk/gtk.h>
#include <string.h>
#include <stdlib.h>
#include <gdk_imlib.h>
#include "pixmap.h"
#include "about.h"

void createAboutBox()
{
  static GtkWidget *window = NULL;
  GtkWidget *pixmap;
  GtkWidget *button;
  GtkWidget *label;
  GtkWidget *vbox;
  char *labelStr = (char *)malloc(strlen(VERSION)+
                                  strlen("GMP3 ")+
                                  strlen(" by Brett Kosinski")+1);
  strcpy(labelStr, "GMP3 ");
  strcat(labelStr, VERSION);
  strcat(labelStr, " by Brett Kosinski");

  if (! window)
    {
      window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
      gtk_window_set_title(GTK_WINDOW(window), "About GMP3");
      gtk_window_set_wmclass(GTK_WINDOW(window), "gmp3.about_gmp3", NULL);
      gtk_widget_realize(window);

      vbox = gtk_vbox_new(FALSE, 0);
      gtk_container_add(GTK_CONTAINER(window), vbox);
      gtk_widget_show(vbox);

      pixmap = load_image("gmp3logo.jpg", window->window,
                          &window->style->bg[GTK_STATE_NORMAL],
                          NULL, NULL, FALSE);
      gtk_box_pack_start(GTK_BOX(vbox), pixmap, FALSE, FALSE, 0);
      gtk_widget_show(pixmap);

      label = gtk_label_new(labelStr);
      free(labelStr);
      gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
      gtk_widget_show(label);

      button = gtk_button_new_with_label("Close");
      gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
      gtk_widget_show(button);

      gtk_signal_connect_object(GTK_OBJECT(button), "clicked",
                                GTK_SIGNAL_FUNC(gtk_widget_hide),
                                GTK_OBJECT(window));

      gtk_signal_connect_object(GTK_OBJECT(window), "delete_event",
                                GTK_SIGNAL_FUNC(gtk_widget_hide),
                                GTK_OBJECT(window));
      gtk_widget_show(window);
    }
  else
    {
      if (! GTK_WIDGET_VISIBLE(window))
        gtk_widget_show(window);
      else
        return;
    }
}