summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e4e2594)
raw | patch | inline | side by side (parent: e4e2594)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Sat, 16 Feb 2008 09:58:21 +0000 (09:58 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Sat, 16 Feb 2008 09:58:21 +0000 (09:58 +0000) |
src/widgets/toolbox.cpp | patch | blob | history |
index bee1d0a83dc0d3ca7640bf842602a2eda333f681..1063ce2a19b0e250245e25785113d60f8a681177 100644 (file)
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
#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"
namespace {
-bool visible = false;
+bool popdown_visible = false;
+bool popdown_hasfocus = false;
void
sp_text_toolbox_selection_changed (Inkscape::Selection */*selection*/, GObject *tbl)
{
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);
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 ();
// 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);
}
}
- // 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 @@ sp_text_toolbox_family_list_keypress (GtkWidget *w, GdkEventKey *event, GObject
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;
}
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 |
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;
}
}
{
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,
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));