Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- merged gtk-2 branch to main branch

  • Loading branch information...
commit e48fe6e2447337b2126016e7f02d677389f13bb3 1 parent 60b30da
andreas99 authored
View
51 README
@@ -1,13 +1,14 @@
-gmrun 0.6.0 http://www.sourceforge.net/projects/gmrun
-------------
+gmrun 0.9.0 http://students.infoiasi.ro/~mishoo/site/gmrun.epl
+------------ ---------------------------------------------------
Short GtkEntry for file autocompletion + main.cc that does the
needed stuff for running programs. This is intended as a
- replacement to grun, which (sorry) sucks. The idea comes from the
- KDE Window Manager (ALT-F2 in KDE). Though, GNOME is better :)
+ replacement to grun or gnome-run, which (sorry) sucks. The idea
+ comes from the KDE Window Manager (ALT-F2 in KDE). Though, GNOME
+ is better :)
-Copyright (c) 2000 Mishoo.
+Copyright (c) 2000-2003 Mihai Bazon
Author: Mihai Bazon <mishoo@infoiasi.ro>.
send postcards to:
@@ -52,30 +53,41 @@ Features
www.google.com. The URL-s are configurable from the configuration
file, in a simple manner (I hope..).
+ * Extension handlers (added in 0.8.0). Basically you can run, for
+ instance, a ".txt" file, assuming that you have configured a handler for
+ it in the configuration file. The default handler for ".txt" files is,
+ of course, Emacs. But you can easily change that, you... you VIM user!
+
+
+Requirements
+-------------
+
+ * A good C++ compiler (that is, g++ 3.0 or later). It did originally
+ compile with g++ 2.95, but not anymore ;-] -- though that's easy to fix.
+
+ * GTK-2. gmrun upto and including 0.8.1 were for GTK-1.x series, version
+ 0.9.0 requires GTK-2.
+
For code critics
-----------------
This program is written in 2 hours. The code might seem a little weird,
- but it works, and is that I'm interested in. Code completion is written
- in C++, although GTK+ is written in standard C. Should you think this
- is a problem, feel free to rewrite the code in C (it could be at least 4
- times bigger).
+ but it works, and that's what I'm interested in. Code completion is
+ written in C++, although GTK+ is written in standard C. Should you think
+ this is a problem, feel free to rewrite the code in C (it could be at
+ least 4 times bigger).
It uses some static data (I know, I'm a too lasy programmer to think about
something better); this means that if you're having *two or more*
- (GtkCompletionLine)s in a program, you're looking for trouble. The static
+ GtkCompletionLine-s in a program, you're looking for trouble. The static
data will be *shared* between them, and completion might not work
- correctly. However, I don't know for sure, and I'm not going to test this.
+ correctly. However, I don't know for sure, and I'm not going to test
+ this.
- Running programs is done with "system" libc function. I dunno if it's The
- Right Thing, but it works. It might have some problems when running suid
- programs. This could be reimplemented using gnome-exec, but a lot of code
- should be rewritten, so don't bother ask me to do this.
-
Having all that said, you should know that I'm not actually a bad
- programmer; the problem being too simple for huge code complications, I
- preferred the easy way of doing different kind of things. It works pretty
+ programmer ;-] The problem being too simple for huge code complications, I
+ preferred the easy way of doing different kind of things. It works quite
fine, so "don't expect tons of C code for completion" (quoted from some
sources in mini-commander applet of GNOME).
@@ -106,6 +118,7 @@ Compilation, installation
KeySysRun="Alt+Ctrl+Shift+Enter"
+
Tips and tricks (hope that doesn't sound MS-ish...)
----------------------------------------------------
@@ -140,7 +153,7 @@ Tips and tricks (hope that doesn't sound MS-ish...)
- SPACE - the same, but clears the selection and appends one space.
- Pressing ENTER (anytime) runs the command that is written in the entry.
- Pressing CTRL+Enter (anytime) runs the command in a terminal (check your
- configuration file. But if the entry is empty (no text is present, or
+ configuration file). But if the entry is empty (no text is present, or
only whitespaces) then a fresh terminal will be started.
5. Suppose you use CTRL-R to search backwards through history. If,
View
36 config.h.in
@@ -1,8 +1,4 @@
-/* config.h.in. Generated automatically from configure.in by autoheader. */
-
-/* Define if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
+/* config.h.in. Generated from configure.in by autoheader. */
#undef ENABLE_NLS
#undef HAVE_CATGETS
#undef HAVE_GETTEXT
@@ -13,21 +9,41 @@
#undef PACKAGE_DATA_DIR
#undef PACKAGE_SOURCE_DIR
-/* Define if you have the <dirent.h> header file. */
+/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
+ */
#undef HAVE_DIRENT_H
-/* Define if you have the <ndir.h> header file. */
+/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#undef HAVE_NDIR_H
-/* Define if you have the <sys/dir.h> header file. */
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
+ */
#undef HAVE_SYS_DIR_H
-/* Define if you have the <sys/ndir.h> header file. */
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
+ */
#undef HAVE_SYS_NDIR_H
/* Name of package */
#undef PACKAGE
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
/* Version number of package */
#undef VERSION
-
View
24 config/gmrunrc
@@ -2,56 +2,46 @@
# gmrun is (C) Mihai Bazon, <mishoo@infoiasi.ro>
# GPL v2.0 applies
-
-
# Set terminal
Terminal = gnome-terminal --start-factory-server --use-factory
TermExec = ${Terminal} -e
AlwaysInTerm = ssh telnet ftp lynx mc vi vim pine centericq perldoc man
-
-
# Set window geometry (except height)
Width = 400
Top = 100
Left = 200
-
-
# History size
History = 256
-
-
# Shows last history line selected when invoked
ShowLast = 1
-
+# Show files starting with '.'
+# Default is 0 (off), set it to 1 if you want "hidden" files to show up
+# in the completion window
+ShowDotFiles = 0
# Timeout (in milliseconds) after which gmrun will simulate a TAB press
# Set this to NULL if don't like this feature.
TabTimeout = 0
-
-
# URL handlers
# If the entered text is "http://www.google.com" then:
# - %u gets replaced with the whole URL ("http://www.google.com")
# - %s gets replaced with "//www.google.com". This is useful for URL-s
# like "man:printf" --> %s will get replaced with "printf"
-
-URL_http = /usr/local/mozilla/mozilla -remote "openURL(%u, new-window)"
-URL_mailto = /usr/local/mozilla/mozilla -remote "mailto(%s)"
+URL_http = mozilla -remote "openURL(%u, new-window)"
+URL_mailto = mozilla -remote "mailto(%s)"
URL_man = ${TermExec} 'man %s'
URL_info = ${TermExec} 'info %s'
URL_pd = ${TermExec} 'perldoc %s'
-URL_file = xftree %s
+URL_file = nautilus %s
URL_readme = ${TermExec} 'less /usr/doc/%s/README'
URL_info = ${TermExec} 'info %s'
URL_sh = sh -c '%s'
-
-
# extension handlers
EXT:doc,rtf = AbiWord %s
EXT:txt,cc,cpp,h,java,html,htm,epl,tex,latex,js,css,xml,xsl,am = emacs %s
View
13 configure.in
@@ -1,7 +1,7 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(configure.in)
-AM_INIT_AUTOMAKE(gmrun, 0.8.1)
+AM_INIT_AUTOMAKE(gmrun, 0.9.1)
AM_CONFIG_HEADER(config.h)
AC_ARG_ENABLE(debug,
@@ -40,8 +40,15 @@ AC_PROG_CXX
AC_PATH_STLPORT_LIB
AC_PATH_STLPORT_INC
-AM_PATH_GTK(1.2.6, ,
- AC_MSG_ERROR(Cannot find GTK: Is gtk-config in path?))
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.0.4
+ gobject-2.0 >= 2.0.4
+ gthread-2.0 >= 2.0.4)
+AC_SUBST(GLIB_CFLAGS)
+AC_SUBST(GLIB_LIBS)
+
+PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.0.5)
+AC_SUBST(GTK_CFLAGS)
+AC_SUBST(GTK_LIBS)
dnl Set PACKAGE_DATA_DIR in config.h.
if test "x${datadir}" = 'x${prefix}/share'; then
View
43 gmrun.spec.in
@@ -1,14 +1,15 @@
%define prefix @PREFIX@
-Name: @PACKAGE@
-Version: @VERSION@
-Release: 1
-Summary: Small 'Run application' X11 utility based on GTK
-Group: X11/Utilities
-Source: %{name}-%{version}.tar.gz
-License: GPL
-Packager: Mihai Bazon <mishoo@infoiasi.ro>
-BuildPrereq: gtk+ >= 1.2.6
+Name: @PACKAGE@
+Version: @VERSION@
+Release: 2
+Summary: Small GTK based 'Run application'
+Group: X11/Utilities
+Source: %{name}-%{version}.tar.gz
+License: GPL
+Packager: Mihai Bazon <mishoo@infoiasi.ro>
+BuildPrereq: gtk+ >= 2.0.6
+BuildRoot: %{_tmppath}/%{name}-root
%description
@@ -19,20 +20,34 @@ BuildPrereq: gtk+ >= 1.2.6
%prep
%setup -q
+
%build
%configure
-./configure --prefix=%{prefix}
-make
+
%install
-make install-strip
+rm -rf %{buildroot}
+make install-strip DESTDIR=%{buildroot}
+
+%clean
+rm -rf %{buildroot}
%files
%defattr(-,root,root)
-%{_bindir}/%{name}
+ %{_bindir}/%{name}
%doc AUTHORS COPYING INSTALL README NEWS ChangeLog
-%{prefix}/share/gmrun/gmrunrc
+%dir %{_datadir}/%{name}
+ %{_datadir}/%{name}/*
%changelog
+* Sun Aug 03 2003 Mihai Bazon <mishoo@infoiasi.ro> 0.9-2
+- fixed a parsing bug in the "run command" function
+
+* Sun Jun 22 2003 Marius FERARU <altblue@n0i.net> 0.9-0.n0i
+- version 0.9
+
+* Sat Jun 14 2003 Marius FERARU <altblue@n0i.net> 0.8.1-1.n0i
+- rebuild on RHL9
+
* Sat Aug 17 2002 Mihai Bazon <mishoo@infoiasi.ro>
- Some bugs fixed, specifically the behavior of END/HOME keys (or C-E, C-A),
and the major one: you could not run a file that has an extension handler
View
166 missing
@@ -1,7 +1,7 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
-# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
-# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
+# Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -18,11 +18,37 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
+run=:
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+ configure_ac=configure.ac
+else
+ configure_ac=configure.in
+fi
+
+case "$1" in
+--run)
+ # Try to run requested program, and just exit if it succeeds.
+ run=
+ shift
+ "$@" && exit 0
+ ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
case "$1" in
-h|--h|--he|--hel|--help)
@@ -35,6 +61,7 @@ error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
+ --run try to run the given command, and emulate it if it fails
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
@@ -43,13 +70,15 @@ Supported PROGRAM values:
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
+ help2man touch the output file
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
+ tar try tar, gnutar, gtar, then tar without non-portable flags
yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
- echo "missing - GNU libit 0.0"
+ echo "missing 0.4 - GNU automake"
;;
-*)
@@ -58,31 +87,46 @@ Supported PROGRAM values:
exit 1
;;
- aclocal)
+ aclocal*)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
- you modified \`acinclude.m4' or \`configure.in'. You might want
+ you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
- you modified \`configure.in'. You might want to install the
+ you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
- you modified \`acconfig.h' or \`configure.in'. You might want
+ you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
- files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in`
+ files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
@@ -95,10 +139,15 @@ WARNING: \`$1' is missing on your system. You should only need it if
touch $touch_files
;;
- automake)
+ automake*)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
- you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'.
+ you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
@@ -106,6 +155,34 @@ WARNING: \`$1' is missing on your system. You should only need it if
while read f; do touch "$f"; done
;;
+ autom4te)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+ system. You might have modified some files without having the
+ proper tools for further handling them.
+ You can get \`$1Help2man' as part of \`Autoconf' from any GNU
+ archive site."
+
+ file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
+ test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
+ if test -f "$file"; then
+ touch $file
+ else
+ test -z "$file" || exec >$file
+ echo "#! /bin/sh"
+ echo "# Created by GNU Automake missing as a replacement of"
+ echo "# $ $@"
+ echo "exit 0"
+ chmod +x $file
+ exit 1
+ fi
+ ;;
+
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
@@ -159,7 +236,37 @@ WARNING: \`$1' is missing on your system. You should only need it if
fi
;;
+ help2man)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a dependency of a manual page. You may need the
+ \`Help2man' package in order for those modifications to take
+ effect. You can get \`Help2man' from any GNU archive site."
+
+ file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+ if test -z "$file"; then
+ file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
+ fi
+ if [ -f "$file" ]; then
+ touch $file
+ else
+ test -z "$file" || exec >$file
+ echo ".ab help2man is required to generate this page"
+ exit 1
+ fi
+ ;;
+
makeinfo)
+ if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
+ # We have makeinfo, but it failed.
+ exit 1
+ fi
+
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
@@ -175,6 +282,45 @@ WARNING: \`$1' is missing on your system. You should only need it if
touch $file
;;
+ tar)
+ shift
+ if test -n "$run"; then
+ echo 1>&2 "ERROR: \`tar' requires --run"
+ exit 1
+ fi
+
+ # We have already tried tar in the generic part.
+ # Look for gnutar/gtar before invocation to avoid ugly error
+ # messages.
+ if (gnutar --version > /dev/null 2>&1); then
+ gnutar "$@" && exit 0
+ fi
+ if (gtar --version > /dev/null 2>&1); then
+ gtar "$@" && exit 0
+ fi
+ firstarg="$1"
+ if shift; then
+ case "$firstarg" in
+ *o*)
+ firstarg=`echo "$firstarg" | sed s/o//`
+ tar "$firstarg" "$@" && exit 0
+ ;;
+ esac
+ case "$firstarg" in
+ *h*)
+ firstarg=`echo "$firstarg" | sed s/h//`
+ tar "$firstarg" "$@" && exit 0
+ ;;
+ esac
+ fi
+
+ echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+ You may want to install GNU tar or Free paxutils, or check the
+ command line arguments."
+ exit 1
+ ;;
+
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and you do not seem to have it handy on your
View
84 src/gtkcompletionline.cc
@@ -1,5 +1,5 @@
/*****************************************************************************
- * $Id: gtkcompletionline.cc,v 1.31 2002/09/24 08:13:03 mishoo Exp $
+ * $Id: gtkcompletionline.cc,v 1.32 2003/11/16 10:43:32 andreas99 Exp $
* Copyright (C) 2000, Mishoo
* Author: Mihai Bazon Email: mishoo@fenrir.infoiasi.ro
*
@@ -15,7 +15,6 @@
#include <gtk/gtkclist.h>
#include <gtk/gtkwindow.h>
#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtkframe.h>
#include <gtk/gtkmain.h>
#include <stddef.h>
@@ -50,6 +49,7 @@ enum {
SEARCH_LETTER,
SEARCH_NOT_FOUND,
EXT_HANDLER,
+ CANCEL,
LAST_SIGNAL
};
@@ -66,6 +66,7 @@ static StrSet path;
static StrSet execs;
static StrSet dirlist;
static string prefix;
+static int g_show_dot_files;
/* callbacks */
static void gtk_completion_line_class_init(GtkCompletionLineClass *klass);
@@ -105,63 +106,71 @@ gtk_completion_line_class_init(GtkCompletionLineClass *klass)
gtk_completion_line_signals[UNIQUE] =
gtk_signal_new("unique",
- GTK_RUN_FIRST, object_class->type,
+ GTK_RUN_FIRST, G_TYPE_FROM_CLASS(object_class),
GTK_SIGNAL_OFFSET(GtkCompletionLineClass,
unique),
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
gtk_completion_line_signals[NOTUNIQUE] =
gtk_signal_new("notunique",
- GTK_RUN_FIRST, object_class->type,
+ GTK_RUN_FIRST, G_TYPE_FROM_CLASS(object_class),
GTK_SIGNAL_OFFSET(GtkCompletionLineClass,
notunique),
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
gtk_completion_line_signals[INCOMPLETE] =
gtk_signal_new("incomplete",
- GTK_RUN_FIRST, object_class->type,
+ GTK_RUN_FIRST, G_TYPE_FROM_CLASS(object_class),
GTK_SIGNAL_OFFSET(GtkCompletionLineClass,
incomplete),
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
gtk_completion_line_signals[RUNWITHTERM] =
gtk_signal_new("runwithterm",
- GTK_RUN_FIRST, object_class->type,
+ GTK_RUN_FIRST, G_TYPE_FROM_CLASS(object_class),
GTK_SIGNAL_OFFSET(GtkCompletionLineClass,
runwithterm),
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
gtk_completion_line_signals[SEARCH_MODE] =
gtk_signal_new("search_mode",
- GTK_RUN_FIRST, object_class->type,
+ GTK_RUN_FIRST, G_TYPE_FROM_CLASS(object_class),
GTK_SIGNAL_OFFSET(GtkCompletionLineClass,
search_mode),
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
gtk_completion_line_signals[SEARCH_NOT_FOUND] =
gtk_signal_new("search_not_found",
- GTK_RUN_FIRST, object_class->type,
+ GTK_RUN_FIRST, G_TYPE_FROM_CLASS(object_class),
GTK_SIGNAL_OFFSET(GtkCompletionLineClass,
search_not_found),
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
gtk_completion_line_signals[SEARCH_LETTER] =
gtk_signal_new("search_letter",
- GTK_RUN_FIRST, object_class->type,
+ GTK_RUN_FIRST, G_TYPE_FROM_CLASS(object_class),
GTK_SIGNAL_OFFSET(GtkCompletionLineClass,
search_letter),
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
gtk_completion_line_signals[EXT_HANDLER] =
gtk_signal_new("ext_handler",
- GTK_RUN_FIRST, object_class->type,
+ GTK_RUN_FIRST, G_TYPE_FROM_CLASS(object_class),
GTK_SIGNAL_OFFSET(GtkCompletionLineClass,
ext_handler),
gtk_marshal_NONE__POINTER, GTK_TYPE_NONE, 1,
GTK_TYPE_POINTER);
- gtk_object_class_add_signals(object_class,
- gtk_completion_line_signals, LAST_SIGNAL);
+ gtk_completion_line_signals[CANCEL] =
+ gtk_signal_new("cancel",
+ GTK_RUN_FIRST, G_TYPE_FROM_CLASS(object_class),
+ GTK_SIGNAL_OFFSET(GtkCompletionLineClass,
+ ext_handler),
+ gtk_marshal_NONE__POINTER, GTK_TYPE_NONE, 1,
+ GTK_TYPE_POINTER);
+
+ //gtk_object_class_add_signals(object_class,
+ // gtk_completion_line_signals, LAST_SIGNAL);
klass->unique = NULL;
klass->notunique = NULL;
@@ -171,6 +180,7 @@ gtk_completion_line_class_init(GtkCompletionLineClass *klass)
klass->search_letter = NULL;
klass->search_not_found = NULL;
klass->ext_handler = NULL;
+ klass->cancel = NULL;
}
/* init */
@@ -186,6 +196,7 @@ gtk_completion_line_init(GtkCompletionLine *object)
object->hist_search_mode = GCL_SEARCH_OFF;
object->hist_word = new string;
object->tabtimeout = 0;
+ object->show_dot_files = 0;
on_key_press_handler =
gtk_signal_connect(GTK_OBJECT(object), "key_press_event",
@@ -305,6 +316,8 @@ set_words(GtkCompletionLine *object, const vector<string>& words, int pos = -1)
if (pos != string::npos)
gtk_signal_emit_by_name(
GTK_OBJECT(object), "ext_handler", s.substr(pos + 1).c_str());
+ else
+ gtk_signal_emit_by_name(GTK_OBJECT(object), "ext_handler", NULL);
}
gtk_entry_set_text(GTK_ENTRY(object), ss.str().c_str());
@@ -341,6 +354,8 @@ select_executables_only(const struct dirent* dent)
int lenp = prefix.length();
if (dent->d_name[0] == '.') {
+ if (!g_show_dot_files)
+ return 0;
if (dent->d_name[1] == '\0')
return 0;
if ((dent->d_name[1] == '.') && (dent->d_name[2] == '\0'))
@@ -417,13 +432,10 @@ generate_completion_from_execs(GtkCompletionLine *object)
}
static string
-get_common_part(const char *s1, const char *s2)
+get_common_part(const char *p1, const char *p2)
{
string ret;
- const char *p1 = s1;
- const char *p2 = s2;
-
while (*p1 == *p2 && *p1 != '\0' && *p2 != '\0') {
ret += *p1;
p1++;
@@ -536,7 +548,7 @@ static int
parse_tilda(GtkCompletionLine *object)
{
string text = gtk_entry_get_text(GTK_ENTRY(object));
- size_t where = text.find("~");
+ gint where = (gint)text.find("~");
if (where != string::npos) {
if ((where > 0) && (text[where - 1] != ' '))
return 0;
@@ -547,8 +559,8 @@ parse_tilda(GtkCompletionLine *object)
size_t i = home.length() - 1;
while ((i >= 0) && (home[i] == '/'))
home.erase(i--);
- text.replace(where, 1, home);
- gtk_entry_set_text(GTK_ENTRY(object), text.c_str());
+ gtk_editable_insert_text(GTK_EDITABLE(object), home.c_str(), home.length(), &where);
+ gtk_editable_delete_text(GTK_EDITABLE(object), where, where + 1);
}
}
@@ -636,6 +648,7 @@ complete_line(GtkCompletionLine *object)
int pos = get_words(object, words);
prefix = words[pos];
+ g_show_dot_files = object->show_dot_files;
if (prefix[0] != '/') {
if (object->where == NULL) {
generate_path();
@@ -688,10 +701,6 @@ complete_line(GtkCompletionLine *object)
object->win_compl = gtk_window_new(GTK_WINDOW_POPUP);
gtk_widget_set_name(object->win_compl, "Msh_Run_Window");
- GtkWidget *the_frame = gtk_frame_new("");
- gtk_frame_set_shadow_type(GTK_FRAME(the_frame), GTK_SHADOW_OUT);
- gtk_widget_show(the_frame);
-
/*gtk_window_set_position(GTK_WINDOW(object->win_compl),
GTK_WIN_POS_MOUSE);*/
@@ -720,24 +729,22 @@ complete_line(GtkCompletionLine *object)
}
GtkWidget *scroll = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll), GTK_SHADOW_OUT);
gtk_widget_show(scroll);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scroll),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
- gtk_container_set_border_width(GTK_CONTAINER(scroll), 5);
-
+ gtk_container_set_border_width(GTK_CONTAINER(object->list_compl), 2);
gtk_container_add(GTK_CONTAINER (scroll), object->list_compl);
object->list_compl_items_where = 0;
gtk_widget_show(object->list_compl);
- int w = gtk_clist_optimal_column_width(GTK_CLIST(object->list_compl),
- 0);
+ int w = gtk_clist_optimal_column_width(GTK_CLIST(object->list_compl), 0);
gtk_widget_set_usize(scroll, w + 40, 150);
- gtk_container_add(GTK_CONTAINER(object->win_compl), the_frame);
- gtk_container_add(GTK_CONTAINER(the_frame), scroll);
+ gtk_container_add(GTK_CONTAINER(object->win_compl), scroll);
GdkWindow *top = gtk_widget_get_parent_window(GTK_WIDGET(object));
int x, y;
@@ -746,8 +753,9 @@ complete_line(GtkCompletionLine *object)
y += GTK_WIDGET(object)->allocation.y +
GTK_WIDGET(object)->allocation.height;
- gtk_widget_popup(object->win_compl, x, y);
- // gtk_widget_show(object->win_compl);
+ // gtk_widget_popup(object->win_compl, x, y);
+ gtk_window_move(GTK_WINDOW(object->win_compl), x, y);
+ gtk_widget_show(object->win_compl);
gtk_clist_select_row(GTK_CLIST(object->list_compl),
object->list_compl_items_where, 0);
@@ -1000,7 +1008,7 @@ on_key_press(GtkCompletionLine *cl, GdkEventKey *event, gpointer data)
}
}
}
- return TRUE;
+ return FALSE;
case GDK_Down:
if (cl->win_compl != NULL) {
@@ -1096,9 +1104,15 @@ on_key_press(GtkCompletionLine *cl, GdkEventKey *event, gpointer data)
case GDK_Escape:
if (MODE_SRC) {
search_off(cl);
- STOP_PRESS;
- return TRUE;
- } else goto ordinary;
+ } else if (cl->win_compl != NULL) {
+ gtk_widget_destroy(cl->win_compl);
+ cl->win_compl = NULL;
+ } else {
+ // user cancelled
+ gtk_signal_emit_by_name(GTK_OBJECT(cl), "cancel");
+ }
+ STOP_PRESS;
+ return TRUE;
case GDK_G:
case GDK_g:
View
9 src/gtkcompletionline.h
@@ -1,5 +1,5 @@
/*****************************************************************************
- * $Id: gtkcompletionline.h,v 1.11 2002/08/16 10:30:18 mishoo Exp $
+ * $Id: gtkcompletionline.h,v 1.12 2003/11/16 10:43:32 andreas99 Exp $
* Copyright (C) 2000, Mishoo
* Author: Mihai Bazon Email: mishoo@fenrir.infoiasi.ro
*
@@ -57,6 +57,7 @@ extern "C++" {
int first_key;
int tabtimeout;
+ int show_dot_files;
};
struct _GtkCompletionLineClass
@@ -72,6 +73,7 @@ extern "C++" {
void (* search_letter)(GtkCompletionLine *cl);
void (* search_not_found)(GtkCompletionLine *cl);
void (* ext_handler)(GtkCompletionLine *cl);
+ void (* cancel)(GtkCompletionLine *cl);
};
guint gtk_completion_line_get_type(void);
@@ -81,3 +83,8 @@ extern "C++" {
}
#endif /* __GTKCOMPLETIONLINE_H__ */
+
+// Local Variables: ***
+// mode: c++ ***
+// c-basic-offset: 2 ***
+// End: ***
View
91 src/main.cc
@@ -1,5 +1,5 @@
/*****************************************************************************
- * $Id: main.cc,v 1.24 2002/08/17 13:19:31 mishoo Exp $
+ * $Id: main.cc,v 1.25 2003/11/16 10:43:32 andreas99 Exp $
* Copyright (C) 2000, Mishoo
* Author: Mihai Bazon Email: mishoo@fenrir.infoiasi.ro
*
@@ -41,8 +41,30 @@ struct gigi
GtkWidget *w2;
};
+/// BEGIN: TIMEOUT MANAGEMENT
+
static gint search_off_timeout(struct gigi *g);
+static guint g_search_off_timeout_id = 0;
+
+static void remove_search_off_timeout()
+{
+ if (g_search_off_timeout_id) {
+ gtk_timeout_remove(g_search_off_timeout_id);
+ g_search_off_timeout_id = 0;
+ }
+}
+
+static void add_search_off_timeout(guint32 timeout, struct gigi *g, GtkFunction func = 0)
+{
+ remove_search_off_timeout();
+ if (!func)
+ func = GtkFunction(search_off_timeout);
+ g_search_off_timeout_id = gtk_timeout_add(timeout, func, g);
+}
+
+/// END: TIMEOUT MANAGEMENT
+
GtkStyle* style_normal(GtkWidget *w)
{
static GtkStyle *style;
@@ -110,7 +132,7 @@ run_with_system(const std::string& command, struct gigi* g)
#endif
gtk_label_set_text(GTK_LABEL(g->w1), error.c_str());
gtk_widget_set_style(g->w1, style_notfound(g->w1));
- gtk_timeout_add(2000, GtkFunction(search_off_timeout), g);
+ add_search_off_timeout(2000, g);
}
}
@@ -146,6 +168,7 @@ run_the_command(const std::string& command, struct gigi* g)
CT_ESCAPE
};
TYPE_CONTEXT context = CT_NORMAL;
+ TYPE_CONTEXT save_context = CT_NORMAL;
string tmp;
char c;
@@ -158,6 +181,7 @@ run_the_command(const std::string& command, struct gigi* g)
switch (c) {
case '\\':
if (context != CT_ESCAPE) {
+ save_context = context;
context = CT_ESCAPE;
} else {
goto ordinary;
@@ -199,7 +223,7 @@ run_the_command(const std::string& command, struct gigi* g)
ordinary:
default:
if (context == CT_ESCAPE) {
- context = CT_NORMAL;
+ context = save_context;
tmp += c;
} else if (context == CT_QUOTE) {
tmp += c;
@@ -227,7 +251,7 @@ run_the_command(const std::string& command, struct gigi* g)
gtk_label_set_text(GTK_LABEL(g->w1), error.c_str());
gtk_widget_set_style(g->w1, style_notfound(g->w1));
- gtk_timeout_add(2000, GtkFunction(search_off_timeout), g);
+ add_search_off_timeout(2000, g);
}
#endif
@@ -235,7 +259,7 @@ static void
on_ext_handler(GtkCompletionLine *cl, const char* ext, struct gigi* g)
{
string cmd;
- if (configuration.get_ext_handler(ext, cmd)) {
+ if (ext && configuration.get_ext_handler(ext, cmd)) {
string str("Handler: ");
size_t pos = cmd.find_first_of(" \t");
if (pos == string::npos)
@@ -244,7 +268,9 @@ on_ext_handler(GtkCompletionLine *cl, const char* ext, struct gigi* g)
str += cmd.substr(0, pos);
gtk_label_set_text(GTK_LABEL(g->w2), str.c_str());
gtk_widget_show(g->w2);
- gtk_timeout_add(1000, GtkFunction(search_off_timeout), g);
+ // gtk_timeout_add(1000, GtkFunction(search_off_timeout), g);
+ } else {
+ search_off_timeout(g);
}
}
@@ -296,7 +322,7 @@ on_compline_unique(GtkCompletionLine *cl, struct gigi *g)
{
gtk_label_set_text(GTK_LABEL(g->w1), "unique");
gtk_widget_set_style(g->w1, style_unique(g->w1));
- gtk_timeout_add(1000, GtkFunction(search_off_timeout), g);
+ add_search_off_timeout(1000, g);
}
static void
@@ -304,7 +330,7 @@ on_compline_notunique(GtkCompletionLine *cl, struct gigi *g)
{
gtk_label_set_text(GTK_LABEL(g->w1), "not unique");
gtk_widget_set_style(g->w1, style_notunique(g->w1));
- gtk_timeout_add(1000, GtkFunction(search_off_timeout), g);
+ add_search_off_timeout(1000, g);
}
static void
@@ -312,7 +338,7 @@ on_compline_incomplete(GtkCompletionLine *cl, struct gigi *g)
{
gtk_label_set_text(GTK_LABEL(g->w1), "not found");
gtk_widget_set_style(g->w1, style_notfound(g->w1));
- gtk_timeout_add(1000, GtkFunction(search_off_timeout), g);
+ add_search_off_timeout(1000, g);
}
static void
@@ -325,7 +351,7 @@ on_search_mode(GtkCompletionLine *cl, struct gigi *g)
} else {
gtk_widget_hide(g->w2);
gtk_label_set_text(GTK_LABEL(g->w1), "Search OFF");
- gtk_timeout_add(1000, GtkFunction(search_off_timeout), g);
+ add_search_off_timeout(1000, g);
}
}
@@ -349,7 +375,7 @@ on_search_not_found(GtkCompletionLine *cl, struct gigi *g)
{
gtk_label_set_text(GTK_LABEL(g->w1), "Not Found!");
gtk_widget_set_style(g->w2, style_notfound(g->w2));
- gtk_timeout_add(1000, GtkFunction(search_fail_timeout), g);
+ add_search_off_timeout(1000, g, GtkFunction(search_fail_timeout));
}
static bool
@@ -373,16 +399,23 @@ url_check(GtkCompletionLine *cl, struct gigi *g)
string url_handler;
if (configuration.get_string(string("URL_") + url_type, url_handler)) {
- string::size_type j;
+ string::size_type j = 0;
+
+ do {
+ j = url_handler.find("%s", j);
+ if (j != string::npos) {
+ url_handler.replace(j, 2, url);
+ }
+ } while (j != string::npos);
+
+ j = 0;
+ do {
+ j = url_handler.find("%u", j);
+ if (j != string::npos) {
+ url_handler.replace(j, 2, text);
+ }
+ } while (j != string::npos);
- j = url_handler.find("%s");
- if (j != string::npos) {
- url_handler.replace(j, 2, url);
- }
- j = url_handler.find("%u");
- if (j != string::npos) {
- url_handler.replace(j, 2, text);
- }
cl->hist->append(text.c_str());
cl->hist->sync_the_file();
run_the_command(url_handler.c_str(), g);
@@ -392,7 +425,7 @@ url_check(GtkCompletionLine *cl, struct gigi *g)
(string("No URL handler for [") +
url_type + "]").c_str());
gtk_widget_set_style(g->w1, style_notfound(g->w1));
- gtk_timeout_add(1000, GtkFunction(search_off_timeout), g);
+ add_search_off_timeout(1000, g);
return true;
}
}
@@ -517,15 +550,16 @@ int main(int argc, char **argv)
gtk_misc_set_padding(GTK_MISC(label_search), 10, 0);
gtk_box_pack_start(GTK_BOX(hhbox), label_search, TRUE, TRUE, 0);
- GtkAccelGroup *accels = gtk_accel_group_new();
- gtk_window_add_accel_group(GTK_WINDOW(win), accels);
-
compline = gtk_completion_line_new();
gtk_widget_set_name(compline, "Msh_Run_Compline");
int prefs_width;
if (!configuration.get_int("Width", prefs_width))
prefs_width = 500;
+ // don't show files starting with "." by default
+ if (!configuration.get_int("ShowDotFiles", GTK_COMPLETION_LINE(compline)->show_dot_files))
+ GTK_COMPLETION_LINE(compline)->show_dot_files = 0;
+
{
int tmp;
if (configuration.get_int("TabTimeout", tmp))
@@ -536,9 +570,7 @@ int main(int argc, char **argv)
g.w2 = label_search;
gtk_widget_set_usize(compline, prefs_width, -2);
- gtk_widget_add_accelerator(compline, "destroy", accels,
- GDK_Escape, 0, (GtkAccelFlags)0);
- gtk_signal_connect(GTK_OBJECT(compline), "destroy",
+ gtk_signal_connect(GTK_OBJECT(compline), "cancel",
GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
gtk_signal_connect(GTK_OBJECT(compline), "activate",
GTK_SIGNAL_FUNC(on_compline_activated), &g);
@@ -584,3 +616,8 @@ int main(int argc, char **argv)
gtk_main();
}
+
+// Local Variables: ***
+// mode: c++ ***
+// c-basic-offset: 2 ***
+// End: ***
Please sign in to comment.
Something went wrong with that request. Please try again.