~ubuntu-branches/debian/sid/gworldclock/sid

« back to all changes in this revision

Viewing changes to misc.c

  • Committer: Bazaar Package Importer
  • Author(s): Drew Parsons
  • Date: 2005-03-28 13:50:18 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050328135018-jk2szisqaovghn3s
Tags: 1.4.4-1
* New upstream version.
  - modernised design of AddZone dialog. Closes: #193952.
  - removed use of deprecated GTK functions and objects.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* various ancillary functions */
 
2
 
 
3
#include "misc.h"
 
4
 
 
5
void DestroyWindow(GtkWidget *w, gpointer window)
 
6
{
 
7
  gtk_widget_destroy((GtkWidget *)window);
 
8
}
 
9
 
 
10
gint GotOK(GtkWidget *w, GdkEventKey *event,  gpointer Button)
 
11
{
 
12
  GdkEvent *dummyevent;
 
13
  gint return_val;
 
14
 
 
15
  if(event->keyval==GDK_Return) {
 
16
    dummyevent=(GdkEvent*)g_malloc(sizeof(GdkEvent));
 
17
    g_signal_emit_by_name((GObject *) Button,
 
18
                            "clicked", &dummyevent, &return_val);
 
19
    g_free(dummyevent);
 
20
    return TRUE;
 
21
  }
 
22
  return FALSE;
 
23
}
 
24
 
 
25
gint GotOKInDialog(GtkWidget *w, GdkEventKey *event,  gpointer dialog)
 
26
{
 
27
  gint return_val;
 
28
 
 
29
  if(event->keyval==GDK_Return) 
 
30
  {
 
31
     gtk_dialog_response( GTK_DIALOG( dialog ), OK_BUTTON );
 
32
     return TRUE;
 
33
  }
 
34
  return FALSE;
 
35
}
 
36
 
 
37
/* find the length (in characters) of the longest entry in a GList
 
38
   containing string data. */
 
39
gint getLongestEntry(GList *list)
 
40
{
 
41
  GList *plist;
 
42
  gint longest = 0;
 
43
  gint length;
 
44
  
 
45
  plist = list;
 
46
  while ( plist != NULL ) 
 
47
    {
 
48
    length = strlen( (gchar*)plist->data );
 
49
    if ( length > longest )
 
50
      longest = length;
 
51
    plist = g_list_next(plist);
 
52
  }
 
53
  return longest;
 
54
}
 
55
 
 
56
 
 
57
/* displays the message in an "OK" style dialog box.
 
58
   messageType indicates Warning, Error, etc (see GtkMessageDialog).
 
59
*/
 
60
void showMessageDialog( gchar *message, GtkMessageType messageType )
 
61
{
 
62
   GtkWidget *dialog;
 
63
 
 
64
   dialog = gtk_message_dialog_new( NULL,
 
65
                                    0,
 
66
                                    messageType,
 
67
                                    GTK_BUTTONS_OK,
 
68
                                    message);
 
69
 
 
70
   g_signal_connect_swapped (G_OBJECT (dialog), "response",
 
71
                             G_CALLBACK (gtk_widget_destroy),
 
72
                             GTK_OBJECT (dialog));
 
73
   gtk_widget_show(dialog);                                  
 
74
}
 
75