~ubuntu-branches/ubuntu/hardy/avidemux/hardy

« back to all changes in this revision

Viewing changes to avidemux/ADM_userInterfaces/ADM_GTK/ADM_dialogFactory/FAC_hex.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Matvey Kozhev
  • Date: 2007-12-18 13:53:04 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071218135304-cdqec2lg2bglyz15
Tags: 1:2.4~preview3-0.0ubuntu1
* Upload to Ubuntu. (LP: #163287, LP: #126572)
* debian/changelog: re-added Ubuntu releases.
* debian/control:
  - Require debhelper >= 5.0.51 (for dh_icons) and imagemagick.
  - Build-depend on libsdl1.2-dev instead of libsdl-dev.
  - Build against newer libx264-dev. (LP: #138854)
  - Removed libamrnb-dev, not in Ubuntu yet.
* debian/rules:
  - Install all icon sizes, using convert (upstream installs none).
  - Added missing calls to dh_installmenu, dh_installman, dh_icons and
    dh_desktop.
* debian/menu, debian/avidemux-qt.menu:
  - Corrected package and executable names.
* debian/avidemux-common.install: Install icons.
* debian/avidemux.common.manpages: Install man/avidemux.1.
* debian/links, debian/avidemux-cli.links, debian/avidemux-gtk.links:
  - Link manpages to avidemux.1.gz.
* debian/install, debian/avidemux-qt.install, debian/avidemux-gtk.desktop,
  debian/avidemux-qt.desktop: Install desktop files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
  FAC_toggle.cpp
 
3
  Handle dialog factory element : Toggle
 
4
  (C) 2006 Mean Fixounet@free.fr 
 
5
***************************************************************************/
 
6
 
 
7
/***************************************************************************
 
8
 *                                                                         *
 
9
 *   This program is free software; you can redistribute it and/or modify  *
 
10
 *   it under the terms of the GNU General Public License as published by  *
 
11
 *   the Free Software Foundation; either version 2 of the License, or     *
 
12
 *   (at your option) any later version.                                   *
 
13
 *                                                                         *
 
14
 ***************************************************************************/
 
15
 
 
16
#include <config.h>
 
17
 
 
18
 
 
19
#include <string.h>
 
20
#include <stdio.h>
 
21
#include <math.h>
 
22
 
 
23
#include "default.h"
 
24
#include "ADM_toolkit_gtk/ADM_gladeSupport.h"
 
25
#include "ADM_toolkit_gtk/toolkit_gtk.h"
 
26
#include "ADM_toolkit_gtk/toolkit_gtk_include.h"
 
27
#include "ADM_commonUI/DIA_factory.h"
 
28
#include "ADM_assert.h"
 
29
 
 
30
#define HEX_NB_LINE   8
 
31
#define HEX_NB_COLUMN 16
 
32
 
 
33
 
 
34
 
 
35
typedef struct hexStruct
 
36
 
37
    GtkWidget *grid;
 
38
    GtkWidget *entry[HEX_NB_LINE];
 
39
    uint8_t   *data;
 
40
    uint32_t  size;
 
41
    uint32_t  curOffset;
 
42
}hexStruct;
 
43
 
 
44
static void updateMe(hexStruct *s);
 
45
static void prev(void *z,hexStruct *s);
 
46
static void next(void *z,hexStruct *s);
 
47
 
 
48
diaElemHex::diaElemHex(const char *toggleTitle, uint32_t dataSize,uint8_t *data)
 
49
  : diaElem(ELEM_HEXDUMP)
 
50
{
 
51
  param=NULL;
 
52
  paramTitle=toggleTitle;
 
53
  this->tip=NULL;
 
54
  this->data=data;
 
55
  this->dataSize=dataSize;
 
56
   setSize(3);
 
57
}
 
58
 
 
59
diaElemHex::~diaElemHex()
 
60
{
 
61
  if(myWidget)
 
62
  {
 
63
     hexStruct *s=(hexStruct *)myWidget;
 
64
     delete s;
 
65
     myWidget=NULL;
 
66
  }
 
67
}
 
68
void diaElemHex::setMe(void *dialog, void *opaque,uint32_t line)
 
69
{
 
70
  GtkWidget *hexTable;
 
71
  GtkWidget *buttonP, *alignment1, *hbox1, *image1, *label1;
 
72
  GtkWidget *buttonN, *alignment2, *hbox2, *image2, *label2;
 
73
  uint8_t *tail=data+dataSize;
 
74
  
 
75
  hexTable=gtk_table_new(1,HEX_NB_LINE,0);
 
76
  gtk_widget_show(hexTable);
 
77
  
 
78
  
 
79
  gtk_table_attach (GTK_TABLE (opaque), hexTable, 0, 2, line, line+1,
 
80
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
 
81
                    (GtkAttachOptions) (0), 0, 0);
 
82
  
 
83
  hexStruct *s=new hexStruct;
 
84
  s->grid=hexTable;
 
85
  s->data=data;
 
86
  s->size=dataSize;
 
87
  s->curOffset=0;
 
88
  for(int i=0;i<HEX_NB_LINE;i++)
 
89
  {
 
90
    s->entry[i]=gtk_label_new("");
 
91
    gtk_label_set_selectable(GTK_LABEL(s->entry[i]), TRUE);
 
92
    gtk_misc_set_alignment (GTK_MISC (s->entry[i]), 0, 1);
 
93
    gtk_widget_show(s->entry[i]);
 
94
     gtk_table_attach (GTK_TABLE (hexTable), s->entry[i], 0, 1, i, i+1,
 
95
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
 
96
                    (GtkAttachOptions) (0), 0, 0);
 
97
  }
 
98
  myWidget=(void *)s;
 
99
  //*************************
 
100
  buttonP = gtk_button_new_with_mnemonic (QT_TR_NOOP("_Previous"));
 
101
  gtk_widget_show (buttonP);
 
102
  gtk_table_attach (GTK_TABLE (opaque), buttonP, 0, 1, line+1, line+2,
 
103
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
 
104
                    (GtkAttachOptions) (0), 0, 0);
 
105
   g_signal_connect(GTK_OBJECT(buttonP), "clicked",
 
106
                    GTK_SIGNAL_FUNC(prev), s);
 
107
   
 
108
  buttonN = gtk_button_new_with_mnemonic (QT_TR_NOOP("_Next"));
 
109
  gtk_widget_show (buttonN);
 
110
  gtk_table_attach (GTK_TABLE (opaque), buttonN, 1, 2, line+1, line+2,
 
111
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
 
112
                    (GtkAttachOptions) (0), 0, 0);
 
113
   g_signal_connect(GTK_OBJECT(buttonN), "clicked",
 
114
                    GTK_SIGNAL_FUNC(next), s);
 
115
#if 0
 
116
  alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0);
 
117
  gtk_widget_show (alignment1);
 
118
  
 
119
 
 
120
  hbox1 = gtk_hbox_new (FALSE, 2);
 
121
  gtk_widget_show (hbox1);
 
122
  gtk_container_add (GTK_CONTAINER (alignment1), hbox1);
 
123
 
 
124
  
 
125
  
 
126
  GTK_WIDGET_SET_FLAGS (buttonP, GTK_CAN_DEFAULT);
 
127
  gtk_box_pack_start (GTK_BOX (hbox1), buttonP, FALSE, FALSE, 0);
 
128
  gtk_container_add (GTK_CONTAINER (buttonP), alignment1);
 
129
  
 
130
  image1 = gtk_image_new_from_stock ("gtk-go-back", GTK_ICON_SIZE_BUTTON);
 
131
  gtk_widget_show (image1);
 
132
  gtk_box_pack_start (GTK_BOX (hbox1), image1, FALSE, FALSE, 0);
 
133
 
 
134
  label1 = gtk_label_new_with_mnemonic (QT_TR_NOOP("_Previous"));
 
135
  gtk_widget_show (label1);
 
136
  gtk_box_pack_start (GTK_BOX (hbox1), label1, FALSE, FALSE, 0);
 
137
 
 
138
  gtk_table_attach (GTK_TABLE (opaque), hbox1, 0, 1, line+1, line+2,
 
139
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
 
140
                    (GtkAttachOptions) (0), 0, 0);
 
141
  
 
142
  g_signal_connect(GTK_OBJECT(buttonP), "clicked",
 
143
                    GTK_SIGNAL_FUNC(prev), s);
 
144
 
 
145
 
 
146
  alignment2 = gtk_alignment_new (0.5, 0.5, 0, 0);
 
147
  gtk_widget_show (alignment2);
 
148
  gtk_container_add (GTK_CONTAINER (buttonN), alignment2);
 
149
 
 
150
  hbox2 = gtk_hbox_new (FALSE, 2);
 
151
  gtk_widget_show (hbox2);
 
152
  gtk_container_add (GTK_CONTAINER (alignment2), hbox2);
 
153
 
 
154
  buttonN = gtk_button_new ();
 
155
  gtk_widget_show (buttonN);
 
156
  gtk_box_pack_start (GTK_BOX (hbox2), buttonN, FALSE, FALSE, 0);
 
157
  GTK_WIDGET_SET_FLAGS (buttonN, GTK_CAN_DEFAULT);
 
158
 
 
159
  
 
160
  image2 = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_BUTTON);
 
