Permalink
Browse files

Code separated into several files, key binding testing and preference…

…s dialog.
  • Loading branch information...
1 parent 5e6ca6d commit 036e3209a36c259b300399a4f58a11ed424ed6f7 @dnohales committed Jan 17, 2012
@@ -5,9 +5,23 @@ function removeElementById(id){
}
}
+function safeElemHandle(id, handler){
+ var elem = document.getElementById(id);
+ if(elem){
+ handler(elem);
+ }
+}
+
removeElementById("gb");
removeElementById("gt-logo");
removeElementById("gt-ft-mkt");
removeElementById("select_document");
removeElementById("gt-res-tip");
-document.getElementById("ft-r").innerHTML = "Powered by Google";
+
+safeElemHandle("gt-res-dict", function(elem){
+ elem.style.marginTop = "0em";
+});
+safeElemHandle("ft-r", function(elem){
+ elem.innerHTML = "Powered by Google";
+});
+
@@ -0,0 +1,217 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="2.24"/>
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkDialog" id="preferences_dialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Gablabel preferences</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">5</property>
+ <child>
+ <object class="GtkFrame" id="frame1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">out</property>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="top_padding">5</property>
+ <property name="bottom_padding">5</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="row_spacing">5</property>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Translate clipboard text:</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Translate selected text:</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="entry1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_padding">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="entry2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_padding">5</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Key bindings</property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="top_padding">10</property>
+ <property name="left_padding">5</property>
+ <property name="right_padding">5</property>
+ <child>
+ <object class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0.029999999329447746</property>
+ <property name="label" translatable="yes">Use this domain to launch translator:</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="combobox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAspectFrame" id="aspectframe1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHSeparator" id="hseparator1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="button1">
+ <property name="label">gtk-close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">button1</action-widget>
+ </action-widgets>
+ </object>
+</interface>
View
@@ -0,0 +1,66 @@
+namespace Gablabel
+{
+ public class Application : GLib.Object
+ {
+ private static Application singleton_instance = null;
+
+ public static Application get_instance(){
+ return Application.singleton_instance;
+ }
+
+ enum BindingName {
+ CLIPBOARD,
+ SELECTED
+ }
+
+ public MainWindow window { get; private set; }
+ public StatusIconManager statusIcon { get; private set; }
+ public KeyBindingManager keyBindings { get; private set; }
+ public GLib.Settings settings { get; private set; }
+ private Gee.Map<Application.BindingName, string> currentBindings = new Gee.HashMap<Application.BindingName, string>();
+
+ private Application(string[] args){
+ Gtk.init(ref args);
+
+ Intl.bindtextdomain( Config.GETTEXT_PACKAGE, Config.LOCALEDIR );
+ Intl.bind_textdomain_codeset( Config.GETTEXT_PACKAGE, "UTF-8" );
+ Intl.textdomain( Config.GETTEXT_PACKAGE );
+ }
+
+ public int run(){
+ try{
+ window = new Gablabel.MainWindow();
+ statusIcon = new StatusIconManager(window);
+ window.start();
+ statusIcon.start();
+
+ keyBindings = new KeyBindingManager();
+ keyBindings.bind("<Ctrl><Alt>S", (event) => {
+ statusIcon.on_selected_activated();
+ });
+
+ settings = new GLib.Settings("es.nohal.gablabel");
+ settings.changed
+
+ Gtk.main();
+ return 0;
+ } catch(Error e){
+ stderr.printf("Failed to load the UI file: " + e.message);
+ return 1;
+ }
+ }
+
+ private void refreshBindings(){
+
+ }
+
+ public static int main(string[] args){
+ Application a = new Application(args);
+ return a.run();
+ }
+ }
+
+ public Application App(){
+ return Application.get_instance();
+ }
+}
View
@@ -1,5 +1,10 @@
set(VALA_SRC
- gablabel.vala
+ Application.vala
+ MainWindow.vala
+ StatusIconManager.vala
+ TranslatorWebView.vala
+ KeyBindingManager.vala
+ PreferencesDialogManager.vala
)
find_package(PkgConfig)
@@ -8,22 +13,26 @@ pkg_check_modules(GIO REQUIRED gio-2.0)
pkg_check_modules(GTK REQUIRED gtk+-2.0)
pkg_check_modules(WEBKIT REQUIRED webkit-1.0)
pkg_check_modules(APPINDICATOR REQUIRED appindicator-0.1)
+pkg_check_modules(GEE REQUIRED gee-1.0)
set(CFLAGS
${GOBJECT_CFLAGS} ${GOBJECT_CFLAGS_OTHER}
${GIO_CFLAGS} ${GIO_CFLAGS_OTHER}
${GTK_CFLAGS} ${GTK_CFLAGS_OTHER}
${WEBKIT_CFLAGS} ${WEBKIT_CFLAGS_OTHER}
${APPINDICATOR_CFLAGS} ${APPINDICATOR_CFLAGS_OTHER}
+ ${GEE_CFLAGS} ${GEE_CFLAGS_OTHER}
)
add_definitions(${CFLAGS})
+add_definitions("--include config.h")
set(LIBS
${GOBJECT_LIBRARIES}
${GIO_LIBRARIES}
${GTK_LIBRARIES}
${WEBKIT_LIBRARIES}
${APPINDICATOR_LIBRARIES}
+ ${GEE_LIBRARIES}
)
set(LIB_PATHS
@@ -32,6 +41,7 @@ set(LIB_PATHS
${GTK_LIBRARY_DIRS}
${WEBKIT_LIBRARY_DIRS}
${APPINDICATOR_LIBRARY_DIRS}
+ ${GEE_LIBRARY_DIRS}
)
link_directories(${LIB_PATHS})
@@ -47,6 +57,9 @@ vala_precompile(VALA_C
${VALA_SRC}
PACKAGES
config
+ gee-1.0
+ gdk-x11-2.0
+ x11
webkit-1.0
gtk+-2.0
appindicator-0.1
Oops, something went wrong.

0 comments on commit 036e320

Please sign in to comment.