[patch] new widget message WIDGET_RESIZED
- From: Roland Illig <roland illig gmx de>
- To: MC Devel <mc-devel gnome org>
- Subject: [patch] new widget message WIDGET_RESIZED
- Date: Thu, 20 Jan 2005 18:16:33 +0100
Hi all,
I am currently cleaning up the src/view.{h,c} files. I don't like that
the procedure view_update_bytes_per_line is exported in view.h, so I
wrote a nice workaround for it. I am sure this can be used in many other
places.
With this patch applied, there's no need for view_update_bytes_per_line
to be exported to the world. Furthermore, it's no more the
responsibility of the _users_ of WView to keep the bytes_per_line
updated, which is nice.
It works for me. ;)
Roland
Index: src/dialog.c
===================================================================
RCS file: /cvsroot/mc/mc/src/dialog.c,v
retrieving revision 1.27
diff -u -p -u -r1.27 dialog.c
--- src/dialog.c 2 Nov 2004 11:49:56 -0000 1.27
+++ src/dialog.c 20 Jan 2005 17:07:12 -0000
@@ -819,6 +819,7 @@ void widget_set_size (Widget *widget, in
widget->y = y;
widget->cols = cols;
widget->lines = lines;
+ send_message (widget, WIDGET_RESIZED, 0 /* unused */);
}
/* Replace widget old_w for widget new_w in the dialog h */
Index: src/dialog.h
===================================================================
RCS file: /cvsroot/mc/mc/src/dialog.h,v
retrieving revision 1.18
diff -u -p -u -r1.18 dialog.h
--- src/dialog.h 9 Jan 2005 16:15:24 -0000 1.18
+++ src/dialog.h 20 Jan 2005 17:07:12 -0000
@@ -44,7 +44,8 @@ typedef enum {
WIDGET_HOTKEY, /* Sent to widget to catch preprocess key */
WIDGET_DESTROY, /* Sent to widget at destruction time */
WIDGET_CURSOR, /* Sent to widget to position the cursor */
- WIDGET_IDLE, /* Send to widgets with options & W_WANT_IDLE*/
+ WIDGET_IDLE, /* Sent to widgets with options & W_WANT_IDLE*/
+ WIDGET_RESIZED, /* Sent after a widget has been resized */
} widget_msg_t;
typedef enum {
Index: src/layout.c
===================================================================
RCS file: /cvsroot/mc/mc/src/layout.c,v
retrieving revision 1.85
diff -u -p -u -r1.85 layout.c
--- src/layout.c 19 Sep 2004 15:55:59 -0000 1.85
+++ src/layout.c 20 Jan 2005 17:07:12 -0000
@@ -633,10 +633,6 @@ panel_do_cols (int index)
set_panel_formats ((WPanel *) panels [index].widget);
else {
panel_update_cols (panels [index].widget, frame_half);
-
- /* In case of an Hex Quick View must review line length */
- if (get_display_type (index) == view_quick)
- view_update_bytes_per_line ((WView *) panels [index].widget);
}
}
Index: src/view.c
===================================================================
RCS file: /cvsroot/mc/mc/src/view.c,v
retrieving revision 1.168
diff -u -p -u -r1.168 view.c
--- src/view.c 3 Dec 2004 19:19:19 -0000 1.168
+++ src/view.c 20 Jan 2005 17:07:15 -0000
@@ -753,7 +753,7 @@ do_view_init (WView *view, const char *_
return 0;
}
-void
+static void
view_update_bytes_per_line (WView *view)
{
int cols;
@@ -2734,6 +2734,8 @@ view_callback (WView *view, widget_msg_t
cb_ret_t i;
Dlg_head *h = view->widget.parent;
+ view_update_bytes_per_line (view);
+
switch (msg) {
case WIDGET_INIT:
view_update_bytes_per_line (view);
@@ -2781,6 +2783,10 @@ view_callback (WView *view, widget_msg_t
delete_hook (&select_file_hook, view_hook);
return MSG_HANDLED;
+ case WIDGET_RESIZED:
+ view_update_bytes_per_line (view);
+ /* FALLTROUGH */
+
default:
return default_proc (msg, parm);
}
Index: src/view.h
===================================================================
RCS file: /cvsroot/mc/mc/src/view.h,v
retrieving revision 1.27
diff -u -p -u -r1.27 view.h
--- src/view.h 3 Dec 2004 19:17:47 -0000 1.27
+++ src/view.h 20 Jan 2005 17:07:15 -0000
@@ -9,8 +9,6 @@ WView *view_new (int y, int x, int cols,
int view_init (WView *view, const char *_command, const char *_file,
int start_line);
-void view_update_bytes_per_line (WView *view);
-
/* Command: view a _file, if _command != NULL we use popen on _command */
/* move direction should be a pointer that will hold the direction in which */
/* the user wants to move (-1 previous file, 1 next file, 0 do nothing) */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]