[go: up one dir, main page]

File: toolbar.c

package info (click to toggle)
linpopup 0.9.3.pre4-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 440 kB
  • ctags: 151
  • sloc: ansic: 2,102; sh: 197; makefile: 171
file content (117 lines) | stat: -rw-r--r-- 4,068 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/* LinPopUp - A Linux enhanced port of Winpopup, running over Samba.
 * By Jean-Marc Jacquet <littleigloo@chez.com> 
 * Copyright (C) 1998 Little Igloo Org  http://www.chez.com/littleigloo
 *
 *
 * 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 <gdk/gdkkeysyms.h>
#include "protos.h"

#include "pixmaps/new_16.xpm"
#include "pixmaps/reply_16.xpm"
#include "pixmaps/del_16.xpm"
#include "pixmaps/left_16.xpm"
#include "pixmaps/right_16.xpm"
#include "pixmaps/min_16.xpm"
#include "pixmaps/new_256.xpm"
#include "pixmaps/reply_256.xpm"
#include "pixmaps/del_256.xpm"
#include "pixmaps/left_256.xpm"
#include "pixmaps/right_256.xpm"
#include "pixmaps/min_256.xpm"



GtkWidget *
new_pixmap (GtkWidget * widget, char **data)
{
  GdkPixmap *gdkpixmap;
  GdkBitmap *mask;
  GtkWidget *pixmap;

  gdkpixmap = gdk_pixmap_create_from_xpm_d (widget->window, &mask, &widget->style->bg[GTK_STATE_NORMAL], data);
  pixmap = gtk_pixmap_new (gdkpixmap, mask);
  return pixmap;
}



GtkWidget *
create_toolbar (GtkWidget * window, GtkWidget * vbox)
{
  GtkWidget *toolbar;
  GdkColormap *colormap;
  static GtkWidget *icon_new, *icon_reply, *icon_del, *icon_left, *icon_right,
   *icon_min;
  static GdkColor tooltips_fg =
  {0, 0, 0, 0};
  static GdkColor tooltips_bg =
  {0, 0xffff, 0xffff, 0xcccc};

  toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, user_rc.toolbar_style);
  gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, TRUE, 0);
  gtk_widget_show (toolbar);

  colormap = gtk_widget_get_colormap (window);
  if (gdk_color_alloc (colormap, &tooltips_fg)
      && gdk_color_alloc (colormap, &tooltips_bg))
    {
      gtk_tooltips_set_colors (GTK_TOOLBAR (toolbar)->tooltips, &tooltips_bg, &tooltips_fg);
    }

  if (user_rc.hcolors)
    {
      icon_new = new_pixmap (window, new_256);
      icon_reply = new_pixmap (window, reply_256);
      icon_del = new_pixmap (window, del_256);
      icon_left = new_pixmap (window, left_256);
      icon_right = new_pixmap (window, right_256);
      icon_min = new_pixmap (window, min_256);
    }
  else
    {
      icon_new = new_pixmap (window, new_16);
      icon_reply = new_pixmap (window, reply_16);
      icon_del = new_pixmap (window, del_16);
      icon_left = new_pixmap (window, left_16);
      icon_right = new_pixmap (window, right_16);
      icon_min = new_pixmap (window, min_16);
    }

  gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), " New ", " Send a New Message", "", icon_new,
			   GTK_SIGNAL_FUNC (send_message), NULL);
  gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), " Reply ", " Reply to this Message", "", icon_reply,
			   GTK_SIGNAL_FUNC (reply_message), NULL);

  gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));

  gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), " Delete ", "Delete this Message", "", icon_del,
			   GTK_SIGNAL_FUNC (delete_showed_message), NULL);

  gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), " Previous ", "Show Previous Message", "", icon_left,
			   GTK_SIGNAL_FUNC (show_previous_message), NULL);
  gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), " Next ", "Show Next Message", "", icon_right,
			   GTK_SIGNAL_FUNC (show_next_message), NULL);

  gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));

  gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), " Minimize ", "Minimize LinPopUp", "", icon_min,
		     GTK_SIGNAL_FUNC (iconify_window), GTK_WINDOW (window));

  return toolbar;
}