Bug fixed. Solve GtkText warnings.

This commit is contained in:
Toshio Sekiya 2023-02-05 00:56:18 +09:00
parent 9650830860
commit 6941069d49
5 changed files with 100 additions and 28 deletions

View file

@ -448,14 +448,38 @@ template children for the given widget. This is the opposite of
version. If your GTK version is lower than 4.8, you need to modify the version. If your GTK version is lower than 4.8, you need to modify the
program.</p> program.</p>
<h2 id="a-waring-from-gtktext">A waring from GtkText</h2> <h2 id="a-waring-from-gtktext">A waring from GtkText</h2>
<p>If the list has many items and it needs to be scrolled, a warning <p>If your program has the following two, a warning message can be
message can be issued.</p> issued.</p>
<ul>
<li>The list has many items and it needs to be scrolled.</li>
<li>A GtkText instance is the focus widget.</li>
</ul>
<pre><code>GtkText - unexpected blinking selection. Removing</code></pre> <pre><code>GtkText - unexpected blinking selection. Removing</code></pre>
<p>I dont have an idea why this happens. But if GtkText “focusable” <p>I dont have an exact idea why this happens. But if GtkText
property is FALSE, the warning doesnt happen. So it probably come from “focusable” property is FALSE, the warning doesnt happen. So it
focus and scroll. If you know the reason, please let me know.</p> probably comes from focus and scroll.</p>
<p>It is a warning message, not a fatal error. I think we can ignore <p>You can avoid this by unsetting any focus widget under the main
it.</p> window. When scroll begins, the “value-changed” signal on the vertical
adjustment of the scrolled window is emitted.</p>
<p>The following is extracted from the ui file and C source file.</p>
<div class="sourceCode" id="cb7"><pre
class="sourceCode xml"><code class="sourceCode xml"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a>... ... ...</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a>&lt;<span class="kw">object</span><span class="ot"> class=</span><span class="st">&quot;GtkScrolledWindow&quot;</span>&gt;</span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a> &lt;<span class="kw">property</span><span class="ot"> name=</span><span class="st">&quot;hexpand&quot;</span>&gt;TRUE&lt;/<span class="kw">property</span>&gt;</span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a> &lt;<span class="kw">property</span><span class="ot"> name=</span><span class="st">&quot;vexpand&quot;</span>&gt;TRUE&lt;/<span class="kw">property</span>&gt;</span>
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a> &lt;<span class="kw">property</span><span class="ot"> name=</span><span class="st">&quot;vadjustment&quot;</span>&gt;</span>
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a> &lt;<span class="kw">object</span><span class="ot"> class=</span><span class="st">&quot;GtkAdjustment&quot;</span>&gt;</span>
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a> &lt;<span class="kw">signal</span><span class="ot"> name=</span><span class="st">&quot;value-changed&quot;</span><span class="ot"> handler=</span><span class="st">&quot;adjustment_value_changed_cb&quot;</span><span class="ot"> swapped=</span><span class="st">&quot;no&quot;</span><span class="ot"> object=</span><span class="st">&quot;LeWindow&quot;</span>/&gt;</span>
<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a> &lt;/<span class="kw">object</span>&gt;</span>
<span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a> &lt;/<span class="kw">property</span>&gt;</span>
<span id="cb7-10"><a href="#cb7-10" aria-hidden="true" tabindex="-1"></a>... ... ... </span></code></pre></div>
<div class="sourceCode" id="cb8"><pre
class="sourceCode numberSource C numberLines"><code class="sourceCode c"><span id="cb8-1"><a href="#cb8-1"></a><span class="dt">static</span> <span class="dt">void</span></span>
<span id="cb8-2"><a href="#cb8-2"></a>adjustment_value_changed_cb <span class="op">(</span>GtkAdjustment <span class="op">*</span>adjustment<span class="op">,</span> gpointer user_data<span class="op">)</span> <span class="op">{</span></span>
<span id="cb8-3"><a href="#cb8-3"></a> GtkWidget <span class="op">*</span>win <span class="op">=</span> GTK_WIDGET <span class="op">(</span>user_data<span class="op">);</span></span>
<span id="cb8-4"><a href="#cb8-4"></a></span>
<span id="cb8-5"><a href="#cb8-5"></a> gtk_window_set_focus <span class="op">(</span>GTK_WINDOW <span class="op">(</span>win<span class="op">),</span> NULL<span class="op">);</span></span>
<span id="cb8-6"><a href="#cb8-6"></a><span class="op">}</span></span></code></pre></div>
</div> </div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</body> </body>

View file

