progress bar on panel
Dani
dani at damufo.com
Wed Dec 6 10:47:25 CET 2017
Hello:
(I ama novice with gtk)
I wanted to put a progress bar on xfce4-panel.
I do not know why the behavior is different if it goes horizontally or
vertically.
I am not able to focus on the widget.
They put different background colors so that the position can be
appreciated.
What he wanted is:
- Center widget.
- Set the space to the sides (horizontal) up and down (vertical) so that
it occupies less.
In the gtk3 documentation I did not find much about this.
Any idea of where do I have to look?
Here's an image of how it looks with the current code
https://ibb.co/dcb17w
https://image.ibb.co/n0sKub/xfce4_timer_plugin.png
The code is this, there are many commented parties, they are proof that
they did not work ...
static void add_pbar(XfcePanelPlugin *plugin, plugin_data *pd){
gdouble frac;
GtkCssProvider *css_provider;
gtk_widget_hide(GTK_WIDGET(plugin));
/* Always true except at initialization */
if(pd->box){
g_object_ref(G_OBJECT(pd->pbar));
gtk_container_remove(GTK_CONTAINER(pd->box),pd->pbar);
gtk_widget_destroy(pd->box);
}
if (pd -> box) {
frac = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (pd->pbar));
gtk_widget_destroy(pd->box);
pd->pbar = gtk_progress_bar_new ();
//gtk_progress_bar_set_bar_style (GTK_PROGRESS_BAR(pd->pbar),
// GTK_PROGRESS_CONTINUOUS);
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pd->pbar),frac);
}
gtk_progress_bar_set_inverted (GTK_PROGRESS_BAR(pd->pbar), TRUE);
/* vertical bar */
if(xfce_panel_plugin_get_orientation(plugin)==GTK_ORIENTATION_HORIZONTAL){
pd->box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_name (GTK_WIDGET (pd->box ), "xfce4-timer-plugin-v");
//gtk_container_set_border_width (GTK_CONTAINER(pd->box), BORDER/2);
gtk_container_set_border_width (GTK_CONTAINER(pd->box), 0);
gtk_container_add(GTK_CONTAINER(plugin),pd->box);
gtk_orientable_set_orientation(GTK_ORIENTABLE(pd->pbar),
GTK_ORIENTATION_VERTICAL);
gtk_widget_set_size_request(GTK_WIDGET(pd->pbar),PBAR_THICKNESS,0);
//gtk_box_pack_start(GTK_BOX(pd->box),
// gtk_separator_new(GTK_ORIENTATION_VERTICAL),
// FALSE, FALSE, 0);
/* Sane default Gtk style */
css_provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (css_provider,
"#xfce4-timer-plugin-v {"
//"-GtkWidget-focus-padding: 0;"
//"-GtkWidget-focus-line-width: 0;"
//"-GtkButton-default-border: 0;"
//"-GtkButton-inner-border: 0;"
//"-GtkButton-background-color: red;"
"background-color: red;"
//"padding: 0px;"
//"padding‑right: -10px;"
//"margin‑right: -10px;"
//"border‑right: -10px;"
//"width: 20px;"
"border-left: solid 15px blue;"
"border-right: solid 5px pink;"
"}",
-1, NULL);
gtk_style_context_add_provider (GTK_STYLE_CONTEXT
(gtk_widget_get_style_context (GTK_WIDGET (pd->box ))),
GTK_STYLE_PROVIDER
(css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
gtk_box_pack_start(GTK_BOX(pd->box),pd->pbar,FALSE,FALSE,0);
//gtk_box_pack_start(GTK_BOX(pd->box),
// gtk_separator_new(GTK_ORIENTATION_VERTICAL),
// FALSE, FALSE, 0);
}
else{ /* horizontal bar */
pd->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_name (GTK_WIDGET (pd->box ), "xfce4-timer-plugin-h");
//gtk_container_set_border_width (GTK_CONTAINER(pd->box), BORDER/2);
gtk_container_set_border_width (GTK_CONTAINER(pd->box), BORDER/2);
gtk_container_add(GTK_CONTAINER(plugin),pd->box);
gtk_orientable_set_orientation(GTK_ORIENTABLE(pd->pbar),
GTK_ORIENTATION_HORIZONTAL);
gtk_widget_set_size_request(GTK_WIDGET(pd->pbar),0,PBAR_THICKNESS);
//gtk_box_pack_start(GTK_BOX(pd->box),
// gtk_separator_new(GTK_ORIENTATION_HORIZONTAL),
// FALSE, FALSE, 0);
gtk_widget_set_name (GTK_WIDGET (pd->pbar ),
"xfce4-timer-plugin-h-pbar");
/* Sane default Gtk style */
css_provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (css_provider,
"#xfce4-timer-plugin-h {"
//"-GtkWidget-focus-padding: 0;"
//"-GtkWidget-focus-line-width: 0;"
//"-GtkButton-default-border: 0;"
//"-GtkButton-inner-border: 0;"
//"-GtkButton-background-color: red;"
"background-color: green;"
//"padding: 0px;"
"padding‑right: 20px;"
"margin‑right: 20px;"
"border-width: 20px;"
"border-top-color: rgb(128,57,0);"
"border-left-color:
rgba(10%,20%,30%,0.5);"
"border-right-color: #ff00cc;"
"border-bottom-color:
#ffff0000cccc;} #xfce4-timer-plugin-h-pbar {border: solid 5px pink;}",
-1, NULL);
gtk_style_context_add_provider (GTK_STYLE_CONTEXT
(gtk_widget_get_style_context (GTK_WIDGET (pd->box ))),
GTK_STYLE_PROVIDER (css_provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
gtk_box_pack_start(GTK_BOX(pd->box),pd->pbar,FALSE,FALSE,0);
//gtk_box_pack_start(GTK_BOX(pd->box),
// gtk_separator_new(GTK_ORIENTATION_HORIZONTAL),
// FALSE, FALSE, 0);
}
gtk_widget_show_all(GTK_WIDGET(plugin));
}
Very thanks
--
Dani
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.xfce.org/pipermail/xfce4-dev/attachments/20171206/0b3445c7/attachment-0001.html>
More information about the Xfce4-dev
mailing list