161
  gtk_widget_show (image2);
 
162
  gtk_box_pack_start (GTK_BOX (hbox2), image2, FALSE, FALSE, 0);
 
163
 
 
164
  label2 = gtk_label_new_with_mnemonic (QT_TR_NOOP("_Next"));
 
165
  gtk_widget_show (label2);
 
166
  gtk_box_pack_start (GTK_BOX (hbox2), label2, FALSE, FALSE, 0);
 
167
 
 
168
  gtk_table_attach (GTK_TABLE (opaque), hbox2, 0, 1, line+2, line+3,
 
169
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
 
170
                    (GtkAttachOptions) (0), 0, 0);
 
171
  g_signal_connect(GTK_OBJECT(buttonN), "clicked",
 
172
                    GTK_SIGNAL_FUNC(next),  s);
 
173
#endif
 
174
  updateMe(s);
 
175
}
 
176
void prev(void *z,hexStruct *s)
 
177
{
 
178
  if(s->curOffset>=HEX_NB_COLUMN*4)
 
179
      s->curOffset-=HEX_NB_COLUMN*4;
 
180
  updateMe(s);
 
181
  
 
182
}
 
183
void next(void *z,hexStruct *s)
 
184
{
 
185
      s->curOffset+=HEX_NB_COLUMN*4;
 
186
  updateMe(s);
 
187
}
 
