/* HexChat * Copyright (C) 1998-2010 Peter Zelezny. * Copyright (C) 2009-2013 Berke Viktor. * * 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 * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ /* file included in chanview.c */ typedef struct { GtkWidget *outer; /* outer box */ GtkWidget *inner; /* inner box */ GtkWidget *b1; /* button1 */ GtkWidget *b2; /* button2 */ } tabview; static void chanview_populate (chanview *cv); /* ignore "toggled" signal? */ static int ignore_toggle = FALSE; static int tab_left_is_moving = 0; static int tab_right_is_moving = 0; /* userdata for gobjects used here: * * tab (togglebuttons inside boxes): * "u" userdata passed to tab-focus callback function (sess) * "c" the tab's (chan *) * * box (family box) * "f" family * */ /* * GtkViewports request at least as much space as their children do. * If we don't intervene here, the GtkViewport will be granted its * request, even at the expense of resizing the top-level window. */ static void cv_tabs_sizerequest (GtkWidget *viewport, GtkRequisition *requisition, chanview *cv) { if (!cv->vertical) requisition->width = 1; else requisition->height = 1; } static void cv_tabs_sizealloc (GtkWidget *widget, GtkAllocation *allocation, chanview *cv) { GdkWindow *parent_win; GtkAdjustment *adj; GtkWidget *inner; gint viewport_size; inner = ((tabview *)cv)->inner; parent_win = gtk_widget_get_window (gtk_widget_get_parent (inner)); if (cv->vertical) { adj = gtk_viewport_get_vadjustment (GTK_VIEWPORT (gtk_widget_get_parent (inner))); gdk_window_get_geometry (parent_win, 0, 0, 0, &viewport_size, 0); } else { adj = gtk_viewport_get_hadjustment (GTK_VIEWPORT (gtk_widget_get_parent (inner))); gdk_window_get_geometry (parent_win, 0, 0, &viewport_size, 0, 0); } if (gtk_adjustment_get_upper (adj) <= viewport_size) { gtk_widget_hide (((tabview *)cv)->b1); gtk_widget_hide (((tabview *)cv)->b2); } else { gtk_widget_show (((tabview *)cv)->b1); gtk_widget_show (((tabview *)cv)->b2); } } static gint tab_search_offset (GtkWidget *inner, gint start_offset, gboolean forward, gboolean vertical) { GList *boxes; GList *tabs; GtkWidget *box; GtkWidget *button; GtkAllocation allocation; gint found; boxes = gtk_container_get_children (GTK_CONTAINER (inner)); if (!forward && boxes) boxes = g_list_last (boxes); while (boxes) { box = (GtkWidget *)boxes->data; boxes = (forward ? boxes->next : boxes->prev); tabs = gtk_container_get_children (GTK_CONTAINER (box)); if (!forward && tabs) tabs = g_list_last (tabs); while (tabs) { button = (GtkWidget *)tabs->data; tabs = (forward ? tabs->next : tabs->prev); if (!GTK_IS_TOGGLE_BUTTON (button)) continue; gtk_widget_get_allocation (button, &allocation); found = (vertical ? allocation.y : allocation.x); if ((forward && found > start_offset) || (!forward && found < start_offset)) return found; } } return 0; } static void tab_scroll_left_up_clicked (GtkWidget *widget, chanview *cv) { GtkAdjustment *adj; gint viewport_size; gfloat new_value; GtkWidget *inner; GdkWindow *parent_win; gdouble i; inner = ((tabview *)cv)->inner; parent_win = gtk_widget_get_window (gtk_widget_get_parent (inner)); if (cv->vertical) { adj = gtk_viewport_get_vadjustment (GTK_VIEWPORT (gtk_widget_get_parent(inner))); gdk_window_get_geometry (parent_win, 0, 0, 0, &viewport_size, 0); } else { adj = gtk_viewport_get_hadjustment (GTK_VIEWPORT (gtk_widget_get_parent(inner))); gdk_window_get_geometry (parent_win, 0, 0, &viewport_size, 0, 0); } new_value = tab_search_offset (inner, gtk_adjustment_get_value (adj), 0, cv->vertical); if (new_value + viewport_size > gtk_adjustment_get_upper (adj)) new_value = gtk_adjustment_get_upper (adj) - viewport_size; if (!tab_left_is_moving) { tab_left_is_moving = 1; for (i = gtk_adjustment_get_value (adj); ((i > new_value) && (tab_left_is_moving)); i -= 0.1) { gtk_adjustment_set_value (adj, i); while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); } gtk_adjustment_set_value (adj, new_value); tab_left_is_moving = 0; /* hSP: set to false in case we didnt get stopped (the normal case) */ } else { tab_left_is_moving = 0; /* hSP: jump directly to next element if user is clicking faster than we can scroll.. */ } } static void tab_scroll_right_down_clicked (GtkWidget *widget, chanview *cv) { GtkAdjustment *adj; gint viewport_size; gfloat new_value; GtkWidget *inner; GdkWindow *parent_win; gdouble i; inner = ((tabview *)cv)->inner; parent_win = gtk_widget_get_window (gtk_widget_get_parent (inner)); if (cv->vertical) { adj = gtk_viewport_get_vadjustment (GTK_VIEWPORT (gtk_widget_get_parent(inner))); gdk_window_get_geometry (parent_win, 0, 0, 0, &viewport_size, 0); } else { adj = gtk_viewport_get_hadjustment (GTK_VIEWPORT (gtk_widget_get_parent(inner))); gdk_window_get_geometry (parent_win, 0, 0, &viewport_size, 0, 0); } new_value = tab_search_offset (inner, gtk_adjustment_get_value (adj), 1, cv->vertical); if (new_value == 0 || new_value + viewport_size > gtk_adjustment_get_upper (adj)) new_value = gtk_adjustment_get_upper (adj) - viewport_size; if (!tab_right_is_moving) { tab_right_is_moving = 1; for (i = gtk_adjustment_get_value (adj); ((i < new_value) && (tab_right_is_moving)); i += 0.1) { gtk_adjustment_set_value (adj, i); while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); } gtk_adjustment_set_value (adj, new_value); tab_right_is_moving = 0; /* hSP: set to false in case we didnt get stopped (the normal case) */ } else { tab_right_is_moving = 0; /* hSP: jump directly to next element if user is clicking faster than we can scroll.. */ } } static gboolean tab_scroll_cb (GtkWidget *widget, GdkEventScroll *event, gpointer cv) { if (prefs.hex_gui_tab_scrollchans) { if (event->direction == GDK_SCROLL_DOWN) mg_switch_page (1, 1); else if (event->direction == GDK_SCROLL_UP) mg_switch_page (1, -1); } else { /* mouse wheel scrolling */ if (event->direction == GDK_SCROLL_UP) tab_scroll_left_up_clicked (widget, cv); else if (event->direction == GDK_SCROLL_DOWN) tab_scroll_right_down_clicked (widget, cv); } return FALSE; } static void cv_tabs_xclick_cb (GtkWidget *button, chanview *cv) { cv->cb_xbutton (cv, cv->focused, cv->focused->tag, cv->focused->userdata); } /* make a Scroll (arrow) button */ static GtkWidget * make_sbutton (GtkArrowType type, void *click_cb, void *userdata) { GtkWidget *button, *arro
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{E93E1255-95D1-4B08-8FDF-B53CC6A21280}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>fetext</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\hexchat.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\hexchat.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>hexchat-text</TargetName>
<OutDir>$(HexChatBin)</OutDir>
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>hexchat-text</TargetName>
<OutDir>$(HexChatBin)</OutDir>
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>$(DepLibs);"$(OutDir)\common.lib";%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_CONSOLE;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>$(DepLibs);"$(OutDir)\common.lib";%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="fe-text.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="fe-text.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>