Fix font picker

This commit is contained in:
Lubomir Rintel 2008-02-16 14:10:44 +00:00
parent f9a699108c
commit fc8c18b028
2 changed files with 177 additions and 2 deletions

View File

@ -0,0 +1,170 @@
Fix the font selector #432892
Index: src/desktop-style.cpp
===================================================================
--- src/desktop-style.cpp (revision 17350)
+++ src/desktop-style.cpp (revision 17352)
@@ -1096,7 +1096,7 @@
}
}
- if (texts == 0 || !style_res->text->font_specification.set)
+ if (texts == 0)
return QUERY_STYLE_NOTHING;
if (texts > 1) {
Index: src/widgets/toolbox.cpp
===================================================================
--- src/widgets/toolbox.cpp (revision 17350)
+++ src/widgets/toolbox.cpp (revision 17352)
@@ -40,6 +40,7 @@
#include "widgets/spw-utilities.h"
#include "widgets/spinbutton-events.h"
#include "dialogs/text-edit.h"
+#include "dialogs/dialog-events.h"
#include "ui/widget/style-swatch.h"
@@ -3957,7 +3958,8 @@
namespace {
-bool visible = false;
+bool popdown_visible = false;
+bool popdown_hasfocus = false;
void
sp_text_toolbox_selection_changed (Inkscape::Selection */*selection*/, GObject *tbl)
@@ -4146,13 +4148,10 @@
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
GtkTreeModel *model = 0;
- GtkWidget *popdown = GTK_WIDGET (g_object_get_data (tbl, "family-popdown-window"));
GtkWidget *entry = GTK_WIDGET (g_object_get_data (tbl, "family-entry"));
GtkTreeIter iter;
char *family = 0;
- (void)popdown;
-
gdk_pointer_ungrab (GDK_CURRENT_TIME);
gdk_keyboard_ungrab (GDK_CURRENT_TIME);
@@ -4175,7 +4174,7 @@
int result_fontspec =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION);
-
+
font_instance * fontFromStyle = font_factory::Default()->FaceFromStyle(query);
SPCSSAttr *css = sp_repr_css_attr_new ();
@@ -4183,7 +4182,7 @@
// First try to get the font spec from the stored value
Glib::ustring fontSpec = query->text->font_specification.set ? query->text->font_specification.value : "";
-
+
if (fontSpec.empty()) {
// Construct a new font specification if it does not yet exist
font_instance * fontFromStyle = font_factory::Default()->FaceFromStyle(query);
@@ -4223,7 +4222,7 @@
}
}
- // If querying returned nothing, read the style from the text tool prefs (default style for new texts)
+ // If querying returned nothing, set the default style of the tool (for new texts)
if (result_fontspec == QUERY_STYLE_NOTHING)
{
sp_repr_css_change (inkscape_get_repr (INKSCAPE, "tools.text"), css, "style");
@@ -4485,10 +4484,19 @@
case GDK_Return:
case GDK_Escape: // defocus
gtk_widget_hide (w);
- visible = false;
+ popdown_visible = false;
gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
return TRUE; // I consumed the event
break;
+ case GDK_w:
+ case GDK_W:
+ if (event->state & GDK_CONTROL_MASK) {
+ gtk_widget_hide (w);
+ popdown_visible = false;
+ gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
+ return TRUE; // I consumed the event
+ }
+ break;
}
return FALSE;
}
@@ -4598,11 +4606,12 @@
GtkWidget *widget = GTK_WIDGET (g_object_get_data (tbl, "family-entry"));
int x, y;
- if (!visible)
+ if (!popdown_visible)
{
gdk_window_get_origin (widget->window, &x, &y);
gtk_window_move (GTK_WINDOW (popdown), x, y + widget->allocation.height + 2); //2px of grace space
gtk_widget_show_all (popdown);
+ //sp_transientize (popdown);
gdk_pointer_grab (widget->window, TRUE,
GdkEventMask (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
@@ -4612,14 +4621,16 @@
gdk_keyboard_grab (widget->window, TRUE, GDK_CURRENT_TIME);
- visible = true;
+ popdown_visible = true;
}
else
{
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
gdk_pointer_ungrab (GDK_CURRENT_TIME);
gdk_keyboard_ungrab (GDK_CURRENT_TIME);
+ gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
gtk_widget_hide (popdown);
- visible = false;
+ popdown_visible = false;
}
}
@@ -4639,12 +4650,26 @@
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- gtk_widget_hide (popdown);
- visible = false;
- gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
+ if (popdown_hasfocus) {
+ gtk_widget_hide (popdown);
+ popdown_hasfocus = false;
+ popdown_visible = false;
+ gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
+ return TRUE;
+ }
+ return FALSE;
+}
+
+gboolean
+sp_text_toolbox_popdown_focus_in (GtkWidget *popdown,
+ GdkEventFocus */*event*/,
+ GObject */*tbl*/)
+{
+ popdown_hasfocus = true;
return TRUE;
}
+
void
cell_data_func (GtkTreeViewColumn */*column*/,
GtkCellRenderer *cell,
@@ -4745,6 +4770,7 @@
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (sp_text_toolbox_text_popdown_clicked), tbl);
g_signal_connect (G_OBJECT (window), "focus-out-event", G_CALLBACK (sp_text_toolbox_popdown_focus_out), tbl);
+ g_signal_connect (G_OBJECT (window), "focus-in-event", G_CALLBACK (sp_text_toolbox_popdown_focus_in), tbl);
g_signal_connect (G_OBJECT (window), "key-press-event", G_CALLBACK(sp_text_toolbox_family_list_keypress), tbl);
GtkTreeSelection *tselection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));

View File

@ -1,6 +1,6 @@
Name: inkscape
Version: 0.45.1+0.46pre1
Release: 4%{?dist}
Release: 5%{?dist}
Summary: Vector-based drawing program using SVG
Group: Applications/Productivity
@ -13,6 +13,7 @@ Patch2: inkscape-0.46pre1-gcc43.patch
Patch3: inkscape-0.46pre1-vectors.patch
Patch4: inkscape-0.46pre1-ocal1.patch
Patch5: inkscape-0.46pre1-ocal2.patch
Patch6: inkscape-0.46pre1-fontsel.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -71,9 +72,10 @@ C and C++, using the Gtk+ toolkit and optionally some Gnome libraries.
%patch3 -p1 -b .vectors
%patch4 -p1 -b .ocal1
%patch5 -p1 -b .ocal2
%patch6 -p0 -b .fontsel
find -type f -regex '.*\.\(cpp\|h\)' -perm +111 -exec chmod -x {} ';'
find share/extensions/ -type f -regex '.*\.py' -perm +111 -exec chmod -x {} ';'
dos2unix share/extensions/*.py
dos2unix -k -q share/extensions/*.py
%build
@ -130,6 +132,9 @@ update-desktop-database %{_datadir}/applications > /dev/null 2>&1 || :
%changelog
* Sat Feb 16 2008 Lubomir Kundrak <lkundrak@redhat.com> - 0.45.1+0.46pre1-5
- Attempt to fix the font selector (#432892)
* Thu Feb 14 2008 Lubomir Kundrak <lkundrak@redhat.com> - 0.45.1+0.46pre1-4
- Tolerate recoverable errors in OCAL feeds
- Fix OCAL insecure temporary file usage (#432807)