From c1fb49b68933b8de89950064d989d8a87628046e Mon Sep 17 00:00:00 2001 From: Norbert Warmuth Date: Tue, 22 Jun 1999 10:29:29 +0000 Subject: [PATCH] David's "Hex View in GMC & some June patches" sent on June 14 (don't blame David for the ChangeLog entries). 1999-06-22 David Martin * gnome/gnome-file-property-dialog.c (switch_metadata_box): Tag some strings for localization. * gnome/gnome-open-dialog.c (gnome_open_dialog_new): Don't assemble label_string from seperate strings (makes it easier to translate). * src/view.c (display): added view_gotoxy's in order to make hex mode work in the gnome edition. * gtkedit/gtkedit.c (tb_items): Mark strings for localization. 1999-06-22 Norbert Warmuth * gnome/gview.c (viewer_size_changed): Update internal viewer state used in hex mode. And some fixes to the bug reported on mc-bugs ("Two Big Bugs in Quickview@mc"). 1999-06-22 Norbert Warmuth * src/cmd.c (quick_view_cmd): Change panel when the file we want to view isn't in the current panel (prevents a "file not found" error). * src/menu.c (menubar_execute): De-activate the menubar previous to invoking the callback. This is needed to make change_panel in quick_view_cmd work (the activated menubar doesn't allow unfocus, i.e. dlg_one_down|up don't change anything). * src/view.c (do_view_init): improved error handling w.r.t quick view (mc used to dump core when the file to view couldn't be opened). --- ChangeLog | 4 ++++ gnome/ChangeLog | 13 ++++++++++++ gnome/gnome-file-property-dialog.c | 4 ++-- gnome/gnome-open-dialog.c | 4 ++-- gnome/gview.c | 1 + gtkedit/gtkedit.c | 24 ++++++++++----------- src/ChangeLog | 19 +++++++++++++++++ src/cmd.c | 2 ++ src/menu.c | 8 ++++++- src/view.c | 34 +++++++++++++++++++++--------- 10 files changed, 86 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 578c30572..bb6219743 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +1999-06-22 David Martin + + * gtkedit/gtkedit.c (tb_items): Mark strings for localization. + 1999-06-07 Shooby Ban * po/hu.po, configure.in: added hungarian translations... diff --git a/gnome/ChangeLog b/gnome/ChangeLog index 602b5fee0..bd624479e 100644 --- a/gnome/ChangeLog +++ b/gnome/ChangeLog @@ -1,3 +1,16 @@ +1999-06-22 David Martin + + * gnome-file-property-dialog.c (switch_metadata_box): Tag some + strings for localization. + + * gnome-open-dialog.c (gnome_open_dialog_new): Don't assemble + label_string from seperate strings (makes it easier to translate). + +1999-06-22 Norbert Warmuth + + * gview.c (viewer_size_changed): Update internal viewer state used + in hex mode. + 1999-06-17 Federico Mena Quintero * gdesktop.c (set_icon_wmclass): New function to set the wmclass diff --git a/gnome/gnome-file-property-dialog.c b/gnome/gnome-file-property-dialog.c index b5688a36a..78a114cc6 100644 --- a/gnome/gnome-file-property-dialog.c +++ b/gnome/gnome-file-property-dialog.c @@ -384,8 +384,8 @@ switch_metadata_box (GnomeFilePropertyDialog *fp_dlg) } if (fp_dlg->executable) { - gtk_label_set_text (GTK_LABEL (fp_dlg->prop1_label), "Drop Action"); - gtk_label_set_text (GTK_LABEL (GTK_BIN (fp_dlg->prop1_cbox)->child), "Use default Drop Action options"); + gtk_label_set_text (GTK_LABEL (fp_dlg->prop1_label), _("Drop Action")); + gtk_label_set_text (GTK_LABEL (GTK_BIN (fp_dlg->prop1_cbox)->child), _("Use default Drop Action options")); if (fp_dlg->drop_target) { gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (fp_dlg->prop1_cbox), FALSE); gtk_entry_set_text (GTK_ENTRY (fp_dlg->prop1_entry), fp_dlg->drop_target); diff --git a/gnome/gnome-open-dialog.c b/gnome/gnome-open-dialog.c index b02472e4c..346ce6ca9 100644 --- a/gnome/gnome-open-dialog.c +++ b/gnome/gnome-open-dialog.c @@ -380,8 +380,8 @@ gnome_open_dialog_new (gchar *file_name) dialog = gtk_type_new (gnome_open_dialog_get_type ()); /* the first label */ - label_string = g_strconcat (_("Select an application to open \""), - file_name, "\" with.", NULL); + label_string = g_strdup_printf ( + _("Select an application to open \"%s\" with."),file_name); label = gtk_label_new (label_string); gtk_widget_set_usize (label, 300, -1); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); diff --git a/gnome/gview.c b/gnome/gview.c index 5b2cff79e..16a64581e 100644 --- a/gnome/gview.c +++ b/gnome/gview.c @@ -36,6 +36,7 @@ static void viewer_size_changed (GtkWidget *widget, guint cols, guint lines, WView *view) { widget_set_size (&view->widget, 0, 0, lines, cols); + view_update_bytes_per_line (view); dlg_redraw (view->widget.parent); } diff --git a/gtkedit/gtkedit.c b/gtkedit/gtkedit.c index a81a09179..ec3f81d45 100644 --- a/gtkedit/gtkedit.c +++ b/gtkedit/gtkedit.c @@ -1243,17 +1243,17 @@ struct _TbItems { static TbItems tb_items[] = { - {"F1", "Help", "Interactive help browser", GNOME_STOCK_MENU_BLANK, 0, NULL}, - {"F2", "Save", "Save to current file name", GNOME_STOCK_MENU_SAVE, gtk_edit_save_file, NULL}, - {"F3", "Mark", "Toggle In/Off invisible marker to highlight text", GNOME_STOCK_MENU_BLANK, gtk_edit_toggle_mark, NULL}, - {"F4", "Replc", "Find and replace strings/regular expressions", GNOME_STOCK_MENU_SRCHRPL, gtk_edit_replace, NULL}, - {"F5", "Copy", "Copy highlighted block to cursor postition", GNOME_STOCK_MENU_COPY, gtk_edit_copy, NULL}, + {"F1", N_("Help"), N_("Interactive help browser"), GNOME_STOCK_MENU_BLANK, 0, NULL}, + {"F2", N_("Save"), N_("Save to current file name"), GNOME_STOCK_MENU_SAVE, gtk_edit_save_file, NULL}, + {"F3", N_("Mark"), N_("Toggle In/Off invisible marker to highlight text"), GNOME_STOCK_MENU_BLANK, gtk_edit_toggle_mark, NULL}, + {"F4", N_("Replc"), N_("Find and replace strings/regular expressions"), GNOME_STOCK_MENU_SRCHRPL, gtk_edit_replace, NULL}, + {"F5", N_("Copy"), N_("Copy highlighted block to cursor position"), GNOME_STOCK_MENU_COPY, gtk_edit_copy, NULL}, - {"F6", "Move", "Copy highlighted block to cursor postition", GNOME_STOCK_MENU_BLANK, gtk_edit_move, NULL}, - {"F7", "Find", "Find strings/regular expressions", GNOME_STOCK_MENU_SEARCH, gtk_edit_search, NULL}, - {"F8", "Dlete", "Delete highlighted text", GNOME_STOCK_MENU_BLANK, gtk_edit_delete, NULL}, - {"F9", "Menu", "Pull down menu", GNOME_STOCK_MENU_BLANK, /* gtk_edit_menu*/ 0, NULL}, - {"F10", "Quit", "Exit editor", GNOME_STOCK_MENU_QUIT, gtk_edit_quit, NULL}, + {"F6", N_("Move"), N_("Move highlighted block to cursor position"), GNOME_STOCK_MENU_BLANK, gtk_edit_move, NULL}, + {"F7", N_("Find"), N_("Find strings/regular expressions"), GNOME_STOCK_MENU_SEARCH, gtk_edit_search, NULL}, + {"F8", N_("Dlete"), N_("Delete highlighted text"), GNOME_STOCK_MENU_BLANK, gtk_edit_delete, NULL}, + {"F9", N_("Menu"), N_("Pull down menu"), GNOME_STOCK_MENU_BLANK, /* gtk_edit_menu*/ 0, NULL}, + {"F10", N_("Quit"), N_("Exit editor"), GNOME_STOCK_MENU_QUIT, gtk_edit_quit, NULL}, {0, 0, 0, 0, 0, 0} }; @@ -1264,8 +1264,8 @@ static GtkWidget *create_toolbar (GtkWidget * window, GtkEdit * edit) toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH); for (t = &tb_items[0]; t->text; t++) { t->widget = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), - t->text, - t->tooltip, + _(t->text), + _(t->tooltip), 0, gnome_stock_pixmap_widget (window, t->icon), t->cb, diff --git a/src/ChangeLog b/src/ChangeLog index 43f8a4f9b..c96112c16 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,22 @@ +1999-06-22 Norbert Warmuth + + * cmd.c (quick_view_cmd): Change panel when the file we want to + view isn't in the current panel (prevents a "file not found" + error). + + * menu.c (menubar_execute): De-activate the menubar previous to + invoking the callback. This is needed to make change_panel in + quick_view_cmd work (the activated menubar doesn't allow unfocus, + i.e. dlg_one_down|up don't change anything). + + * view.c (do_view_init): improved error handling w.r.t quick view + (mc used to dump core when the file to view couldn't be opened). + +1999-06-22 David Martin + + * view.c (display): added view_gotoxy's in order to make the gnome + edition operational in hex mode. + Fri Jun 18 11:29:56 1999 Norbert Warmuth * user.c (user_menu_cmd): Allow national characters as hotkeys. diff --git a/src/cmd.c b/src/cmd.c index 09247810b..ad2fe2681 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1495,6 +1495,8 @@ info_cmd (void) void quick_view_cmd (void) { + if (get_panel_widget (MENU_PANEL_IDX) == cpanel) + change_panel (); set_display_type (MENU_PANEL_IDX, view_quick); } #endif diff --git a/src/menu.c b/src/menu.c index 70aafc2ab..206b78516 100644 --- a/src/menu.c +++ b/src/menu.c @@ -229,10 +229,16 @@ static void menubar_drop (WMenu *menubar, int selected) static void menubar_execute (WMenu *menubar, int entry) { const Menu menu = menubar->menu [menubar->selected]; + const callfn call_back = menu->entries [entry].call_back; is_right = menubar->selected != 0; - (*menu->entries [entry].call_back)(0); + + /* This used to be the other way round, i.e. first callback and + then menubar_finish. The new order (hack?) is needed to make + change_panel () work which is used in quick_view_cmd () -- Norbert + */ menubar_finish (menubar); + (*call_back)(0); } static void menubar_move (WMenu *menubar, int step) diff --git a/src/view.c b/src/view.c index de6da075d..45fdf888d 100644 --- a/src/view.c +++ b/src/view.c @@ -564,15 +564,23 @@ do_view_init (WView *view, char *_command, char *_file, int start_line) int fd; if ((fd = mc_open(_file, O_RDONLY)) == -1) { - message (1, MSG_ERROR, _(" Can't open \"%s\"\n %s "), + char tmp[BUF_MEDIUM]; + g_snprintf (tmp, sizeof (tmp), + _(" Can't open \"%s\"\n %s "), _file, unix_error_string (errno)); - return -1; + view->filename = g_strdup (_file); + error = set_view_init_error (view, tmp); + goto finish; } if (mc_fstat (fd, &view->s) == -1) { - message (1, MSG_ERROR, _(" Can't open \"%s\"\n %s "), + char tmp[BUF_MEDIUM]; + g_snprintf (tmp, sizeof (tmp), + _(" Can't stat \"%s\"\n %s "), _file, unix_error_string (errno)); mc_close(fd); - return -1; + view->filename = g_strdup (_file); + error = set_view_init_error (view, tmp); + goto finish; } if (_file[0] && view->viewer_magic_flag && (is_gunzipable (fd, &type)) != 0) @@ -587,6 +595,7 @@ do_view_init (WView *view, char *_command, char *_file, int start_line) else error = load_view_file (view, view->filename); +finish: if (error){ if (!view->have_frame){ message (1, MSG_ERROR, error); @@ -608,6 +617,7 @@ do_view_init (WView *view, char *_command, char *_file, int start_line) /* Special case: The data points to the error message */ if (error){ view->data = error; + view->file = -1; view->s.st_size = view->bytes_read = strlen (view->data); } view->last_byte = view->first + view->s.st_size; @@ -863,11 +873,11 @@ display (WView *view) /* Start of text column */ int text_start = width - view->bytes_per_line - 1 + frame_shift; - + for (;row < height && from < view->last_byte; row++){ /* Print the hex offset */ g_snprintf (hex_buff, sizeof (hex_buff), "%05X", (int) (from - view->first)); - widget_move (view, row, frame_shift); + view_gotoyx (view, row, frame_shift); view_add_string (view, hex_buff); /* Hex dump starts from column seven */ @@ -919,18 +929,22 @@ display (WView *view) /* Hex numbers are printed in the groups of four */ /* Groups are separated by a vline */ + view_gotoyx (view, row, col-1); view_add_character (view, ' '); + view_gotoyx (view, row, col); view_add_one_vline (); - view_gotoyx (view, row, col + 1); col += 2; if (boldflag && from==view->search_start+view->found_len-1) view_set_color (view, BOLD_COLOR); } - if (boldflag && from < view->search_start + view->found_len - 1 - && bytes != view->bytes_per_line - 1) - view_add_character (view, ' '); + if (boldflag && + from < view->search_start + view->found_len - 1 && + bytes != view->bytes_per_line - 1) { + view_gotoyx (view, row, col); + view_add_character (view, ' '); + } /* Print the corresponding ascii character */ view_gotoyx (view, row, text_start + bytes);