Pull the search UI construction code out into a distinct function.
[geeqie.git] / src / ui_help.c
index ad9cd9b..296f698 100644 (file)
@@ -1,13 +1,22 @@
 /*
- * (SLIK) SimpLIstic sKin functions
- * (C) 2004 John Ellis
- * Copyright (C) 2008 The Geeqie Team
+ * Copyright (C) 2004 John Ellis
+ * Copyright (C) 2008 - 2016 The Geeqie Team
  *
  * Author: John Ellis
  *
- * This software is released under the GNU General Public License (GNU GPL).
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at your own risk!
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #ifdef HAVE_CONFIG_H
 
 #include "ui_fileops.h"
 #include "ui_misc.h"
+#include "window.h"
 
 
-#define HELP_WINDOW_WIDTH 620
+#define HELP_WINDOW_WIDTH 650
 #define HELP_WINDOW_HEIGHT 350
 
 
@@ -64,10 +74,6 @@ static void help_window_scroll(GtkWidget *text, const gchar *key)
                gtk_text_buffer_get_iter_at_line_offset(buffer, &iter, line, 0);
                gtk_text_buffer_place_cursor(buffer, &iter);
 
-#if 0
-               gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(text), &iter, 0.0, TRUE, 0, 0);
-#endif
-
                /* apparently only scroll_to_mark works when the textview is not visible yet */
 
                /* if mark exists, move it instead of creating one for every scroll */
@@ -125,7 +131,7 @@ static void help_window_load_text(GtkWidget *text, const gchar *path)
 
                        if (!g_utf8_validate(s_buf, l, NULL))
                                {
-                               buf = g_locale_to_utf8(s_buf, strlen(s_buf), NULL, NULL, NULL);
+                               buf = g_locale_to_utf8(s_buf, l, NULL, NULL, NULL);
                                if (!buf) buf = g_strdup("\n");
                                }
                        else
@@ -145,7 +151,7 @@ static void help_window_load_text(GtkWidget *text, const gchar *path)
        gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(text), &iter, 0.0, TRUE, 0, 0);
 }
 
-static gint help_window_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer data)
+static gboolean help_window_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer data)
 {
        gtk_widget_destroy(widget);
        return TRUE;
@@ -166,7 +172,7 @@ void help_window_set_key(GtkWidget *window, const gchar *key)
        text = g_object_get_data(G_OBJECT(window), "text_widget");
        if (!text) return;
 
-       gdk_window_raise(window->window);
+       gdk_window_raise(gtk_widget_get_window(window));
 
        if (key) help_window_scroll(text, key);
 }
@@ -180,14 +186,14 @@ void help_window_set_file(GtkWidget *window, const gchar *path, const gchar *key
        text = g_object_get_data(G_OBJECT(window), "text_widget");
        if (!text) return;
 
-       gdk_window_raise(window->window);
+       gdk_window_raise(gtk_widget_get_window(window));
 
        help_window_load_text(text, path);
        help_window_scroll(text, key);
 }
 
 GtkWidget *help_window_new(const gchar *title,
-                          const gchar *wmclass, const gchar *subclass,
+                          const gchar *subclass,
                           const gchar *path, const gchar *key)
 {
        GtkWidget *window;
@@ -202,9 +208,6 @@ GtkWidget *help_window_new(const gchar *title,
 
        window = window_new(GTK_WINDOW_TOPLEVEL, subclass, NULL, NULL, title);
        gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
-#if 0
-       gtk_container_set_border_width(GTK_CONTAINER(window), PREF_PAD_BORDER);
-#endif
        gtk_window_set_default_size(GTK_WINDOW(window), HELP_WINDOW_WIDTH, HELP_WINDOW_HEIGHT);
 
        g_signal_connect(G_OBJECT(window), "delete_event",
@@ -245,10 +248,10 @@ GtkWidget *help_window_new(const gchar *title,
        gtk_widget_show(hbox);
 
        button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
-       g_signal_connect(G_OBJECT (button), "clicked",
+       g_signal_connect(G_OBJECT(button), "clicked",
                         G_CALLBACK(help_window_close), window);
        gtk_container_add(GTK_CONTAINER(hbox), button);
-       GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+       gtk_widget_set_can_default(button, TRUE);
        gtk_widget_grab_default(button);
        gtk_widget_show(button);
 
@@ -267,3 +270,4 @@ GtkWidget *help_window_get_box(GtkWidget *window)
 {
        return g_object_get_data(G_OBJECT(window), "text_vbox");
 }
+/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */