~ubuntu-branches/ubuntu/hardy/gnomad2/hardy

« back to all changes in this revision

Viewing changes to src/util.c

  • Committer: Bazaar Package Importer
  • Author(s): Shaun Jackman
  • Date: 2005-08-19 16:09:28 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050819160928-l2glu227nh0algdc
Tags: 2.8.0-2
Add a versioned dependency for libnjb-dev (>> 2.2). Closes: #324036.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
*/
18
18
 
19
19
#include "common.h"
 
20
#if !GTK_CHECK_VERSION(2,4,0)
20
21
#include <libgnomeui/libgnomeui.h>
 
22
#endif
 
23
 
 
24
extern GtkWidget *main_window;
21
25
 
22
26
/* Find the length of a string vector */
23
27
gint vectorlength(gchar **vector)
43
47
   * new GLib functions -> 2.0 */
44
48
  gchar *tmpstring;
45
49
 
46
 
  if (!add)
 
50
  if (add == NULL)
47
51
    return org;
48
 
  if (!org)
 
52
  if (org == NULL)
49
53
    return g_strdup(add);
 
54
 
50
55
  tmpstring = (gchar *) g_malloc(strlen(org) + strlen(add) + 1);
51
56
  tmpstring = strcpy(tmpstring, org);
52
57
  tmpstring = strcat(tmpstring, add);
134
139
 * a string in mm:ss notation */
135
140
gchar *seconds_to_mmss(guint seconds)
136
141
{
137
 
  gchar tmp2[4];
 
142
  gchar tmp2[10];
138
143
  gchar tmp[10];
 
144
  guint secfrac = seconds % 60;
 
145
  guint minfrac = seconds / 60;
139
146
 
140
 
  if (!seconds)
 
147
  if (seconds == 0)
141
148
    return g_strdup("0:00");
142
 
  sprintf(tmp2, "0%u", seconds%60);
 
149
 
 
150
  snprintf(tmp2, 10, "0%u", secfrac);
143
151
  while (strlen(tmp2)>2) {
144
152
    tmp2[0]=tmp2[1];
145
153
    tmp2[1]=tmp2[2];
146
154
    tmp2[2]='\0';
147
155
  }
148
 
  sprintf(tmp, "%lu:%s", seconds/60, tmp2);
 
156
  snprintf(tmp, 10, "%lu:%s", minfrac, tmp2);
149
157
  return g_strdup(tmp);
150
158
}
151
159
 
204
212
  GtkWidget *dialog;
205
213
  GtkWidget *label, *button;
206
214
 
 
215
#if GTK_CHECK_VERSION(2,4,0)
 
216
  dialog = gtk_message_dialog_new (GTK_WINDOW(main_window),
 
217
                                   GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
 
218
                                   GTK_MESSAGE_ERROR,
 
219
                                   GTK_BUTTONS_CLOSE,
 
220
                                   errorstring);
 
221
  g_signal_connect_object(GTK_OBJECT(dialog),
 
222
                          "delete_event",
 
223
                          G_CALLBACK(gtk_widget_destroy),
 
224
                          NULL,
 
225
                          0);
 
226
  g_signal_connect_object(GTK_OBJECT(dialog), 
 
227
                          "response",
 
228
                          G_CALLBACK(gtk_widget_destroy), 
 
229
                          NULL,
 
230
                          0);
 
231
  gtk_widget_show(dialog);
 
232
#else
207
233
  dialog = gnome_message_box_new (errorstring,
208
234
                                  GNOME_MESSAGE_BOX_ERROR,
209
235
                                  GNOME_STOCK_BUTTON_OK,
210
236
                                  NULL);
211
237
  gtk_widget_show(dialog);
 
238
#endif
 
239
}
 
240
 
 
241
gboolean request_confirmation_dialog(gchar *confirmstring)
 
242
{
 
243
  GtkWidget *dialog;
 
244
  GtkWidget *label, *button;
 
245
  gint i;
 
246
  gboolean retval = FALSE;
 
247
 
 
248
#if GTK_CHECK_VERSION(2,4,0)
 
249
  dialog = gtk_message_dialog_new (GTK_WINDOW(main_window),
 
250
                                   GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
 
251
                                   GTK_MESSAGE_QUESTION,
 
252
                                   GTK_BUTTONS_YES_NO,
 
253
                                   confirmstring);
 
254
  i = gtk_dialog_run(GTK_DIALOG(dialog));
 
255
  gtk_widget_destroy(dialog);
 
256
  if (i == GTK_RESPONSE_YES) {
 
257
    retval = TRUE;
 
258
  }
 
259
#else
 
260
  /*
 
261
    I can't seem to get GNOMEUI to do this properly, so I'm leaving it
 
262
    out for clients that do not have a sufficiently new GTK.
 
263
 
 
264
    g_print("Awaiting confirmation (GNOMEUI): %s...\n", confirmstring);
 
265
    dialog = gnome_message_box_new (confirmstring,
 
266
                                  GNOME_MESSAGE_BOX_QUESTION,
 
267
                                  GNOME_STOCK_BUTTON_YES,
 
268
                                  GNOME_STOCK_BUTTON_CANCEL,
 
269
                                  NULL);
 
270
    gtk_widget_show(dialog);
 
271
    i = gnome_dialog_run_and_close(GNOME_DIALOG(dialog));
 
272
  
 
273
    if (i == 0) {
 
274
      retval = TRUE;
 
275
    }
 
276
  */
 
277
  retval = TRUE;
 
278
#endif
 
279
  return retval;
212
280
}
213
281
 
214
282
void hexdump(unsigned char *data, guint len)