@ -323,18 +323,44 @@ If your GTK version is lower than 4.8, you need to modify the program.
## A waring from GtkText ## A waring from GtkText
If the list has many items and it needs to be scrolled, a warning message can be issued. If your program has the following two, a warning message can be issued.
- The list has many items and it needs to be scrolled.
- A GtkText instance is the focus widget.
~~~ ~~~
GtkText - unexpected blinking selection. Removing GtkText - unexpected blinking selection. Removing
~~~ ~~~
I don't have an idea why this happens. I don't have an exact idea why this happens.
But if GtkText "focusable" property is FALSE, the warning doesn't happen. But if GtkText "focusable" property is FALSE, the warning doesn't happen.
So it probably come from focus and scroll. So it probably comes from focus and scroll.
If you know the reason, please let me know.
It is a warning message, not a fatal error. You can avoid this by unsetting any focus widget under the main window.
I think we can ignore it. When scroll begins, the "value-changed" signal on the vertical adjustment of the scrolled window is emitted.
The following is extracted from the ui file and C source file.
~~~xml
... ... ...
<object class="GtkScrolledWindow">
<property name="hexpand">TRUE</property>
<property name="vexpand">TRUE</property>
<property name="vadjustment">
<object class="GtkAdjustment">
<signal name="value-changed" handler="adjustment_value_changed_cb" swapped="no" object="LeWindow"/>
</object>
</property>
... ... ...
~~~
~~~C
1 static void
2 adjustment_value_changed_cb (GtkAdjustment *adjustment, gpointer user_data) {
3 GtkWidget *win = GTK_WIDGET (user_data);
4
5 gtk_window_set_focus (GTK_WINDOW (win), NULL);
6 }
~~~
Up: [README.md](../README.md), Prev: [Section 29](sec29.md) Up: [README.md](../README.md), Prev: [Section 29](sec29.md)

View file

@ -218,9 +218,12 @@ ins_cb (GtkButton *btn, LeWindow *win) {
static void static void
rm_cb (GtkButton *btn, LeWindow *win) { rm_cb (GtkButton *btn, LeWindow *win) {
int position;
if (win->position >= 0) { if (win->position >= 0) {
g_list_store_remove (win->liststore, win->position); position = win->position;
win->position = -1; win->position = -1;
g_list_store_remove (win->liststore, position);
update_current (win, -1); update_current (win, -1);
} }
} }
@ -453,12 +456,12 @@ unbind2_cb (GtkListItemFactory *factory, GtkListItem *listitem) {
g_object_set_data (G_OBJECT (listitem), "bind", NULL); g_object_set_data (G_OBJECT (listitem), "bind", NULL);
} }
// static void static void
// adjustment_value_changed_cb (GtkAdjustment *adjustment, gpointer user_data) { adjustment_value_changed_cb (GtkAdjustment *adjustment, gpointer user_data) {
// GtkWidget *win = GTK_WIDGET (user_data); GtkWidget *win = GTK_WIDGET (user_data);
// gtk_widget_set_can_focus (win, FALSE); gtk_window_set_focus (GTK_WINDOW (win), NULL);
// } }
static void static void
le_window_init (LeWindow *win) { le_window_init (LeWindow *win) {
@ -503,7 +506,7 @@ le_window_class_init (LeWindowClass *class) {
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), setup2_cb); gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), setup2_cb);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), bind2_cb); gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), bind2_cb);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), unbind2_cb); gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), unbind2_cb);
// gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), adjustment_value_changed_cb); gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), adjustment_value_changed_cb);
} }
GtkWidget * GtkWidget *

View file

@ -84,13 +84,11 @@
<object class="GtkScrolledWindow"> <object class="GtkScrolledWindow">
<property name="hexpand">TRUE</property> <property name="hexpand">TRUE</property>
<property name="vexpand">TRUE</property> <property name="vexpand">TRUE</property>
<!--
<property name="vadjustment"> <property name="vadjustment">
<object class="GtkAdjustment"> <object class="GtkAdjustment">
<signal name="value-changed" handler="adjustment_value_changed_cb" swapped="no" object="LeWindow"/> <signal name="value-changed" handler="adjustment_value_changed_cb" swapped="no" object="LeWindow"/>
</object> </object>
</property> </property>
-->
<child> <child>
<object class="GtkColumnView" id="columnview"> <object class="GtkColumnView" id="columnview">
<property name="hexpand">TRUE</property> <property name="hexpand">TRUE</property>

View file

@ -221,16 +221,37 @@ If your GTK version is lower than 4.8, you need to modify the program.
## A waring from GtkText ## A waring from GtkText
If the list has many items and it needs to be scrolled, a warning message can be issued. If your program has the following two, a warning message can be issued.
- The list has many items and it needs to be scrolled.
- A GtkText instance is the focus widget.
~~~ ~~~
GtkText - unexpected blinking selection. Removing GtkText - unexpected blinking selection. Removing
~~~ ~~~
I don't have an idea why this happens. I don't have an exact idea why this happens.
But if GtkText "focusable" property is FALSE, the warning doesn't happen. But if GtkText "focusable" property is FALSE, the warning doesn't happen.
So it probably come from focus and scroll. So it probably comes from focus and scroll.
If you know the reason, please let me know.
It is a warning message, not a fatal error. You can avoid this by unsetting any focus widget under the main window.
I think we can ignore it. When scroll begins, the "value-changed" signal on the vertical adjustment of the scrolled window is emitted.
The following is extracted from the ui file and C source file.
~~~xml
... ... ...
<object class="GtkScrolledWindow">
<property name="hexpand">TRUE</property>
<property name="vexpand">TRUE</property>
<property name="vadjustment">
<object class="GtkAdjustment">
<signal name="value-changed" handler="adjustment_value_changed_cb" swapped="no" object="LeWindow"/>
</object>
</property>
... ... ...
~~~
@@@include
listeditor/listeditor.c adjustment_value_changed_cb
@@@