diff options
Diffstat (limited to 'app/wlib/gtklib/ixhelp.c')
| -rw-r--r-- | app/wlib/gtklib/ixhelp.c | 424 | 
1 files changed, 212 insertions, 212 deletions
| diff --git a/app/wlib/gtklib/ixhelp.c b/app/wlib/gtklib/ixhelp.c index 5079f61..80b579c 100644 --- a/app/wlib/gtklib/ixhelp.c +++ b/app/wlib/gtklib/ixhelp.c @@ -17,7 +17,7 @@   *   *  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 Place - Suite 330, Boston, MA 02111-1307, USA. + *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA   */  #include <stdlib.h> @@ -77,34 +77,34 @@ static GtkWidget *contents_view; /** handle for the help contents pane */  static GtkWidget*  lookup_widget(GtkWidget *widget, const gchar *widget_name)  { -    GtkWidget *parent, *found_widget; +	GtkWidget *parent, *found_widget; -    for (;;) { -        if (GTK_IS_MENU(widget)) { -            parent = gtk_menu_get_attach_widget(GTK_MENU(widget)); -        } else { -            parent = widget->parent; -        } +	for (;;) { +		if (GTK_IS_MENU(widget)) { +			parent = gtk_menu_get_attach_widget(GTK_MENU(widget)); +		} else { +			parent = widget->parent; +		} -        if (!parent) { -            parent = (GtkWidget*) g_object_get_data(G_OBJECT(widget), "GladeParentKey"); -        } +		if (!parent) { +			parent = (GtkWidget*) g_object_get_data(G_OBJECT(widget), "GladeParentKey"); +		} -        if (parent == NULL) { -            break; -        } +		if (parent == NULL) { +			break; +		} -        widget = parent; -    } +		widget = parent; +	} -    found_widget = (GtkWidget*) g_object_get_data(G_OBJECT(widget), -                   widget_name); +	found_widget = (GtkWidget*) g_object_get_data(G_OBJECT(widget), +	                widget_name); -    if (!found_widget) { -        g_warning("Widget not found: %s", widget_name); -    } +	if (!found_widget) { +		g_warning("Widget not found: %s", widget_name); +	} -    return found_widget; +	return found_widget;  } @@ -124,21 +124,21 @@ lookup_widget(GtkWidget *widget, const gchar *widget_name)  GtkWidget *  CreateHPaned(GtkBox *container, char *property)  { -    GtkWidget *hpaned; -    long posSlider; +	GtkWidget *hpaned; +	long posSlider; -    /* the horizontal slider */ -    hpaned = gtk_hpaned_new(); -    gtk_container_set_border_width(GTK_CONTAINER(hpaned), 6); +	/* the horizontal slider */ +	hpaned = gtk_hpaned_new(); +	gtk_container_set_border_width(GTK_CONTAINER(hpaned), 6); -    wPrefGetInteger(HTMLHELPSECTION, SLIDERPREFNAME, &posSlider, SLIDERPOSDEFAULT); -    gtk_paned_set_position(GTK_PANED(hpaned), (int)posSlider); +	wPrefGetInteger(HTMLHELPSECTION, SLIDERPREFNAME, &posSlider, SLIDERPOSDEFAULT); +	gtk_paned_set_position(GTK_PANED(hpaned), (int)posSlider); -    /* pack the horizontal slider into the main window */ -    gtk_box_pack_start(container, hpaned, TRUE, TRUE, 0); -    gtk_widget_show(hpaned); +	/* pack the horizontal slider into the main window */ +	gtk_box_pack_start(container, hpaned, TRUE, TRUE, 0); +	gtk_widget_show(hpaned); -    return (hpaned); +	return (hpaned);  }  /** @@ -155,69 +155,69 @@ CreateHPaned(GtkBox *container, char *property)  static gboolean  DestroyHelpWindow(GtkWidget *win, GdkEvent *event, void *ptr)  { -    int i; -    GtkWidget *widget; -    char tmp[ 20 ]; +	int i; +	GtkWidget *widget; +	char tmp[ 20 ]; -    gint x, y; +	gint x, y; -    /* get the slider position and save it */ -    widget = lookup_widget(win, PANED); -    i = gtk_paned_get_position(GTK_PANED(widget)); -    wPrefSetInteger(HTMLHELPSECTION, SLIDERPREFNAME, i); +	/* get the slider position and save it */ +	widget = lookup_widget(win, PANED); +	i = gtk_paned_get_position(GTK_PANED(widget)); +	wPrefSetInteger(HTMLHELPSECTION, SLIDERPREFNAME, i); -    /* get the window position */ -    gtk_window_get_position((GtkWindow *)win, &x, &y); -    sprintf(tmp, "%d %d", x, y); -    wPrefSetString(HTMLHELPSECTION, WINDOWPOSPREFNAME, tmp); +	/* get the window position */ +	gtk_window_get_position((GtkWindow *)win, &x, &y); +	sprintf(tmp, "%d %d", x, y); +	wPrefSetString(HTMLHELPSECTION, WINDOWPOSPREFNAME, tmp); -    /* get the window size */ -    gtk_window_get_size((GtkWindow *)win , &x, &y); -    sprintf(tmp, "%d %d", x, y); -    wPrefSetString(HTMLHELPSECTION, WINDOWSIZEPREFNAME, tmp); +	/* get the window size */ +	gtk_window_get_size((GtkWindow *)win, &x, &y); +	sprintf(tmp, "%d %d", x, y); +	wPrefSetString(HTMLHELPSECTION, WINDOWSIZEPREFNAME, tmp); -    gtk_widget_hide(win); -    return TRUE; +	gtk_widget_hide(win); +	return TRUE;  }  void back_button_clicked(GtkWidget *widget, gpointer data)  { -    webkit_web_view_go_back(WEBKIT_WEB_VIEW(data)); +	webkit_web_view_go_back(WEBKIT_WEB_VIEW(data));  }  void forward_button_clicked(GtkWidget *widget, gpointer data)  { -    webkit_web_view_go_forward(WEBKIT_WEB_VIEW(data)); +	webkit_web_view_go_forward(WEBKIT_WEB_VIEW(data));  }  void home_button_clicked(GtkWidget *widget, gpointer data)  { -    load_into_view("index.html", MAIN_VIEW); +	load_into_view("index.html", MAIN_VIEW);  }  /* Toggles the contents pane */  void contents_button_clicked(GtkWidget *widget, gpointer data)  { -    if (gtk_paned_get_position(GTK_PANED(data)) < 50) { -        gtk_paned_set_position(GTK_PANED(data), 370); -    } else { -        gtk_paned_set_position(GTK_PANED(data), 0); -    } +	if (gtk_paned_get_position(GTK_PANED(data)) < 50) { +		gtk_paned_set_position(GTK_PANED(data), 370); +	} else { +		gtk_paned_set_position(GTK_PANED(data), 0); +	}  }  gboolean contents_click_handler( -    WebKitWebView *web_view, -    WebKitWebFrame *frame, -    WebKitNetworkRequest *request, -    WebKitWebNavigationAction *navigation_action, -    WebKitWebPolicyDecision *policy_decision, -    gpointer data) +        WebKitWebView *web_view, +        WebKitWebFrame *frame, +        WebKitNetworkRequest *request, +        WebKitWebNavigationAction *navigation_action, +        WebKitWebPolicyDecision *policy_decision, +        gpointer data)  { -    webkit_web_view_load_uri(WEBKIT_WEB_VIEW(data), -                             webkit_network_request_get_uri(request)); +	webkit_web_view_load_uri(WEBKIT_WEB_VIEW(data), +	                         webkit_network_request_get_uri(request)); -    return TRUE; +	return TRUE;  }  /** @@ -225,45 +225,45 @@ gboolean contents_click_handler(   */  void initialize_buttons(GtkWidget *main_vbox, GtkWidget *content_hpane)  { -    GtkWidget *buttons_hbuttonbox; -    GtkWidget *back_button; -    GtkWidget *forward_button; -    GtkWidget *home_button; -    GtkWidget *contents_button; - -    // define and attach signals to buttons -    back_button = gtk_button_new_with_label(_("Back")); -    g_signal_connect(back_button, "clicked", G_CALLBACK(back_button_clicked), -                     G_OBJECT(main_view)); - -    forward_button = gtk_button_new_with_label(_("Forward")); -    g_signal_connect(forward_button, "clicked", G_CALLBACK(forward_button_clicked), -                     G_OBJECT(main_view)); - -    home_button = gtk_button_new_with_label(_("Home")); -    g_signal_connect(home_button, "clicked", G_CALLBACK(home_button_clicked), -                     G_OBJECT(main_view)); - -    contents_button = gtk_button_new_with_label(_("Contents")); -    g_signal_connect(contents_button, "clicked", -                     G_CALLBACK(contents_button_clicked), G_OBJECT(content_hpane)); - -    // button layout -    buttons_hbuttonbox = gtk_hbutton_box_new(); -    gtk_container_add(GTK_CONTAINER(buttons_hbuttonbox), back_button); -    gtk_container_add(GTK_CONTAINER(buttons_hbuttonbox), forward_button); -    gtk_container_add(GTK_CONTAINER(buttons_hbuttonbox), home_button); -    gtk_container_add(GTK_CONTAINER(buttons_hbuttonbox), contents_button); -    gtk_box_pack_start(GTK_BOX(main_vbox), buttons_hbuttonbox, FALSE, TRUE, 0); -    gtk_box_set_spacing(GTK_BOX(buttons_hbuttonbox), 6); -    gtk_button_box_set_layout(GTK_BUTTON_BOX(buttons_hbuttonbox), -                              GTK_BUTTONBOX_START); - -    /* Store pointers to all widgets, for use by lookup_widget().  */ -    GLADE_HOOKUP_OBJECT(main_view, back_button, BACKBUTTON); -    GLADE_HOOKUP_OBJECT(main_view, forward_button, FORWARDBUTTON); -    GLADE_HOOKUP_OBJECT(main_view, home_button, HOMEBUTTON); -    GLADE_HOOKUP_OBJECT(main_view, contents_button, CONTENTBUTTON); +	GtkWidget *buttons_hbuttonbox; +	GtkWidget *back_button; +	GtkWidget *forward_button; +	GtkWidget *home_button; +	GtkWidget *contents_button; + +	// define and attach signals to buttons +	back_button = gtk_button_new_with_label(_("Back")); +	g_signal_connect(back_button, "clicked", G_CALLBACK(back_button_clicked), +	                 G_OBJECT(main_view)); + +	forward_button = gtk_button_new_with_label(_("Forward")); +	g_signal_connect(forward_button, "clicked", G_CALLBACK(forward_button_clicked), +	                 G_OBJECT(main_view)); + +	home_button = gtk_button_new_with_label(_("Home")); +	g_signal_connect(home_button, "clicked", G_CALLBACK(home_button_clicked), +	                 G_OBJECT(main_view)); + +	contents_button = gtk_button_new_with_label(_("Contents")); +	g_signal_connect(contents_button, "clicked", +	                 G_CALLBACK(contents_button_clicked), G_OBJECT(content_hpane)); + +	// button layout +	buttons_hbuttonbox = gtk_hbutton_box_new(); +	gtk_container_add(GTK_CONTAINER(buttons_hbuttonbox), back_button); +	gtk_container_add(GTK_CONTAINER(buttons_hbuttonbox), forward_button); +	gtk_container_add(GTK_CONTAINER(buttons_hbuttonbox), home_button); +	gtk_container_add(GTK_CONTAINER(buttons_hbuttonbox), contents_button); +	gtk_box_pack_start(GTK_BOX(main_vbox), buttons_hbuttonbox, FALSE, TRUE, 0); +	gtk_box_set_spacing(GTK_BOX(buttons_hbuttonbox), 6); +	gtk_button_box_set_layout(GTK_BUTTON_BOX(buttons_hbuttonbox), +	                          GTK_BUTTONBOX_START); + +	/* Store pointers to all widgets, for use by lookup_widget().  */ +	GLADE_HOOKUP_OBJECT(main_view, back_button, BACKBUTTON); +	GLADE_HOOKUP_OBJECT(main_view, forward_button, FORWARDBUTTON); +	GLADE_HOOKUP_OBJECT(main_view, home_button, HOMEBUTTON); +	GLADE_HOOKUP_OBJECT(main_view, contents_button, CONTENTBUTTON);  }  /** @@ -275,123 +275,123 @@ void initialize_buttons(GtkWidget *main_vbox, GtkWidget *content_hpane)  GtkWidget*  CreateHelpWindow(void)  { -    GtkWidget *main_vbox; -    GtkWidget *main_view_scroller; -    GtkWidget *contents_view_scroller; -    GtkWidget *content_hpane; +	GtkWidget *main_vbox; +	GtkWidget *main_view_scroller; +	GtkWidget *contents_view_scroller; +	GtkWidget *content_hpane; -    int width; -    int height; -    int x, y; -    int w = 0, h = 0; -    const char *pref; +	int width; +	int height; +	int x, y; +	int w = 0, h = 0; +	const char *pref; -    wHelpWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); +	wHelpWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); -    width = gdk_screen_get_width(gtk_window_get_screen((GtkWindow *)wHelpWindow)); -    height = gdk_screen_get_height(gtk_window_get_screen((GtkWindow *)wHelpWindow)); +	width = gdk_screen_get_width(gtk_window_get_screen((GtkWindow *)wHelpWindow)); +	height = gdk_screen_get_height(gtk_window_get_screen((GtkWindow *)wHelpWindow)); -    pref = wPrefGetString(HTMLHELPSECTION, WINDOWSIZEPREFNAME); +	pref = wPrefGetString(HTMLHELPSECTION, WINDOWSIZEPREFNAME); -    if (pref) { -        sscanf(pref, "%d %d", &w, &h); +	if (pref) { +		sscanf(pref, "%d %d", &w, &h); -        if (w > width) { -            w = width; -        } +		if (w > width) { +			w = width; +		} -        if (h > height) { -            h = height; -        } -    } else { -        w = (width * 2)/ 5; -        h = height - 100; -    } +		if (h > height) { +			h = height; +		} +	} else { +		w = (width * 2)/ 5; +		h = height - 100; +	} -    pref = wPrefGetString(HTMLHELPSECTION, WINDOWPOSPREFNAME); +	pref = wPrefGetString(HTMLHELPSECTION, WINDOWPOSPREFNAME); -    if (pref) { -        sscanf(pref, "%d %d", &x, &y); +	if (pref) { +		sscanf(pref, "%d %d", &x, &y); -        if (y > height - h) { -            y = height - h; -        } +		if (y > height - h) { +			y = height - h; +		} -        if (x > width - w) { -            x = width - w; -        } -    } else { -        x = (width * 3) / 5 - 10; -        y = 70; -    } +		if (x > width - w) { +			x = width - w; +		} +	} else { +		x = (width * 3) / 5 - 10; +		y = 70; +	} -    gtk_window_resize((GtkWindow *)wHelpWindow, w, h); -    gtk_window_move((GtkWindow *)wHelpWindow, x, y); +	gtk_window_resize((GtkWindow *)wHelpWindow, w, h); +	gtk_window_move((GtkWindow *)wHelpWindow, x, y); -    gtk_window_set_title(GTK_WINDOW(wHelpWindow), "XTrkCad Help"); +	gtk_window_set_title(GTK_WINDOW(wHelpWindow), "XTrkCad Help"); -    g_signal_connect(G_OBJECT(wHelpWindow), "delete-event", -                     G_CALLBACK(DestroyHelpWindow), NULL); +	g_signal_connect(G_OBJECT(wHelpWindow), "delete-event", +	                 G_CALLBACK(DestroyHelpWindow), NULL); -    main_view_scroller = gtk_scrolled_window_new(NULL, NULL); -    contents_view_scroller = gtk_scrolled_window_new(NULL, NULL); -    main_view = webkit_web_view_new(); -    contents_view = webkit_web_view_new(); -    // must be done here as it gets locked down later -    load_into_view("contents.html", CONTENTS_VIEW); -    gtk_widget_set_size_request(GTK_WIDGET(wHelpWindow), x, y); +	main_view_scroller = gtk_scrolled_window_new(NULL, NULL); +	contents_view_scroller = gtk_scrolled_window_new(NULL, NULL); +	main_view = webkit_web_view_new(); +	contents_view = webkit_web_view_new(); +	// must be done here as it gets locked down later +	load_into_view("contents.html", CONTENTS_VIEW); +	gtk_widget_set_size_request(GTK_WIDGET(wHelpWindow), x, y); -    main_vbox = gtk_vbox_new(FALSE, 5); -    gtk_container_add(GTK_CONTAINER(wHelpWindow), main_vbox); +	main_vbox = gtk_vbox_new(FALSE, 5); +	gtk_container_add(GTK_CONTAINER(wHelpWindow), main_vbox); -    gtk_container_add(GTK_CONTAINER(main_view_scroller), main_view); +	gtk_container_add(GTK_CONTAINER(main_view_scroller), main_view); -    gtk_container_add(GTK_CONTAINER(contents_view_scroller), contents_view); +	gtk_container_add(GTK_CONTAINER(contents_view_scroller), contents_view); -    content_hpane = gtk_hpaned_new(); -    initialize_buttons(main_vbox, content_hpane); -    gtk_container_add(GTK_CONTAINER(content_hpane), contents_view_scroller); -    gtk_container_add(GTK_CONTAINER(content_hpane), main_view_scroller); -    gtk_box_pack_start(GTK_BOX(main_vbox), content_hpane, TRUE, TRUE, 0); +	content_hpane = gtk_hpaned_new(); +	initialize_buttons(main_vbox, content_hpane); +	gtk_container_add(GTK_CONTAINER(content_hpane), contents_view_scroller); +	gtk_container_add(GTK_CONTAINER(content_hpane), main_view_scroller); +	gtk_box_pack_start(GTK_BOX(main_vbox), content_hpane, TRUE, TRUE, 0); -    gtk_paned_set_position(GTK_PANED(content_hpane), 370); +	gtk_paned_set_position(GTK_PANED(content_hpane), 370); -    g_signal_connect(contents_view, "navigation-policy-decision-requested", -                     G_CALLBACK(contents_click_handler), G_OBJECT(main_view)); +	g_signal_connect(contents_view, "navigation-policy-decision-requested", +	                 G_CALLBACK(contents_click_handler), G_OBJECT(main_view)); -    /* Store pointers to all widgets, for use by lookup_widget().  */ -    GLADE_HOOKUP_OBJECT_NO_REF(wHelpWindow, wHelpWindow, "wHelpWindow"); -    GLADE_HOOKUP_OBJECT(wHelpWindow, content_hpane, PANED); -    GLADE_HOOKUP_OBJECT(wHelpWindow, contents_view, TOCVIEW); -    GLADE_HOOKUP_OBJECT(wHelpWindow, main_view, CONTENTSVIEW); +	/* Store pointers to all widgets, for use by lookup_widget().  */ +	GLADE_HOOKUP_OBJECT_NO_REF(wHelpWindow, wHelpWindow, "wHelpWindow"); +	GLADE_HOOKUP_OBJECT(wHelpWindow, content_hpane, PANED); +	GLADE_HOOKUP_OBJECT(wHelpWindow, contents_view, TOCVIEW); +	GLADE_HOOKUP_OBJECT(wHelpWindow, main_view, CONTENTSVIEW); -    return wHelpWindow; +	return wHelpWindow;  }  void load_into_view(char *file, int requested_view)  { -    GtkWidget *view; +	GtkWidget *view; -    switch (requested_view) { -    case MAIN_VIEW: -        view = main_view; -        break; +	switch (requested_view) { +	case MAIN_VIEW: +		view = main_view; +		break; -    case CONTENTS_VIEW: -        view = contents_view; -        break; +	case CONTENTS_VIEW: +		view = contents_view; +		break; -    default: -        printf("*** error, could not find view"); -        break; -    } +	default: +		printf("*** error, could not find view"); +		break; +	} -    char fileToLoad[250] = "file://"; -    strcat(fileToLoad,directory); -    strcat(fileToLoad,file); +	char fileToLoad[250] = "file://"; +	strcat(fileToLoad,directory); +	strcat(fileToLoad,file); -    //debug printf("*** loading %s into pane %d.\n", fileToLoad, requested_view); -    webkit_web_view_load_uri(WEBKIT_WEB_VIEW(view), fileToLoad); +	//debug printf("*** loading %s into pane %d.\n", fileToLoad, requested_view); +	webkit_web_view_load_uri(WEBKIT_WEB_VIEW(view), fileToLoad);  }  /** @@ -402,36 +402,36 @@ void load_into_view(char *file, int requested_view)  void wHelp(const char * topic)  { -    char *htmlFile; +	char *htmlFile; -    //Take off any topic characters after a '-' +	//Take off any topic characters after a '-' -    if (!topic || !topic[0]) return; +	if (!topic || !topic[0]) { return; } -    if (!CheckHelpTopicExists(topic)) return; +	if (!CheckHelpTopicExists(topic)) { return; } -    if (!wHelpWindow) { -        directory = malloc(BUFSIZ); -        assert(directory != NULL); +	if (!wHelpWindow) { +		directory = malloc(BUFSIZ); +		assert(directory != NULL); -        sprintf(directory, "%s/html/", wGetAppLibDir()); +		sprintf(directory, "%s/html/", wGetAppLibDir()); -        wHelpWindow = CreateHelpWindow(); -        /* load the default content */ -        load_into_view("index.html", MAIN_VIEW); -    } +		wHelpWindow = CreateHelpWindow(); +		/* load the default content */ +		load_into_view("index.html", MAIN_VIEW); +	} -    /* need space for the 'html' extension plus dot plus \0 */ -    htmlFile = malloc(strlen(topic) + 6); +	/* need space for the 'html' extension plus dot plus \0 */ +	htmlFile = malloc(strlen(topic) + 6); -    assert(htmlFile != NULL); +	assert(htmlFile != NULL); -    sprintf(htmlFile, "%s.html", topic); +	sprintf(htmlFile, "%s.html", topic); -    load_into_view(htmlFile, MAIN_VIEW); -    gtk_widget_show_all(wHelpWindow); -    gtk_window_present(GTK_WINDOW(wHelpWindow)); +	load_into_view(htmlFile, MAIN_VIEW); +	gtk_widget_show_all(wHelpWindow); +	gtk_window_present(GTK_WINDOW(wHelpWindow)); -    free(htmlFile); +	free(htmlFile);  } | 
