Made the GTK+ ProgressBar arbitrary resize a program-global style.
This commit is contained in:
parent
09a5a859a0
commit
e28dff429d
|
@ -12,11 +12,10 @@ import (
|
||||||
|
|
||||||
// #include "gtk_unix.h"
|
// #include "gtk_unix.h"
|
||||||
// /* TODO this doesn't need to be in C; it is because an earlier version did it wrong and depended on a function (g_object_set()) that took ..., which cgo doesn't like... but is it safe to embed \0 in a Go string? */
|
// /* TODO this doesn't need to be in C; it is because an earlier version did it wrong and depended on a function (g_object_set()) that took ..., which cgo doesn't like... but is it safe to embed \0 in a Go string? */
|
||||||
// static inline char *gtkProgressBarAllowArbitraryResize(GtkWidget *pbar)
|
// static inline GError *gtkProgressBarAllowArbitraryResize()
|
||||||
// {
|
// {
|
||||||
// /* min-horizontal-bar-width is a style property; we do it through CSS */
|
// /* min-horizontal-bar-width is a style property; we do it through CSS */
|
||||||
// /* thanks tristan in irc.gimp.net/#gtk+ */
|
// /* thanks tristan in irc.gimp.net/#gtk+ */
|
||||||
// /* TODO find out how to make it an application default */
|
|
||||||
// static gchar style[] =
|
// static gchar style[] =
|
||||||
// "* {\n"
|
// "* {\n"
|
||||||
// " -GtkProgressBar-min-horizontal-bar-width: 1;\n"
|
// " -GtkProgressBar-min-horizontal-bar-width: 1;\n"
|
||||||
|
@ -26,8 +25,10 @@ import (
|
||||||
//
|
//
|
||||||
// provider = gtk_css_provider_new();
|
// provider = gtk_css_provider_new();
|
||||||
// if (gtk_css_provider_load_from_data(provider, style, -1, &err) == FALSE)
|
// if (gtk_css_provider_load_from_data(provider, style, -1, &err) == FALSE)
|
||||||
// return (char *) g_strdup(err->message);
|
// return err;
|
||||||
// gtk_style_context_add_provider(gtk_widget_get_style_context(pbar),
|
// /* GDK (at least as far back as GTK+ 3.4, but officially documented as of 3.10) merges all screens into one big one, so we don't need to worry about multimonitor */
|
||||||
|
// /* thanks to baedert and mclasen in irc.gimp.net/#gtk+ */
|
||||||
|
// gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
|
||||||
// (GtkStyleProvider *) provider, GTK_STYLE_PROVIDER_PRIORITY_USER);
|
// (GtkStyleProvider *) provider, GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||||
// return NULL;
|
// return NULL;
|
||||||
// }
|
// }
|
||||||
|
@ -40,7 +41,13 @@ func gtk_init() error {
|
||||||
// TODO allow GTK+ standard command-line argument processing?
|
// TODO allow GTK+ standard command-line argument processing?
|
||||||
result := C.gtk_init_with_args(nil, nil, nil, nil, nil, &err)
|
result := C.gtk_init_with_args(nil, nil, nil, nil, nil, &err)
|
||||||
if result == C.FALSE {
|
if result == C.FALSE {
|
||||||
return fmt.Errorf("%s", fromgstr(err.message))
|
return fmt.Errorf("error actually initilaizing GTK+: %s", fromgstr(err.message))
|
||||||
|
}
|
||||||
|
// otherwise progress bars can't be resized smaller than some predetermined size
|
||||||
|
err = C.gtkProgressBarAllowArbitraryResize()
|
||||||
|
if err != nil {
|
||||||
|
defer C.g_free(C.gpointer(unsafe.Pointer(err)))
|
||||||
|
return fmt.Errorf("error allowing ProgressBar to be arbitrarily resized: %s", fromgstr(err.message))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -255,14 +262,7 @@ func gtk_widget_get_preferred_size(widget *C.GtkWidget) (minWidth int, minHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
func gtk_progress_bar_new() *C.GtkWidget {
|
func gtk_progress_bar_new() *C.GtkWidget {
|
||||||
p := C.gtk_progress_bar_new()
|
return C.gtk_progress_bar_new()
|
||||||
// otherwise the progress bar can't be resized smaller than some predetermined size
|
|
||||||
err := C.gtkProgressBarAllowArbitraryResize(p)
|
|
||||||
if err != nil {
|
|
||||||
defer C.g_free(C.gpointer(unsafe.Pointer(err)))
|
|
||||||
panic(fmt.Errorf("error allowing ProgressBar to be arbitrarily resized: %s", C.GoString(err)))
|
|
||||||
}
|
|
||||||
return p
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func gtk_progress_bar_set_fraction(w *C.GtkWidget, percent int) {
|
func gtk_progress_bar_set_fraction(w *C.GtkWidget, percent int) {
|
||||||
|
|
Loading…
Reference in New Issue