188
void updateMe(hexStruct *s)
 
189
{
 
190
  uint8_t *tail=s->data+s->size;
 
191
  uint8_t *cur;
 
192
  char string[3000];
 
193
  char *ptr;
 
194
  for(int i=0;i<HEX_NB_LINE;i++)
 
195
  {
 
196
     cur=s->data+HEX_NB_COLUMN*i+s->curOffset;
 
197
     
 
198
     sprintf(string,"%06x:",HEX_NB_COLUMN*i+s->curOffset);
 
199
     ptr=string+strlen(string);
 
200
     *ptr=0;
 
201
     for(int j=0;j<HEX_NB_COLUMN;j++)
 
202
     {
 
203
       if(cur<tail)
 
204
       {
 
205
          sprintf(ptr,"%02X ",*cur++);
 
206
       }
 
207
           else
 
208
       {
 
209
                  sprintf(ptr,"XX ");
 
210
       }
 
211
 
 
212
           ptr+=3;
 
213
     }
 
214
 
 
215
     gtk_label_set_text(GTK_LABEL(s->entry[i]),string);     
 
216
  }
 
217
}
 
218
void diaElemHex::getMe(void)
 
219
{
 
220
 
 
221
}
 
222
void diaElemHex::finalize(void) 
 
223
{
 
224
 
 
225
};
 
226
 
 
227
//EOF