ef056d7ec3bc0f3aa7bf5c0cca990d8bba11261c
[hildon] / ut / tc_banner_truncate.c
1 /*
2  * This file is part of hildon-libs
3  *
4  * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
5  *
6  * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com> 
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; version 2.1 of
11  * the License.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24
25 /*
26
27  gcc `pkg-config --cflags gtk+-2.0 hildon-libs` `pkg-config --libs gtk+-2.0 hildon-libs`  -o tc_banner_truncate tc_banner_truncate.c && DISPLAY=:2 run-standalone.sh  ./tc_banner_truncate 1
28
29  Usage 1: tc_banner_truncate <case #>
30  Usage 2: tc_banner_truncate <1|2|3> the string you like to be displayed
31                               1 -> information banner
32                               2 -> progress banner
33                               3 -> animation banner
34 */
35
36 #include <stdio.h>
37 #include <gtk/gtk.h>
38 #include <hildon-widgets/hildon-banner.h>
39
40 #define WAIT g_timeout_add(3000, (GSourceFunc)(gtk_main_quit), NULL);
41
42 #define TC_INFO(string) hildon_banner_show_information(window,  NULL, string); WAIT;
43 #define TC_ANIM(string) banner = hildon_banner_show_animation(NULL, NULL, string);
44 #define TC_PROG(string) banner = hildon_banner_show_progress (NULL, NULL, string);
45
46 static void get_argv_string(int argc, char ** argv, char *text);
47
48 int main(int argc, char **argv)
49 {
50   GtkWidget *window;
51   GtkWidget *banner;
52   int n;
53   char text[10000];
54
55   if(argc <  2){ fprintf(stderr, "Add case # as parameter.\n");  return 1;}
56   if(argc >= 2){ if(sscanf(argv[1], "%d", &n) == 0) n = 1;}
57   if(argc >  2){ get_argv_string(argc, argv, text);}
58
59   gtk_init(&argc, &argv);
60   
61   window = gtk_dialog_new();
62   
63   if(argc > 2){
64     /* text is given in the command line */
65     switch (n){
66     case 1: TC_INFO(text); break;
67     case 2: TC_PROG(text); break;
68     case 3: TC_ANIM(text); break;
69     default:TC_INFO(text); break;
70     }
71     n = -99999;
72   }
73
74   switch (n) {
75   /* NOTE: comments (*) are given for 0.12.12, with default theme (orange)
76    *       (*) "truncated", WRAPPED", etc.
77    */
78
79   case 0: TC_INFO(""); break;
80   case 1: TC_INFO("loading..."); break;
81
82   case 11: TC_INFO("mmmmmmmmmmmmmmmmmm m.."       ); break; //1 line
83   case 12: TC_INFO("mmmmmmmmmmmmmmmmmm m..."      ); break; //truncated
84   case 13: TC_INFO("mmmmmmmmmmmmmmmmmm m...."     ); break; //truncated
85   case 14: TC_INFO("mmmmmmmmmmmmmmmmmm m....."    ); break; //truncated
86   case 15: TC_INFO("mmmmmmmmmmmmmmmmmm m......"   ); break; //truncated
87   case 16: TC_INFO("mmmmmmmmmmmmmmmmmm m......."  ); break; //truncated
88   case 17: TC_INFO("mmmmmmmmmmmmmmmmmm m........" ); break; //truncated
89   case 18: TC_INFO("mmmmmmmmmmmmmmmmmm m........."); break; //WRAPPED
90
91   case 21: TC_INFO("maximum number of characters xxxxxxxx");  break; //WRAPPED
92   case 22: TC_INFO("maximum number of characters xxxxxxxi");  break; //truncated
93
94   case 23: TC_INFO("Maximum number of characters reache"   ); break; //1 line
95   case 24: TC_INFO("Maximum number of characters reached"  ); break; //truncated
96   case 25: TC_INFO("Maximum number of characters reached." ); break; //truncated
97   case 26: TC_INFO("Maximum number of characters reached " ); break; //truncated
98   case 27: TC_INFO("Maximum number of characters reached a"); break; //WRAPPED
99
100   /* progress banners */
101   case 101: TC_PROG(""               ); break;
102   case 102: TC_PROG("hello"          ); break;
103   case 103: TC_PROG("hello progress" ); break;
104
105   /* Bugzilla related TC */
106   case -1: case 25305: TC_INFO("Maximum number of characters reached");      break;
107   case -2: case 23430: TC_INFO("Unable to manage folders during searching"); break; //PASSED
108   case -3: case 26624: TC_ANIM("Connection Manager - Loading");              break;
109   case -4: case 26161: TC_ANIM("Painel de Controle - carregando");           break;
110   case -5: case 26203: TC_ANIM("Caricamento di Pannello di controllo");      break;
111   case -6: case 27875: TC_ANIM("Instant messaging - loading");               break;
112   case -7: case 28760: TC_ANIM("Teach Handwriting- Loading");                break;
113
114   /* word longer than max width */
115   case 201: TC_INFO("mmmmmmmmmmmmmmmmmmmmmmmmmmmmm 1 2 3 4");  break;
116
117   /* misc */
118   case 202: TC_INFO("Maximum number of characters reached osaidfh galds hgdslf helius grkdsz vfliesdfrjaesfrszri os o ozx oyli l ilij ero worjw aeowaijf osijf a jfaowijef aoweijf s faoij flsaijf sajfd oaijfe aosi e 1 2 3 4"); break; /* TRUNCATED after last 'e' */
119
120
121   /* TC for plain GTK (no theme) */
122   case -1031: TC_INFO("iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiil i."); break; //1 line
123   case -1032: TC_INFO("iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiil i."); break; //WRAPPED
124
125   case -1033: TC_INFO("mmmmmmmmmmmmmmmmmm m................................................i" ); break; //1 line
126   case -1034: TC_INFO("mmmmmmmmmmmmmmmmmm m.................................................i"); break; //WRAPPED
127
128
129   default:
130     WAIT;
131   }
132
133   gtk_main();
134   return 0;
135 }
136
137
138
139
140
141
142
143
144 /* ############################################################################## */
145 /* ############################################################################## */
146 /* ############################################################################## */
147
148 static void get_argv_string(int argc, char ** argv, char *text){
149   int i,j;
150   char * s;
151   s = text;
152   for(i=2; i<argc; i++){
153     for(j=0; argv[i][j] != '\0'; j++){
154       *s = argv[i][j];
155       s++;
156     }
157     if(i<(argc-1)){
158       *s=' ';
159       s++;
160     }
161   }
162   /* hem */
163 }