<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<tt>Hello:</tt><tt><br>
</tt><tt><br>
(I am</tt><tt><span id="result_box" class="" lang="en"><span
class="alt-edited"> a novice with gtk</span></span>)<br>
<br>
</tt><tt><span id="result_box" class="" lang="en"><span>I wanted to
put a progress bar on xfce4-panel.</span><br>
<span>I do not know why the behavior is different if it goes
horizontally or vertically.</span><br>
<span>I am not able to focus on the widget.</span><br>
<span>They put different background colors so that the position
can be appreciated.</span><br>
<span>What he wanted is:</span><br>
<span>- Center widget.</span><br>
<span>- Set the space to the sides (horizontal) up and down
(vertical) so that it occupies less.</span><br>
<br>
<span class="">In the gtk3 documentation I did not find much
about this.</span><br>
<span>Any idea of where do I have to look?</span></span></tt><tt><br>
</tt><tt><br>
</tt><br>
<tt><span id="result_box" class="" lang="en"><span class="">Here's
an image of how it looks with the current code<br>
<br>
</span></span><a class="moz-txt-link-freetext" href="https://ibb.co/dcb17w">https://ibb.co/dcb17w</a></tt><tt><br>
<a class="moz-txt-link-freetext" href="https://image.ibb.co/n0sKub/xfce4_timer_plugin.png">https://image.ibb.co/n0sKub/xfce4_timer_plugin.png</a><br>
</tt><tt><br>
</tt><br>
<tt><span id="result_box" class="" lang="en"><span class="">The code
is this, there are many commented parties, they are proof that
they did not work ...<br>
<br>
</span></span></tt><tt>static void add_pbar(XfcePanelPlugin
*plugin, plugin_data *pd){</tt><tt><br>
</tt><tt><br>
</tt><tt> gdouble frac;</tt><tt><br>
</tt><tt><br>
</tt><tt> GtkCssProvider *css_provider;</tt><tt><br>
</tt><tt><br>
</tt><tt> gtk_widget_hide(GTK_WIDGET(plugin));</tt><tt><br>
</tt><tt><br>
</tt><tt> /* Always true except at initialization */</tt><tt><br>
</tt><tt> if(pd->box){</tt><tt><br>
</tt><tt> g_object_ref(G_OBJECT(pd->pbar));</tt><tt><br>
</tt><tt>
gtk_container_remove(GTK_CONTAINER(pd->box),pd->pbar);</tt><tt><br>
</tt><tt> gtk_widget_destroy(pd->box);</tt><tt><br>
</tt><tt> }</tt><tt><br>
</tt><tt><br>
</tt><tt> if (pd -> box) {</tt><tt><br>
</tt><tt> frac = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR
(pd->pbar));</tt><tt><br>
</tt><tt> gtk_widget_destroy(pd->box);</tt><tt><br>
</tt><tt> pd->pbar = gtk_progress_bar_new ();</tt><tt><br>
</tt><tt> //gtk_progress_bar_set_bar_style
(GTK_PROGRESS_BAR(pd->pbar),</tt><tt><br>
</tt><tt> // GTK_PROGRESS_CONTINUOUS);</tt><tt><br>
</tt><tt>
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pd->pbar),frac);</tt><tt><br>
</tt><tt> }</tt><tt><br>
</tt><tt> </tt><tt><br>
</tt><tt> gtk_progress_bar_set_inverted
(GTK_PROGRESS_BAR(pd->pbar), TRUE);</tt><tt><br>
</tt><tt><br>
</tt><tt><br>
</tt><tt><br>
</tt><tt> /* vertical bar */</tt><tt><br>
</tt><tt>
if(xfce_panel_plugin_get_orientation(plugin)==GTK_ORIENTATION_HORIZONTAL){</tt><tt><br>
</tt><tt> pd->box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,
0);</tt><tt><br>
</tt><tt> gtk_widget_set_name (GTK_WIDGET (pd->box ),
"xfce4-timer-plugin-v");</tt><tt><br>
</tt><tt> //gtk_container_set_border_width
(GTK_CONTAINER(pd->box), BORDER/2);</tt><tt><br>
</tt><tt> gtk_container_set_border_width
(GTK_CONTAINER(pd->box), 0);</tt><tt><br>
</tt><tt><br>
</tt><tt> gtk_container_add(GTK_CONTAINER(plugin),pd->box);</tt><tt><br>
</tt><tt>
gtk_orientable_set_orientation(GTK_ORIENTABLE(pd->pbar),</tt><tt><br>
</tt><tt>
GTK_ORIENTATION_VERTICAL);</tt><tt><br>
</tt><tt>
gtk_widget_set_size_request(GTK_WIDGET(pd->pbar),PBAR_THICKNESS,0);</tt><tt><br>
</tt><tt> //gtk_box_pack_start(GTK_BOX(pd->box),</tt><tt><br>
</tt><tt> //
gtk_separator_new(GTK_ORIENTATION_VERTICAL),</tt><tt><br>
</tt><tt> // FALSE, FALSE, 0);</tt><tt><br>
</tt><tt><br>
</tt><tt><br>
</tt><tt><br>
</tt><tt> /* Sane default Gtk style */</tt><tt><br>
</tt><tt> css_provider = gtk_css_provider_new ();</tt><tt><br>
</tt><tt> gtk_css_provider_load_from_data (css_provider,</tt><tt><br>
</tt><tt>
"#xfce4-timer-plugin-v {"</tt><tt><br>
</tt><tt>
//"-GtkWidget-focus-padding: 0;"</tt><tt><br>
</tt><tt>
//"-GtkWidget-focus-line-width: 0;"</tt><tt><br>
</tt><tt>
//"-GtkButton-default-border: 0;"</tt><tt><br>
</tt><tt>
//"-GtkButton-inner-border: 0;"</tt><tt><br>
</tt><tt>
//"-GtkButton-background-color: red;"</tt><tt><br>
</tt><tt> "background-color:
red;"</tt><tt><br>
</tt><tt> //"padding: 0px;"</tt><tt><br>
</tt><tt> //"padding‑right:
-10px;"</tt><tt><br>
</tt><tt> //"margin‑right:
-10px;"</tt><tt><br>
</tt><tt> //"border‑right:
-10px;"</tt><tt><br>
</tt><tt> //"width: 20px;"</tt><tt><br>
</tt><tt> "border-left:
solid 15px blue;"</tt><tt><br>
</tt><tt> "border-right:
solid 5px pink;"</tt><tt><br>
</tt><tt> "}",</tt><tt><br>
</tt><tt> -1, NULL);</tt><tt><br>
</tt><tt> gtk_style_context_add_provider (GTK_STYLE_CONTEXT
(gtk_widget_get_style_context (GTK_WIDGET (pd->box ))),</tt><tt><br>
</tt><tt> GTK_STYLE_PROVIDER
(css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);</tt><tt><br>
</tt><tt><br>
</tt><tt>
gtk_box_pack_start(GTK_BOX(pd->box),pd->pbar,FALSE,FALSE,0);</tt><tt><br>
</tt><tt> //gtk_box_pack_start(GTK_BOX(pd->box),</tt><tt><br>
</tt><tt> //
gtk_separator_new(GTK_ORIENTATION_VERTICAL),</tt><tt><br>
</tt><tt> // FALSE, FALSE, 0);</tt><tt><br>
</tt><tt><br>
</tt><tt><br>
</tt><tt><br>
</tt><tt> }</tt><tt><br>
</tt><tt> else{ /* horizontal bar */</tt><tt><br>
</tt><tt> pd->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);</tt><tt><br>
</tt><tt> gtk_widget_set_name (GTK_WIDGET (pd->box ),
"xfce4-timer-plugin-h");</tt><tt><br>
</tt><tt> //gtk_container_set_border_width
(GTK_CONTAINER(pd->box), BORDER/2);</tt><tt><br>
</tt><tt> gtk_container_set_border_width
(GTK_CONTAINER(pd->box), BORDER/2);</tt><tt><br>
</tt><tt> gtk_container_add(GTK_CONTAINER(plugin),pd->box);</tt><tt><br>
</tt><tt><br>
</tt><tt>
gtk_orientable_set_orientation(GTK_ORIENTABLE(pd->pbar),</tt><tt><br>
</tt><tt> GTK_ORIENTATION_HORIZONTAL);</tt><tt><br>
</tt><tt>
gtk_widget_set_size_request(GTK_WIDGET(pd->pbar),0,PBAR_THICKNESS);</tt><tt><br>
</tt><tt> //gtk_box_pack_start(GTK_BOX(pd->box),</tt><tt><br>
</tt><tt> //
gtk_separator_new(GTK_ORIENTATION_HORIZONTAL),</tt><tt><br>
</tt><tt> // FALSE, FALSE, 0);</tt><tt><br>
</tt><tt><br>
</tt><tt> gtk_widget_set_name (GTK_WIDGET (pd->pbar ),
"xfce4-timer-plugin-h-pbar");</tt><tt><br>
</tt><tt> /* Sane default Gtk style */</tt><tt><br>
</tt><tt> css_provider = gtk_css_provider_new ();</tt><tt><br>
</tt><tt> gtk_css_provider_load_from_data (css_provider,</tt><tt><br>
</tt><tt> "#xfce4-timer-plugin-h
{"</tt><tt><br>
</tt><tt>
//"-GtkWidget-focus-padding: 0;"</tt><tt><br>
</tt><tt>
//"-GtkWidget-focus-line-width: 0;"</tt><tt><br>
</tt><tt>
//"-GtkButton-default-border: 0;"</tt><tt><br>
</tt><tt>
//"-GtkButton-inner-border: 0;"</tt><tt><br>
</tt><tt>
//"-GtkButton-background-color: red;"</tt><tt><br>
</tt><tt> "background-color:
green;"</tt><tt><br>
</tt><tt> //"padding: 0px;"</tt><tt><br>
</tt><tt> "padding‑right: 20px;"</tt><tt><br>
</tt><tt> "margin‑right: 20px;"</tt><tt><br>
</tt><tt> "border-width: 20px;"</tt><tt><br>
</tt><tt> "border-top-color:
rgb(128,57,0);"</tt><tt><br>
</tt><tt> "border-left-color:
rgba(10%,20%,30%,0.5);"</tt><tt><br>
</tt><tt> "border-right-color:
#ff00cc;"</tt><tt><br>
</tt><tt> "border-bottom-color:
#ffff0000cccc;} #xfce4-timer-plugin-h-pbar {border: solid 5px
pink;}",</tt><tt><br>
</tt><tt> -1, NULL);</tt><tt><br>
</tt><tt> gtk_style_context_add_provider (GTK_STYLE_CONTEXT
(gtk_widget_get_style_context (GTK_WIDGET (pd->box ))),</tt><tt><br>
</tt><tt> GTK_STYLE_PROVIDER
(css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);</tt><tt><br>
</tt><tt><br>
</tt><tt>
gtk_box_pack_start(GTK_BOX(pd->box),pd->pbar,FALSE,FALSE,0);</tt><tt><br>
</tt><tt> //gtk_box_pack_start(GTK_BOX(pd->box),</tt><tt><br>
</tt><tt> //
gtk_separator_new(GTK_ORIENTATION_HORIZONTAL),</tt><tt><br>
</tt><tt> // FALSE, FALSE, 0);</tt><tt><br>
</tt><tt><br>
</tt><tt> }</tt><tt><br>
</tt><tt><br>
</tt><tt><br>
</tt><tt> gtk_widget_show_all(GTK_WIDGET(plugin)); </tt><tt><br>
</tt><tt><br>
</tt><tt>}</tt><tt><br>
</tt><tt><br>
<br>
Very thanks<br>
</tt><tt><br>
</tt>
<pre class="moz-signature" cols="72">--
Dani</pre>
</body>
</html>