From: Jasper St. Pierre Date: Wed, 29 Oct 2014 23:49:42 +0000 (-0700) Subject: Remove the old log viewer tool X-Git-Tag: 0.9.2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=884818222cd64ba7c1f53efcedc5ecbba8b833a2;p=thirdparty%2Fplymouth.git Remove the old log viewer tool --- diff --git a/configure.ac b/configure.ac index d5957d71..d6e0f6a1 100644 --- a/configure.ac +++ b/configure.ac @@ -60,7 +60,7 @@ if test x$enable_pango = xyes; then AC_SUBST(PANGO_LIBS) fi -AC_ARG_ENABLE(gtk, AS_HELP_STRING([--enable-gtk],[enable building with gtk, disabled there is no log viewer or x11 redenderer]),enable_gtk=$enableval,enable_gtk=yes) +AC_ARG_ENABLE(gtk, AS_HELP_STRING([--enable-gtk],[enable building with gtk, disabled there is no x11 renderer]),enable_gtk=$enableval,enable_gtk=yes) AM_CONDITIONAL(ENABLE_GTK, [test "$enable_gtk" = yes]) if test x$enable_gtk = xyes; then @@ -149,19 +149,6 @@ AS_AC_EXPAND(PLYMOUTH_RUNTIME_DIR, $plymouthruntimedir) AC_ARG_WITH(rhgb-compat-link, AS_HELP_STRING([--with-rhgb-compat-link],[Install /usr/bin/rhgb-client compatability symlink]),with_rhgb_compat_link=${withval},with_rhgb_compat_link=no) AM_CONDITIONAL(WITH_RHGB_COMPAT_LINK, [test "$with_rhgb_compat_link" = yes]) -AC_ARG_WITH(log-viewer, AS_HELP_STRING([--with-log-viewer],[Install plymouth log viewer]),with_log_viewer=${withval},with_log_viewer=no) -AM_CONDITIONAL(WITH_LOG_VIEWER, [test "$with_log_viewer" = yes]) - -if test x$with_log_viewer = xyes; then - if test x$enable_gtk = xno; then - AC_MSG_ERROR([log viewer enabled bug gtk disabled]) - fi - AC_ARG_WITH(gdm-autostart-file, AS_HELP_STRING([--with-gdm-autostart-file],[start log viewer from gdm on boot errors]),with_gdm_autostart_file=$withval,with_gdm_autostart_file=yes) -else - with_gdm_autostart_file=no -fi -AM_CONDITIONAL(START_FROM_GDM, [test "$with_gdm_autostart_file" = yes]) - AC_ARG_WITH(logo, AS_HELP_STRING([--with-logo],[logo used by boot splash plugins]),logofile=${withval},logofile=$datadir/plymouth/bizcom.png) AC_SUBST(logofile) AS_AC_EXPAND(PLYMOUTH_LOGO_FILE, $logofile) @@ -306,7 +293,6 @@ AC_CONFIG_FILES([Makefile src/Makefile src/client/ply-boot-client.pc src/client/Makefile - src/viewer/Makefile src/upstart-bridge/Makefile themes/Makefile themes/spinfinity/Makefile diff --git a/docs/development.txt b/docs/development.txt index 57a819f5..407687e2 100644 --- a/docs/development.txt +++ b/docs/development.txt @@ -251,8 +251,7 @@ dlopen(3). │ ├── text │ ├── throbgress │ └── two-step - ├── upstart-bridge # code for interfacing with the upstart init system - └── viewer # small gtk boot.log viewer application + └── upstart-bridge # code for interfacing with the upstart init system ./themes # example themes that use the various splash plugins diff --git a/src/Makefile.am b/src/Makefile.am index fc2f5da1..ceb72ba1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = libply libply-splash-core libply-splash-graphics . plugins client viewer +SUBDIRS = libply libply-splash-core libply-splash-graphics . plugins client if ENABLE_UPSTART_MONITORING SUBDIRS += upstart-bridge endif diff --git a/src/viewer/Makefile.am b/src/viewer/Makefile.am deleted file mode 100644 index 0c5c3ec1..00000000 --- a/src/viewer/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -SUBDIRS = . -EXTRA_DIST= - -AM_CPPFLAGS = -I$(top_srcdir) \ - -I$(srcdir) -if WITH_LOG_VIEWER -plymouth_log_viewerdir = $(bindir) -plymouth_log_viewer_PROGRAMS = plymouth-log-viewer - -plymouth_log_viewer_CFLAGS = $(GTK_CFLAGS) -DPLYMOUTH_LOG_DIRECTORY=\"$(localstatedir)/log\" -plymouth_log_viewer_LDADD = $(GTK_LIBS) -plymouth_log_viewer_SOURCES = $(srcdir)/plymouth-log-viewer.c - -if START_FROM_GDM -gdmautostartdir = $(datadir)/gdm/autostart/LoginWindow -gdmautostart_DATA = plymouth-log-viewer.desktop -endif -endif - -EXTRA_DIST += plymouth-log-viewer.desktop - -MAINTAINERCLEANFILES = Makefile.in diff --git a/src/viewer/plymouth-log-viewer.c b/src/viewer/plymouth-log-viewer.c deleted file mode 100644 index ea407749..00000000 --- a/src/viewer/plymouth-log-viewer.c +++ /dev/null @@ -1,334 +0,0 @@ -/* - * plymout-log-viewer.c - Display boot messages - * - * Copyright (C) 2008 Red Hat, Inc. - * - * Author: Matthias Clasen - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#ifndef GETTEXT_PACKAGE -#define GETTEXT_PACKAGE "bootmessages" -#endif - -#ifndef DEFAULT_LOG -#define DEFAULT_LOG "/var/log/boot.log" -#endif - -#ifndef DEFAULT_SPOOL_FILE -#define DEFAULT_SPOOL_FILE "/var/spool/plymouth/boot.log" -#endif - -static gboolean show_icon = FALSE; -static gboolean force = FALSE; - -static GOptionEntry entries[] = -{ - { "icon", 0, 0, G_OPTION_ARG_NONE, &show_icon, N_ ("Show a status icon if there are errors"), NULL }, - { "force", 0, 0, G_OPTION_ARG_NONE, &force, N_ ("Show the icon even without errors"), NULL }, - { NULL } -}; - -static void -popup_menu (GtkStatusIcon *icon, - guint button, - guint activate_time, - gpointer user_data) -{ - GtkWidget *menu = user_data; - - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, - gtk_status_icon_position_menu, icon, - button, activate_time); -} - -static void -activate_icon (GtkStatusIcon *icon, - gpointer user_data) -{ - GtkWidget *window = user_data; - - gtk_window_present (GTK_WINDOW (window)); -} - -static gboolean -check_for_errors (const char *file) -{ - struct stat log_info, spool_file_info; - - if (stat (file, &log_info) < 0) - return FALSE; - - if (stat (DEFAULT_SPOOL_FILE, &spool_file_info) < 0) - return FALSE; - - return spool_file_info.st_dev == log_info.st_dev && - spool_file_info.st_ino == log_info.st_ino; -} - -static GtkTextBuffer * -read_boot_log (const char *file, - int *seen_errors, - GError **error) -{ - char *content; - char *content_utf8; - gsize length; - char *p, *q; - GtkTextBuffer *buffer; - GtkTextIter iter; - GString *partial; - - if (!g_file_get_contents (file, &content, &length, error)) - return NULL; - - content_utf8 = g_locale_to_utf8 (content, length, NULL, NULL, NULL); - if (content_utf8) { - g_free (content); - content = content_utf8; - } - - if (check_for_errors (file)) - *seen_errors = 2; - else - *seen_errors = 0; - - buffer = gtk_text_buffer_new (NULL); - gtk_text_buffer_create_tag (buffer, "blue", "foreground", "blue", NULL); - gtk_text_buffer_create_tag (buffer, "green", "foreground", "green", NULL); - gtk_text_buffer_create_tag (buffer, "red", "foreground", "red", NULL); - gtk_text_buffer_create_tag (buffer, "yellow", "foreground", "yellow", NULL); - - partial = g_string_new (""); - - p = content; - while (*p) { - switch (*p) { - case '\r': - /* keep isolated \r */ - if (p[1] != '\r' && p[-1] != '\r' && - p[1] != '\n' && p[-1] != '\n') { - gtk_text_buffer_get_end_iter (buffer, &iter); - gtk_text_buffer_insert (buffer, &iter, p, 1); - } - p++; - break; - case '\t': - gtk_text_buffer_get_end_iter (buffer, &iter); - gtk_text_buffer_insert (buffer, &iter, " ", 8); - p++; - break; - case '\033': - if (strncmp (p, "\033[0;34m", 7) == 0 && (q = strstr (p, "\033[0;39m"))) { - p += 7; - gtk_text_buffer_get_end_iter (buffer, &iter); - gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, p, q - p, "blue", NULL); - p = q + 7; - } else if (strncmp (p, "\033[60G", 5) == 0) { - gtk_text_buffer_get_end_iter (buffer, &iter); - gtk_text_buffer_insert (buffer, &iter, "\t", 1); - p += 5; - } else if (strncmp (p, "\033[0;31m", 7) == 0 && (q = strstr (p, "\033[0;39m"))) { - p += 7; - gtk_text_buffer_get_end_iter (buffer, &iter); - gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, p, q - p, "red", NULL); - p = q + 7; - } else if (strncmp (p, "\033[0;32m", 7) == 0 && (q = strstr (p, "\033[0;39m"))) { - p += 7; - gtk_text_buffer_get_end_iter (buffer, &iter); - gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, p, q - p, "green", NULL); - p = q + 7; - } else if (strncmp (p, "\033[0;33m", 7) == 0 && (q = strstr (p, "\033[0;39m"))) { - p += 7; - gtk_text_buffer_get_end_iter (buffer, &iter); - gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, p, q - p, "yellow", NULL); - p = q + 7; - } else if (strncmp (p, "\033%G", 3) == 0) { - p += 3; - } else { - p++; - } - break; - default: - /* GtkTextBuffer doesn't let us insert partial utf-8 characters */ - g_string_append_c (partial, *p); - if (g_utf8_get_char_validated (partial->str, partial->len) != (gunichar) - 2) { - gtk_text_buffer_get_end_iter (buffer, &iter); - gtk_text_buffer_insert (buffer, &iter, partial->str, partial->len); - g_string_truncate (partial, 0); - } - p++; - break; - } - } - - g_string_free (partial, TRUE); - g_free (content); - - return buffer; -} - -static void -close_window (GtkWidget *window) -{ - if (show_icon) - gtk_widget_hide (window); - else - gtk_main_quit (); -} - -static GtkWidget * -create_window (GtkTextBuffer *buffer) -{ - GtkWidget *window; - GtkWidget *scrolledwin; - GtkWidget *box; - GtkWidget *terminal; - GtkWidget *bbox; - GtkWidget *close_button; - PangoFontDescription *description; - PangoTabArray *tabs; - int width, height; - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER); - gtk_window_set_title (GTK_WINDOW (window), _ ("Boot messages")); - gtk_container_set_border_width (GTK_CONTAINER (window), 12); - - width = MIN (800, 0.75 * gdk_screen_get_width (gdk_screen_get_default ())); - height = MIN (600, 0.75 * gdk_screen_get_height (gdk_screen_get_default ())); - gtk_window_set_default_size (GTK_WINDOW (window), width, height); - - box = gtk_vbox_new (FALSE, 0); - scrolledwin = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwin), - GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwin), - GTK_SHADOW_IN); - terminal = gtk_text_view_new_with_buffer (buffer); - gtk_text_view_set_editable (GTK_TEXT_VIEW (terminal), FALSE); - - description = pango_font_description_from_string ("monospace"); - gtk_widget_modify_font (terminal, description); - pango_font_description_free (description); - - tabs = pango_tab_array_new_with_positions (1, TRUE, PANGO_TAB_LEFT, width - 130); - gtk_text_view_set_tabs (GTK_TEXT_VIEW (terminal), tabs); - gtk_text_view_set_left_margin (GTK_TEXT_VIEW (terminal), 12); - gtk_text_view_set_right_margin (GTK_TEXT_VIEW (terminal), 12); - - bbox = gtk_hbutton_box_new (); - gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_END); - close_button = gtk_button_new_from_stock (GTK_STOCK_CLOSE); - - gtk_container_add (GTK_CONTAINER (window), box); - gtk_box_pack_start (GTK_BOX (box), scrolledwin, TRUE, TRUE, 6); - gtk_container_add (GTK_CONTAINER (scrolledwin), terminal); - gtk_box_pack_start (GTK_BOX (box), bbox, FALSE, TRUE, 6); - gtk_box_pack_start (GTK_BOX (bbox), close_button, FALSE, TRUE, 6); - - g_signal_connect (window, "delete-event", - G_CALLBACK (close_window), NULL); - g_signal_connect_swapped (close_button, "clicked", - G_CALLBACK (close_window), window); - - gtk_widget_show_all (box); - - return window; -} - -int -main (int argc, char *argv[]) -{ - GtkStatusIcon *icon; - GtkWidget *menu; - GtkWidget *quit_item; - GtkWidget *window; - GtkTextBuffer *buffer; - GError *error = NULL; - int seen_errors; - gchar *file; - - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); - - if (!gtk_init_with_args (&argc, &argv, - _ ("[FILE]"), entries, GETTEXT_PACKAGE, &error)) { - g_print ("%s\n", error ? error->message : "Beep"); - exit (1); - } - - if (argc > 1) - file = argv[1]; - else - file = DEFAULT_LOG; - - buffer = read_boot_log (file, &seen_errors, &error); - if (buffer == NULL) { - g_print ("%s\n", error ? error->message : "Blop"); - exit (1); - } - - window = create_window (buffer); - - if (seen_errors == 2) - gtk_window_set_icon_name (GTK_WINDOW (window), GTK_STOCK_DIALOG_WARNING); - else - gtk_window_set_icon_name (GTK_WINDOW (window), GTK_STOCK_INFO); - - if (show_icon) { - menu = gtk_menu_new (); - quit_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL); - gtk_menu_append (GTK_MENU (menu), quit_item); - gtk_widget_show_all (menu); - g_signal_connect (quit_item, "activate", G_CALLBACK (gtk_main_quit), NULL); - - icon = gtk_status_icon_new (); - if (seen_errors == 2) - gtk_status_icon_set_from_stock (icon, GTK_STOCK_DIALOG_WARNING); - else if (seen_errors == 1 || force) - gtk_status_icon_set_from_stock (icon, GTK_STOCK_INFO); - else - exit (0); - - gtk_status_icon_set_tooltip (icon, _ ("Console output from services during system startup")); - gtk_status_icon_set_title (icon, _ ("Boot messages")); - - g_signal_connect (icon, "activate", G_CALLBACK (activate_icon), window); - g_signal_connect (icon, "popup-menu", G_CALLBACK (popup_menu), menu); - } else { - gtk_window_present (GTK_WINDOW (window)); - } - - gtk_main (); - - return 0; -} diff --git a/src/viewer/plymouth-log-viewer.desktop b/src/viewer/plymouth-log-viewer.desktop deleted file mode 100644 index d157d19e..00000000 --- a/src/viewer/plymouth-log-viewer.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Name=Boot messages -Comment=Boot messages -Exec=plymouth-log-viewer --icon -Terminal=false -Type=Application -Categories= -OnlyShowIn=GNOME;XFCE;